[GRASS-SVN] r59816 - grass/branches/releasebranch_7_0/tools

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 19 12:20:33 PDT 2014


Author: martinl
Date: 2014-04-19 12:20:32 -0700 (Sat, 19 Apr 2014)
New Revision: 59816

Modified:
   grass/branches/releasebranch_7_0/tools/mkhtml.py
Log:
Fix TOC for pages with no h2 tag
    (merge r59815 from trunk)


Modified: grass/branches/releasebranch_7_0/tools/mkhtml.py
===================================================================
--- grass/branches/releasebranch_7_0/tools/mkhtml.py	2014-04-19 19:10:42 UTC (rev 59815)
+++ grass/branches/releasebranch_7_0/tools/mkhtml.py	2014-04-19 19:20:32 UTC (rev 59816)
@@ -125,20 +125,23 @@
     fd.write('<div class="toc">\n')
     fd.write('<ul class="toc">\n')
     first = True
+    has_h2 = False
     in_h3 = False
     indent = 4
     for tag, href, text in data:
-        if tag == 'h3' and not in_h3:
+        if tag == 'h3' and not in_h3 and has_h2:
             fd.write('\n%s<ul class="toc">\n' % (' ' * indent))
             indent += 4
             in_h3 = True
         elif not first:
             fd.write('</li>\n')
             
-        if tag == 'h2' and in_h3:
-            indent -= 4
-            fd.write('%s</ul></li>\n' % (' ' * indent))
-            in_h3 = False
+        if tag == 'h2':
+            has_h2 = True
+            if in_h3:
+                indent -= 4
+                fd.write('%s</ul></li>\n' % (' ' * indent))
+                in_h3 = False
         
         fd.write('%s<li class="toc"><a href="#%s" class="toc">%s</a>' % \
                      (' ' * indent, href, text))



More information about the grass-commit mailing list