9393
9494--- @type XML.GeneratorTable
9595export .generator_metatable = setmetatable ({}, {
96- --- @param self XML.GeneratorTable
96+ --- @param _ XML.GeneratorTable
9797 --- @param tag_name string
98- __index = function (self , tag_name )
98+ __index = function (_ , tag_name )
9999 --- @param attributes { [string] : string , [integer] : (XML.Node | string | fun (): XML.Node ) } | string
100100 --- @return table | fun ( children : ( XML.Node | string | fun (): XML.Node ) [] ): XML.Node
101101 return function (attributes )
@@ -107,19 +107,21 @@ export.generator_metatable = setmetatable({}, {
107107 }
108108
109109 -- if we have a situation such as
110- --[[
111- tag "string"
112- ]]
110+ --- ```lua
111+ --- tag "string"
112+ --- ```
113113 --
114114 -- then the content is the `string`
115115 local tname = typename (attributes )
116- if tname ~= " table" and tname ~= " HTML .Node" then
116+ if tname ~= " table" and tname ~= " XML .Node" then
117117 node .attributes = attributes and { tostring (attributes ) } or {}
118118 elseif tname == " XML.Node" then
119+
120+ --- ```lua
119121 --- local tag = div { p "hi" }
120122 --- div(tag)
123+ --- ```
121124 node .children = { attributes }
122- attributes = {}
123125 else
124126 node .attributes = attributes --[[ @as any]]
125127 end
@@ -210,7 +212,10 @@ function export.html_table(tbl)
210212 return xml .table {
211213 function ()
212214 local function getval (v )
213- if typename (v ) ~= " table" and (typename (v ) ~= " XML.Node" and (getmetatable (v ) or {}).__tostring ~= nil ) then
215+ local tname = typename (v )
216+ if tname == " XML.Node" then return v end
217+
218+ if typename (v ) ~= " table" or (getmetatable (v ) or {}).__tostring then
214219 return tostring (v )
215220 end
216221
0 commit comments