Method: IsoDoc::HtmlFunction::Html#html_toc
- Defined in:
- lib/isodoc/html_function/html.rb
#html_toc(docxml) ⇒ Object
299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/isodoc/html_function/html.rb', line 299 def html_toc(docxml) =begin idx = docxml.at("//div[@id = 'toc']") or return docxml toc = "<ul>" tocidx = 0 docxml.xpath("//main//h1 | //main//h2[not(@class = 'TermNum')]").each do |h| h["id"] ||= "toc#{tocidx}" toc += html_toc_entry(h.name == "h1" ? 1 : 2, h) tocidx += 1 end idx.children = "#{toc}</ul>" =end docxml end |