Geoffrey Sneddon  committed 3116e68

Add --w3c-compat-class-toc (adds @class='toc' on every ol in the TOC).

  • Participants
  • Parent commits be56a86

Comments (0)

Files changed (2)

 	parser.add_option("", "--w3c-compat-xref-normalization", action="store_true",
 		default=False, dest="w3c_compat_xref_normalization", help="Only use ASCII letters, numbers, and spaces in comparison of cross-reference terms.")
+	parser.add_option("", "--w3c-compat-class-toc", action="store_true",
+		default=False, dest="w3c_compat_class_toc", help="Add @class='toc' on every ol element in the table of contents (instead of only the root ol element).")
 	parser.add_option("", "--profile", action="store_true",
 		default=False, dest="profile", help="Profile the execution of %prog.")

File specGen/processes/

 		self.buildToc(ElementTree, **kwargs)
 		self.addToc(ElementTree, **kwargs)
-	def buildToc(self, ElementTree, min_depth = 2, max_depth = 6, **kwargs):
+	def buildToc(self, ElementTree, min_depth = 2, max_depth = 6, w3c_compat = False, w3c_compat_class_toc = False, **kwargs):
 		# Build the outline of the document
 		outline_creator = outliner.Outliner()
 		outline =
 								# If the final li has no children, or the last children isn't an ol element
 								if len(toc_section[-1]) == 0 or toc_section[-1][-1].tag != "ol":
+									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 w3c_compat or w3c_compat_class_toc:
+									toc_section[0][-1].set("class", "toc")
 							# TOC Section is now the final child (ol) of the final item (li) in the previous section
 							assert toc_section[-1].tag == "li"
 							assert toc_section[-1][-1].tag == "ol"