|
@@ -76,17 +76,19 @@ class HtmlTreeNode(object):
|
|
|
return self.parent.add(new_header, ids)
|
|
|
|
|
|
def __str__(self):
|
|
|
- ret = "<a class='toc-href' href='#{0}' title='{1}'>{1}</a>".format(
|
|
|
- self.id, self.header) if self.header else ""
|
|
|
-
|
|
|
if self.children:
|
|
|
- ret += "<ul>{}</ul>".format('{}'*len(self.children)).format(
|
|
|
- *self.children)
|
|
|
-
|
|
|
- ret = "<li>{}</li>".format(ret)
|
|
|
+ ret = ("<ul>{}</ul>"
|
|
|
+ .format('{}'*len(self.children))
|
|
|
+ .format(*self.children))
|
|
|
+ else:
|
|
|
+ ret = ""
|
|
|
|
|
|
if not self.parent:
|
|
|
- ret = "<div id='toc'><ul>{}</ul></div>".format(ret)
|
|
|
+ ret = "<div id='toc'>{}</div>".format(ret)
|
|
|
+ else:
|
|
|
+ ret = ("<a class='toc-href' href='#{0}' title='{1}'>{1}</a>{2}"
|
|
|
+ .format(self.id, self.header, ret))
|
|
|
+ ret = "<li>{}</li>".format(ret)
|
|
|
|
|
|
return ret
|
|
|
|