X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=doc%2Fmakehelp.py;h=835b8731394524155444e446ef5229ce5b45106c;hp=5ff72f45f6f6ab5d055d5b2e91561247d5d03a6c;hb=11dc64d8fe2c6e39557fbacdd5d9a1ab8d436b05;hpb=fdd2f983f44b38ff8403f32ea0ba15b77d55aaba diff --git a/doc/makehelp.py b/doc/makehelp.py index 5ff72f4..835b873 100755 --- a/doc/makehelp.py +++ b/doc/makehelp.py @@ -15,17 +15,17 @@ beginmarker2 = " ABBREV" endmarker2 = "Game History and Modifications" fp = open("sst-doc.txt", "r") -savetext = "" +savetext = [] state = 0 while True: line = fp.readline() if not line: break if state == 0 and line.startswith(beginmarker1): - line = "%% " + line[12:].lstrip() + line = "% " + line[12:].lstrip() state = 1 if state == 0 and line.startswith(beginmarker2): - savetext += enddelim + "%% ABBREV\n" + savetext.append(enddelim + "%% ABBREV\n") state = 2 if state == 1: if line.find(endmarker1) > -1: @@ -34,12 +34,20 @@ while True: if line.find(endmarker2) > -1: state = 0 if state: - savetext += line.replace("%", "%%") + line = line.replace("%", "%%") + # Hack Unicode non-breaking spaces into ordinary spaces + line = line.replace("\xc2\xa0", " ").replace("\240", "") + # Hack right and left quotes into regular ASCII quotes + line = line.replace("\xe2\x80\x9c", '"').replace("\xe2\x80\x9d", '"') + # Hack dashes and bullets (Hmmm...might want to handle this in curses) + line = line.replace("\xe2\x80\x94", "-").replace("\xe2\x97\x8f", "*"); + if line.startswith("Mnemonic:"): + while not savetext[-1].strip(): + savetext.pop() + savetext.append(line) +savetext = "".join(savetext) # Remove the section titles savetext = re.sub("\n+.*\n*Mnemonic:\\s*", "\n********\n%% ", savetext) -# Hack Unicode non-breaking spaces into ordinary spaces -savetext = savetext.replace("\xc2\xa0", " ").replace("\240", "") - sys.stdout.write(savetext + enddelim)