doc: Generate, embed and animate a table of contents in the navbar itself
[charm.git] / doc / markupSanitizer.py
index 9b23ee3e786fdbf63c7ce50c3197b87e92d56de7..1dc34c34b76e8647b01c3c56f9ee06e08c41a7f9 100755 (executable)
@@ -28,6 +28,24 @@ for p in soup('pre'):
     for b in p('br'):
         b.extract()
 
+# Extract the navigation bar
+navmenu = soup.find('div', 'navigation')
+if navmenu:
+    navmenu.extract()
+
+# Wrap the remaining contents with a div
+soup.body['class'] = 'maincontainer'
+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)
+    # Reinsert the navigation bar at the end
+    soup.body.append(navmenu)
+
 # Print cleaned up markup to stdout
 print( soup.prettify(formatter="html") )