\n')
total_html_lines += 4
else:
current_fh.write("
"+chap_no+"."+str(sect_no)+"."+str(sub_sect_no)+" "+ssect_title+"
\n")
total_html_lines += 1
elif line[:4] == "
":
if line[-6:-1] != "
":
raise ValueError("malformed line with h4 tag: "+line+" on line "+str(line_no))
sub_sub_sect_no += 1
if numbered_sects:
if not h4pat.match(line):
raise ValueError("malformed line with h4 tag: "+line+" on line "+str(line_no))
declared_chap_no = h4pat.sub(r'\1',line)
declared_sect_no = int(h4pat.sub(r'\2',line))
declared_sub_sect_no = int(h4pat.sub(r'\3',line))
declared_sub_sub_sect_no = int(h4pat.sub(r'\4',line))
if (declared_chap_no != chap_no) or (declared_sect_no != sect_no) or (declared_sub_sect_no != sub_sect_no) or (declared_sub_sub_sect_no != sub_sub_sect_no):
log_and_print(f'Level four heading "{line[4:-6]}" should be numbered {chap_no}.{str(sect_no)}.{str(sub_sect_no)}.{str(sub_sub_sect_no)}; correcting!')
sssect_title = h4pat.sub(r'\5',line)
else:
sssect_title = line[4:-6]
sub_sub_sub_sect_no=0
if sssect_title[:12]=="Going Deeper":
s = args.input_file.readline().decode()
line_no += 1
if s != "
\n":
raise ValueError("malformed Going Deeper section (missing starting : "+line+" on line "+str(line_no))
in_GD_ssec = True
current_fh.write('\n')
current_fh.write('
\n')
total_html_lines += 4
else:
current_fh.write("
"+chap_no+"."+str(sect_no)+"."+str(sub_sect_no)+"."+str(sub_sub_sect_no)+" "+sssect_title+"
\n")
total_html_lines += 1
elif line[:4] == "":
if line[-6:-1] != "
":
raise ValueError("malformed line with h5 tag: "+line+" on line "+str(line_no))
sub_sub_sub_sect_no += 1
if numbered_sects:
if not h5pat.match(line):
raise ValueError("malformed line with h5 tag: "+line+" on line "+str(line_no))
declared_chap_no = h5pat.sub(r'\1',line)
declared_sect_no = int(h5pat.sub(r'\2',line))
declared_sub_sect_no = int(h5pat.sub(r'\3',line))
declared_sub_sub_sect_no = int(h5pat.sub(r'\4',line))
declared_sub_sub_sub_sect_no = int(h5pat.sub(r'\5',line))
if (declared_chap_no != chap_no) or (declared_sect_no != sect_no) or (declared_sub_sect_no != sub_sect_no) or (declared_sub_sub_sect_no != sub_sub_sect_no) or (declared_sub_sub_sub_sect_no != sub_sub_sub_sect_no):
log_and_print(f'Level five heading "{line[4:-6]}" should be numbered {chap_no}.{str(sect_no)}.{str(sub_sect_no)}.{str(sub_sub_sect_no)}.{str(sub_sub_sub_sect_no)}; correcting!')
ssssect_title = h5pat.sub(r'\6',line)
else:
sssssect_title = line[4:-6]
current_fh.write(""+chap_no+"."+str(sect_no)+"."+str(sub_sect_no)+"."+str(sub_sub_sect_no)+"."+str(sub_sub_sub_sect_no)+" "+sssssect_title+"
\n")
total_html_lines += 1
else:
# the stuff below doesn't handle nested tables very well...
if in_LandA_ssec and LandA_w_tables:
if line=="\n" or line=="
\n" or line=="\n" or line==" | \n":
continue
if line=="
\n":
current_fh.write('\n')
total_html_lines += 1
in_LandA_ssec = False
continue
if in_SL_ssec:
if line=="\n" or line=="
\n" or line=="\n" or line==" | \n":
continue
if line=="
\n":
current_fh.write("