rendered paste body<ol>
<li><a href="#sandbox">Sandbox</a>
<ol>
<li><a href="#your-text-below-here">Your Text Below Here</a></li>
</ol>
</li>
<li><a href="#test">Test</a>
<ol>
<li><a href="#test2">Test2</a></li>
</ol>
</li>
</ol>
def toc_rows(rows):
ldepth = 0
tmp = ''
for depth,phrase in rows:
if ldepth != depth:
tmp += "\n</ol>\n</li>"*(depth-ldepth-1)
i = 0
while i < depth-ldepth:
if depth-i > 1:
tmp += "</li>"
tmp += "\n<ol>"
i += 1
else:
tmp += '</li>'
tmp += "\n<li><a href=\"#%s\">%s</a>" % (safe_name(phrase), phrase)
ldepth = depth
tmp += "</li>\n</ol>"*ldepth
return tmp