import os import sys if len(sys.argv) < 2: print('Usage: python convert_raw.py [file]', file=sys.stderr) sys.exit(1) if not os.path.exists(sys.argv[1]): print('Please make sure that you have the file.') sys.exit(1) input_filename = sys.argv[1] style = ''' body { font-variant-ligatures: none; } pre { font-family: 'Courier New', Courier, monospace; } a { color: black; } .bottom-nav { position: sticky; bottom: 0px; background-color: white; text-align: right; } h3, h4 { margin: 0; } ''' preamble = f''' {input_filename} ''' postamble = ''' ''' with open(input_filename, 'rb') as f: source = f.read().decode('cp437') with open(f'{input_filename}.HTML', 'w') as f: f.write(preamble) f.write('\n
\n')
    for line in source.split('\r\n'):
        f.write(line.replace('&', '&').replace('<', '<').replace('>', '>'))
        f.write('\n')
    f.write('\n
\n') f.write('\n
Home Top
') f.write(postamble)