minor revisions of initialization text
[charm.git] / doc / markupSanitizer.py
index d46e95adb0673aa615896ccb9b35abfef5ee0acb..bc9ed8825a34b1995a32777e69393f653611dbbc 100755 (executable)
@@ -33,10 +33,11 @@ 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') )
+# Wrap the remaining contents within a div
+if not soup.find('div', id='maincontainer'):
+    soup.body['id'] = 'maincontainer'
+    soup.body.name = 'div'
+    soup.find('div', id='maincontainer').wrap( soup.new_tag('body') )
 
 if navmenu:
     # If this navmenu doesn't already have a TOC, insert one
@@ -44,10 +45,40 @@ if navmenu:
         # Add a toc within the navmenu
         navmenuTOC = BeautifulSoup(open("tmp-navmenu.html"), "lxml")
         navmenuTOC = navmenuTOC.find('ul','manual-toc').extract()
+        navmenuTOC.append( BeautifulSoup("".join([
+        '<li><a href="http://charm.cs.illinois.edu">PPL Homepage</a></li>',
+        '<li><a href="http://charm.cs.illinois.edu/help">Other Manuals</a></li>'])
+        ) )
         navmenu.append(navmenuTOC)
+
+    # Insert navigation symbols to prev and next links
+    prevsymbol = soup.new_tag('span')
+    prevsymbol['class'] = 'navsymbol'
+    prevsymbol.string = u'\xab'
+    prv = navmenu.find('li',id='nav-prev')
+    if prv:
+        prv.find('a').insert(0, prevsymbol)
+
+    nextsymbol = soup.new_tag('span')
+    nextsymbol['class'] = 'navsymbol'
+    nextsymbol.string = u'\xbb'
+    nxt = navmenu.find('li',id='nav-next')
+    if nxt:
+        nxt.find('a').append(nextsymbol)
+
     # Reinsert the navigation bar at the end
     soup.body.append(navmenu)
 
+# Extract the title
+titl = soup.find('title')
+
+# Replace the head section with the user-supplied head markup
+soup.find('head').extract()
+newhead = BeautifulSoup(open("../assets/head.html"), "lxml")
+newhead = newhead.find('head').extract()
+newhead.append(titl)
+soup.html.body.insert_before(newhead)
+
 # Print cleaned up markup to stdout
 print( soup.prettify(formatter="html") )