Differences From
Artifact [38c6bac1b2]:
221 221 local sec = secptr.ref
222 222 if sec.heading_node then -- does this section have a label?
223 223 local ent = tag('li',nil,
224 224 catenate{tag('a', {href='#'..getSafeID(sec)},
225 225 sr.htmlSpan(sec.heading_node.spans, sec.heading_node, sec))})
226 226 if secptr.depth > #stack then
227 227 local n = {tag = 'ol', attrs={}, nodes={ent}}
228 - table.insert(top().nodes[#top().nodes].nodes, n)
228 + if top() then
229 + table.insert(top().nodes[#top().nodes].nodes, n)
230 + end
229 231 table.insert(stack, n)
230 232 else
231 233 if secptr.depth < #stack then
232 234 for j=#stack,secptr.depth+1,-1 do stack[j] = nil end
233 235 end
234 - table.insert(top().nodes, ent)
236 + if top() then
237 + table.insert(top().nodes, ent)
238 + end
235 239 end
236 240
237 241 -- now we need to assemble a list of items within the
238 242 -- section worthy of an entry on their own. currently
239 243 -- this is only anchors created with %toc mark|name
240 244 local innerlinks = {}
241 245 local noteworthy = { anchor = true }