Commit 93dddf9eb7b3263beda332e79ee84cf8ab9c13bb

  • Tree SHA1: 2fa660b
  • Parent SHA1: c38f181 (Fixed ticket 35. Lists now work when padded with five or more spaces after asterisk. Adjusted regex to eat all (one or more) of the spaces. While it may seem wrong (at least in the loose list case), this is how all other implementations work. And it solves a number of edge cases otherwise not accounted for in the list parser.)
  • raw diff | raw patch
Fixed TOC extension to properly nest multiple header levels in the table of contents. Specificly, when stepping back multiple levels, the nestsed listed now follow suite. Test included. Thanks for the patch Jack Miller.
  
6060 if header_rgx.match(c.tag):
6161 tag_level = int(c.tag[-1])
6262
63 # Regardless of how many levels we jumped
64 # only one list should be created, since
65 # empty lists containing lists are illegal.
66
67 if tag_level < level:
63 while tag_level < level:
6864 list_stack.pop()
69 level = tag_level
65 level -= 1
7066
7167 if tag_level > level:
7268 newlist = etree.Element("ul")
7171 else:
7272 list_stack[-1].append(newlist)
7373 list_stack.append(newlist)
74 level = tag_level
74 level += 1
7575
7676 # Do not override pre-existing ids
7777 if not "id" in c.attrib:
  
1<h1 id="header-a">Header A</h1>
2<h2 id="header-1">Header 1</h2>
3<h3 id="header-i">Header i</h3>
4<h1 id="header-b">Header B</h1>
5<div class="toc">
6<ul>
7<li><a href="#header-a">Header A</a><ul>
8<li><a href="#header-1">Header 1</a><ul>
9<li><a href="#header-i">Header i</a></li>
10</ul>
11</li>
12</ul>
13</li>
14<li><a href="#header-b">Header B</a></li>
15</ul>
16</div>
  
1# Header A
2
3## Header 1
4
5### Header i
6
7# Header B
8
9[TOC]