[GRASS-SVN] r43667 - grass/trunk/tools
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Sep 24 08:32:11 EDT 2010
Author: glynn
Date: 2010-09-24 12:32:11 +0000 (Fri, 24 Sep 2010)
New Revision: 43667
Modified:
grass/trunk/tools/mkhtml.py
Log:
Revert attempts to parse HTML using regexps
Modified: grass/trunk/tools/mkhtml.py
===================================================================
--- grass/trunk/tools/mkhtml.py 2010-09-24 12:14:07 UTC (rev 43666)
+++ grass/trunk/tools/mkhtml.py 2010-09-24 12:32:11 UTC (rev 43667)
@@ -4,9 +4,8 @@
#
# MODULE: mkhtml.py
# AUTHOR(S): Markus Neteler, Glynn Clements
-# TOC by Martin Landa <landa.martin gmail.com>
# PURPOSE: create HTML manual page snippets
-# COPYRIGHT: (C) 2007,2009-2010 Glynn Clements and the GRASS Development Team
+# COPYRIGHT: (C) 2007,2009 Glynn Clements and the GRASS Development Team
#
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
@@ -57,64 +56,6 @@
src_data = read_file(src_file)
-def get_toc_item(line, pattern):
- found = pattern.search(line)
- if found:
- return found.group(2).strip()
-
- return None
-
-def filter_toc_item(label):
- return label.replace('"', '"')
-
-def write_toc_level(line, src_list, pattern, pattern_level, level, idx):
- indent = 4
-
- text = get_toc_item(line, pattern)
- if not text:
- return False, level
-
- if pattern_level > level:
- for l in range(level, pattern_level):
- sys.stdout.write('%s<li><ul>\n' % (' ' * l * indent))
- elif level > pattern_level:
- for l in range(level, pattern_level, -1):
- sys.stdout.write('%s</ul></li>\n' % (' ' * (l - 1) * indent))
- level = pattern_level
-
- sys.stdout.write('%s<li><a href="#%s">%s</a></li>\n' % (' ' * level * indent,
- filter_toc_item(text), filter_toc_item(text)))
- src_list[idx] = '<a name="%s"></a>' % filter_toc_item(text) + line
-
- return True, level
-
-def write_toc():
- global src_data
- level = 1
- idx = 0
- indent = 4
-
- sys.stdout.write('<a name="TOC"></a><h2>TABLE OF CONTENT</h2>\n\n<ul>\n')
- src_list = src_data.splitlines()
- for line in src_list:
- found, level = write_toc_level(line, src_list,
- re.compile(r"(<h2>)(.*)(</h2>)", re.IGNORECASE), 1,
- level, idx)
- if not found:
- found, level = write_toc_level(line, src_list,
- re.compile(r"(<h3>)(.*)(</h3>)", re.IGNORECASE), 2,
- level, idx)
- if not found:
- found, level = write_toc_level(line, src_list,
- re.compile(r"(<h4>)(.*)(</h4>)", re.IGNORECASE), 3,
- level, idx)
-
- idx += 1
-
- for l in range(level, 0, -1):
- sys.stdout.write('%s</ul>\n' % (' ' * (l - 1) * indent))
- src_data = '\n'.join(src_list)
-
if not re.search('<html>', src_data, re.IGNORECASE):
tmp_data = read_file(tmp_file)
if not re.search('<html>', tmp_data, re.IGNORECASE):
@@ -123,7 +64,6 @@
for line in tmp_data.splitlines(True):
if not re.search('</body>|</html>', line, re.IGNORECASE):
sys.stdout.write(line)
- write_toc()
sys.stdout.write(src_data)
@@ -133,20 +73,22 @@
sys.exit()
index_names = {
- 'd' : 'display',
+ 'd': 'display',
'db': 'database',
- 'g' : 'general',
- 'i' : 'imagery',
- 'm' : 'misc',
+ 'g': 'general',
+ 'i': 'imagery',
+ 'm': 'misc',
+ 'pg': 'postGRASS',
'ps': 'postscript',
- 'p' : 'paint',
- 'r' : 'raster',
+ 'p': 'paint',
+ 'r': 'raster',
'r3': 'raster3D',
- 's' : 'sites',
- 'v' : 'vector'
+ 's': 'sites',
+ 'v': 'vector'
}
mod_class = pgm.split('.', 1)[0]
index_name = index_names.get(mod_class, mod_class)
sys.stdout.write(footer_tmpl.substitute(INDEXNAME = index_name))
+
More information about the grass-commit
mailing list