11#!/usr/bin/python3
22
33## mkqhcp.py
4- ## Version 1.0.3
4+ ## Version 1.0.5
55
66## Copyright 2022-2023 John Donoghue
77##
@@ -51,14 +51,23 @@ def process(name):
5151 title = e .group ("title" )
5252 break
5353
54+ # section
5455 h2_match = re .compile (r'.*<h2 class="chapter"[^>]*>(?P<title>[^<]+)</h2>.*' )
56+ # appendix
57+ h2a_match = re .compile (r'.*<h2 class="appendix"[^>]*>(?P<title>[^<]+)</h2>.*' )
58+ # index
59+ h2i_match = re .compile (r'.*<h2 class="unnumbered"[^>]*>(?P<title>[^<]+)</h2>.*' )
60+
5561 h3_match = re .compile (r'.*<h3 class="section"[^>]*>(?P<title>[^<]+)</h3>.*' )
5662 h4_match = re .compile (r'.*<h4 class="subsection"[^>]*>(?P<title>[^<]+)</h4>.*' )
5763 tag_match1 = re .compile (r'.*<span id="(?P<tag>[^"]+)"[^>]*></span>.*' )
5864 #tag_match2 = re.compile(r'.*<div class="[sub]*section" id="(?P<tag>[^"]+)"[^>]*>.*')
5965 tag_match2 = re .compile (r'.*<div class="[sub]*section[^"]*" id="(?P<tag>[^"]+)"[^>]*>.*' )
6066 tag_match3 = re .compile (r'.*<div class="chapter-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*' )
67+ tag_match4 = re .compile (r'.*<div class="appendix-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*' )
68+ tag_match5 = re .compile (r'.*<div class="unnumbered-level-extent" id="(?P<tag>[^"]+)"[^>]*>.*' )
6169 index_match = re .compile (r'.*<h4 class="subsection"[^>]*>[\d\.\s]*(?P<name>[^<]+)</h4>.*' )
70+ index_match2 = re .compile (r'.*<h4 class="subsection"[^>]*><span>[\d\.\s]*(?P<name>[^<]+)<.*' )
6271
6372 tag = "top"
6473 has_h2 = False
@@ -82,10 +91,18 @@ def process(name):
8291 e = tag_match2 .match (line )
8392 if not e :
8493 e = tag_match3 .match (line )
94+ if not e :
95+ e = tag_match4 .match (line )
96+ if not e :
97+ e = tag_match5 .match (line )
8598 if e :
8699 tag = e .group ("tag" )
87100
88101 e = h2_match .match (line )
102+ if not e :
103+ e = h2a_match .match (line )
104+ if not e :
105+ e = h2i_match .match (line )
89106 if e :
90107 if has_h3 :
91108 f .write (' </section>\n ' )
@@ -120,13 +137,18 @@ def process(name):
120137 fin .seek (0 )
121138 for line in fin :
122139 line = line .strip ()
140+ print ("L" , line )
123141 e = tag_match1 .match (line )
124142 if not e :
125143 e = tag_match2 .match (line )
144+
126145 if e :
127146 tag = e .group ("tag" )
128147
148+
129149 e = index_match .match (line )
150+ if not e :
151+ e = index_match2 .match (line )
130152 if e :
131153 f .write (' <keyword name="{}" ref="{}.html#{}"></keyword>\n ' .format (e .group ("name" ), name , tag ))
132154
0 commit comments