[GRASS-SVN] r59826 - grass/branches/releasebranch_7_0/tools/g.html2man
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Apr 20 01:12:20 PDT 2014
Author: neteler
Date: 2014-04-20 01:12:20 -0700 (Sun, 20 Apr 2014)
New Revision: 59826
Modified:
grass/branches/releasebranch_7_0/tools/g.html2man/g.html2man.py
Log:
man: Remove ToC (backport from trunk, r59825)
Modified: grass/branches/releasebranch_7_0/tools/g.html2man/g.html2man.py
===================================================================
--- grass/branches/releasebranch_7_0/tools/g.html2man/g.html2man.py 2014-04-20 01:41:09 UTC (rev 59825)
+++ grass/branches/releasebranch_7_0/tools/g.html2man/g.html2man.py 2014-04-20 08:12:20 UTC (rev 59826)
@@ -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