93
93
94
94
--- @type XML.GeneratorTable
95
95
export .generator_metatable = setmetatable ({}, {
96
- --- @param self XML.GeneratorTable
96
+ --- @param _ XML.GeneratorTable
97
97
--- @param tag_name string
98
- __index = function (self , tag_name )
98
+ __index = function (_ , tag_name )
99
99
--- @param attributes { [string] : string , [integer] : (XML.Node | string | fun (): XML.Node ) } | string
100
100
--- @return table | fun ( children : ( XML.Node | string | fun (): XML.Node ) [] ): XML.Node
101
101
return function (attributes )
@@ -107,19 +107,21 @@ export.generator_metatable = setmetatable({}, {
107
107
}
108
108
109
109
-- if we have a situation such as
110
- --[[
111
- tag "string"
112
- ]]
110
+ --- ```lua
111
+ --- tag "string"
112
+ --- ```
113
113
--
114
114
-- then the content is the `string`
115
115
local tname = typename (attributes )
116
- if tname ~= " table" and tname ~= " HTML .Node" then
116
+ if tname ~= " table" and tname ~= " XML .Node" then
117
117
node .attributes = attributes and { tostring (attributes ) } or {}
118
118
elseif tname == " XML.Node" then
119
+
120
+ --- ```lua
119
121
--- local tag = div { p "hi" }
120
122
--- div(tag)
123
+ --- ```
121
124
node .children = { attributes }
122
- attributes = {}
123
125
else
124
126
node .attributes = attributes --[[ @as any]]
125
127
end
@@ -210,7 +212,10 @@ function export.html_table(tbl)
210
212
return xml .table {
211
213
function ()
212
214
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
214
219
return tostring (v )
215
220
end
216
221
0 commit comments