doc: insert navmenu TOC only if there isnt one already
authorRamprasad Venkataraman <ramv@illinois.edu>
Tue, 7 Aug 2012 05:47:03 +0000 (00:47 -0500)
committerRamprasad Venkataraman <ramv@illinois.edu>
Tue, 7 Aug 2012 05:47:03 +0000 (00:47 -0500)
doc/markupSanitizer.py

index 1dc34c34b76e8647b01c3c56f9ee06e08c41a7f9..d46e95adb0673aa615896ccb9b35abfef5ee0acb 100755 (executable)
@@ -39,10 +39,12 @@ soup.body.name = 'div'
 soup.find('div','maincontainer').wrap( soup.new_tag('body') )
 
 if navmenu:
-    # Add a toc within the navmenu
-    navmenuTOC = BeautifulSoup(open("tmp-navmenu.html"), "lxml")
-    navmenuTOC = navmenuTOC.find('ul','manual-toc').extract()
-    navmenu.append(navmenuTOC)
+    # If this navmenu doesn't already have a TOC, insert one
+    if not navmenu.find('ul','manual-toc'):
+        # Add a toc within the navmenu
+        navmenuTOC = BeautifulSoup(open("tmp-navmenu.html"), "lxml")
+        navmenuTOC = navmenuTOC.find('ul','manual-toc').extract()
+        navmenu.append(navmenuTOC)
     # Reinsert the navigation bar at the end
     soup.body.append(navmenu)