From: Eric S. Raymond Date: Fri, 15 Sep 2006 20:12:00 +0000 (+0000) Subject: Fix an extremely obscure bug in the help generation. X-Git-Tag: 2.0~258 X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=commitdiff_plain;h=6230cf44c697419e67ab3b879acd8103a29c7d2d Fix an extremely obscure bug in the help generation. It was triggered by non-breaking space in xmlto output. --- diff --git a/doc/makehelp.py b/doc/makehelp.py index 5ff72f4..460fef1 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,16 @@ 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", "") + 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)