doc: Simply use dom parser to insert head section
authorRamprasad Venkataraman <ramv@illinois.edu>
Tue, 7 Aug 2012 15:53:38 +0000 (10:53 -0500)
committerRamprasad Venkataraman <ramv@illinois.edu>
Tue, 7 Aug 2012 15:53:38 +0000 (10:53 -0500)
doc/assets/head.html [new file with mode: 0644]
doc/dot.latex2html-init
doc/l2h_sanitize_markup.sh
doc/markupSanitizer.py

diff --git a/doc/assets/head.html b/doc/assets/head.html
new file mode 100644 (file)
index 0000000..7c88992
--- /dev/null
@@ -0,0 +1,16 @@
+<head>
+    <meta content='Charm++ Manual' name='content' />
+               <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+
+               <link rel="stylesheet" type="text/css" href="assets/manual.css" />
+    <link href='http://fonts.googleapis.com/css?family=Puritan' rel='stylesheet' type='text/css'>
+    <link href='http://fonts.googleapis.com/css?family=Droid Sans' rel='stylesheet' type='text/css'>
+    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'></script>
+    <script src='http://charm.cs.illinois.edu/codemirror/lib/codemirror.js' type='text/javascript'></script>
+    <script src='http://charm.cs.illinois.edu/codemirror/mode/clike/clike.js' type='text/javascript'></script>
+    <script src='http://charm.cs.illinois.edu/codemirror/lib/util/runmode.js' type='text/javascript'></script>
+    <link href='http://charm.cs.illinois.edu/codemirror/lib/codemirror.css' rel='stylesheet' type='text/css'>
+    <link href='http://charm.cs.illinois.edu/codemirror/theme/lesser-dark.css' rel='stylesheet' type='text/css'>
+    <script src='assets/hilitesyntax.js' type='text/javascript'></script>
+</head>
+
index eb8758a77a278a59b3cd84d84ec4331ed7c2fd36..5c3183b2ae16608b1f2693b823afefb9b20165a0 100644 (file)
@@ -175,17 +175,6 @@ sub replace_morelinks {
 }
 
 sub head_tags {
-    "<link href='http://fonts.googleapis.com/css?family=Puritan' rel='stylesheet' type='text/css'>\n" .
-    "<link href='http://fonts.googleapis.com/css?family=Droid Sans' rel='stylesheet' type='text/css'>\n" .
-    "\n" .
-    "<replace_with_script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'></script>\n" .
-    "\n" .
-    "<replace_with_script src='http://charm.cs.illinois.edu/codemirror/lib/codemirror.js' type='text/javascript'></script>\n" .
-    "<replace_with_script src='http://charm.cs.illinois.edu/codemirror/mode/clike/clike.js' type='text/javascript'></script>\n" .
-    "<replace_with_script src='http://charm.cs.illinois.edu/codemirror/lib/util/runmode.js' type='text/javascript'></script>\n" .
-    "<link href='http://charm.cs.illinois.edu/codemirror/lib/codemirror.css' rel='stylesheet' type='text/css'>\n" .
-    "<link href='http://charm.cs.illinois.edu/codemirror/theme/lesser-dark.css' rel='stylesheet' type='text/css'>\n" .
-    "<replace_with_script src='assets/hilitesyntax.js' type='text/javascript'></script>\n"
 }
 
 1;     # This must be the last line
index 023c0bc022e85cdc0a29f3a3c208c9425d6e4a3d..7f296c0a73b946f67f226013415a27eb90d1923e 100755 (executable)
@@ -23,10 +23,6 @@ do
     # Uncomment to produce backup files for identifying the results of regex
        #mv $f $f.bak || die "error backing up $f"
 
-    # Munge through the markup and... 
        # Relativize all paths
-       # Replace placeholder with script tag
-       sed -e 's!'$cwd'/!!g' \
-           -e 's|replace_with_script|script|g' \
-       tmp > $f || die "error running sed on $f"
+       sed -e 's!'$cwd'/!!g' tmp > $f || die "error running sed on $f"
 done
index d46e95adb0673aa615896ccb9b35abfef5ee0acb..247f81c1dfee7f387d81f36b561069c5d6bb645b 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
@@ -48,6 +49,15 @@ if navmenu:
     # 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()
+soup.html.body.insert_before(newhead)
+
 # Print cleaned up markup to stdout
 print( soup.prettify(formatter="html") )