Anonymous committed 62d9a10

Use <ul> for the toc in w3c_compat since csswg's style sheet expects it

Comments (0)

Files changed (1)


     toc = None
     def __init__(self, ElementTree, **kwargs):
-        self.toc = etree.Element("ol", {"class": "toc"})
         self.buildToc(ElementTree, **kwargs)
         self.addToc(ElementTree, **kwargs)
     def buildToc(self, ElementTree, min_depth=2, max_depth=6, w3c_compat=False,
                  w3c_compat_class_toc=False, **kwargs):
+        # Element to use for the toc
+        list_tag = "ol"
+        if w3c_compat or w3c_compat_class_toc:
+            list_tag = "ul"
+        self.toc = etree.Element(list_tag, {"class": "toc"})
         # Build the outline of the document
         outline_creator = outliner.Outliner(ElementTree, **kwargs)
         outline =**kwargs)
                     while i < corrected_depth:
                             # If the final li has no children, or the last
-                            # children isn't an ol element
+                            # children isn't a list_tag element
                             if len(toc_section[-1]) == 0 or \
-                               toc_section[-1][-1].tag != "ol":
-                                toc_section[-1].append(etree.Element("ol"))
+                               toc_section[-1][-1].tag != list_tag:
+                                toc_section[-1].append(etree.Element(list_tag))
                                                  (i + 1) * 2, **kwargs)
                                 if w3c_compat or w3c_compat_class_toc:
                                     toc_section[-1][-1].set("class", "toc")
                         except IndexError:
-                            # If the current ol has no li in it
+                            # If the current list_tag has no li in it
                             utils.indentNode(toc_section[0], (i + 1) * 2 - 1,
-                            toc_section[0].append(etree.Element("ol"))
+                            toc_section[0].append(etree.Element(list_tag))
                             utils.indentNode(toc_section[0][0], (i + 1) * 2,
                             if w3c_compat or w3c_compat_class_toc:
                                 toc_section[0][0].set("class", "toc")
-                        # TOC Section is now the final child (ol) of the final
+                        # TOC Section is now the final child (list_tag) of the final
                         # item (li) in the previous section
                         assert toc_section[-1].tag == "li"
-                        assert toc_section[-1][-1].tag == "ol"
+                        assert toc_section[-1][-1].tag == list_tag
                         toc_section = toc_section[-1][-1]
                         i += 1
                     # Add the current item to the TOC
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.