#!/usr/bin/env python3 """ Rebuild ___left.htm from the .hhc table of contents file """ import re import sys def parse_hhc(hhc_file): """Parse the HHC file and extract navigation structure""" with open(hhc_file, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Extract all blocks items = [] level = 0 in_ul = False lines = content.split('\n') for i, line in enumerate(lines): if '' in line.lower(): level -= 1 elif '' in line.lower(): # Get the next few lines to extract params obj_lines = [] for j in range(i, min(i+10, len(lines))): obj_lines.append(lines[j]) if '' in lines[j].lower(): break # Parse params name = '' local = '' for ol in obj_lines: name_match = re.search(r' Contents
""" return html def main(): hhc_file = '/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help/POS_Help_v19R1_Feb_2020.hhc' output_file = '/home/pts/Documents/QBPOS_Help_Web/QB_Help_Web/POS_Help/___left.htm' print(f"Parsing {hhc_file}...") items = parse_hhc(hhc_file) print(f"Found {len(items)} navigation items") print(f"Generating {output_file}...") html = generate_left_htm(items) with open(output_file, 'w', encoding='utf-8') as f: f.write(html) print(f"Successfully rebuilt ___left.htm with {len(items)} items") if __name__ == '__main__': main()