[GRASS-SVN] r59825 - grass/trunk/tools/g.html2man

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 19 18:41:09 PDT 2014


Author: glynn
Date: 2014-04-19 18:41:09 -0700 (Sat, 19 Apr 2014)
New Revision: 59825

Modified:
   grass/trunk/tools/g.html2man/g.html2man.py
Log:
Remove ToC (added in r59673)


Modified: grass/trunk/tools/g.html2man/g.html2man.py
===================================================================
--- grass/trunk/tools/g.html2man/g.html2man.py	2014-04-19 21:40:58 UTC (rev 59824)
+++ grass/trunk/tools/g.html2man/g.html2man.py	2014-04-20 01:41:09 UTC (rev 59825)
@@ -10,6 +10,22 @@
     'bull': "*"
     }
 
+# Remove ToC
+def fix(content):
+    if isinstance(content, tuple):
+        tag, attrs, body = content
+        if tag == 'div' and ('class', 'toc') in attrs:
+            return None
+        else:
+            return (tag, attrs, fix(body))
+    elif isinstance(content, list):
+        return [fixed
+                for item in content
+                for fixed in [fix(item)]
+                if fixed is not None]
+    else:
+        return content
+
 def main():
     # parse HTML
     infile = sys.argv[1]
@@ -30,7 +46,7 @@
     # generate groff
     sf = StringIO()
     f = Formatter(infile, sf)
-    f.pp(p.data)
+    f.pp(fix(p.data))
     s = sf.getvalue()
     sf.close()
 



More information about the grass-commit mailing list