[GRASS-SVN] r59815 - grass/trunk/tools

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 19 12:10:42 PDT 2014


Author: martinl
Date: 2014-04-19 12:10:42 -0700 (Sat, 19 Apr 2014)
New Revision: 59815

Modified:
   grass/trunk/tools/mkhtml.py
Log:
Fix TOC for pages with no h2 tag

Modified: grass/trunk/tools/mkhtml.py
===================================================================
--- grass/trunk/tools/mkhtml.py	2014-04-19 18:49:51 UTC (rev 59814)
+++ grass/trunk/tools/mkhtml.py	2014-04-19 19:10:42 UTC (rev 59815)
@@ -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