Skip to content

Commit

Permalink
wikirend.py: hack around the accidental numbered lists in paragraph trap
Browse files Browse the repository at this point in the history
This trap is that if you write:

	A paragraph with a wrapped line talking about version
	1 of something ...

The '1' is (or was) interpreted as the start of a numbered list, not
just another line of the paragraph. Our workaround is an extreme hack;
when ingesting paragraph lines, if we hit what the initial tokenizer
sees as an 'ol' we check to see if the actual character is a '#'. If it
isn't, we take the 'ol' as a plain line of text instead.

This is a backwards incompatible change that required some content
rewrites in Wandering Thoughts, but I don't care; this case is annoying
enough when I hit it that I want it gone and I'm willing to hack things
up.

(At least this is my current story. I reserve the right to change my
mind later.)
  • Loading branch information
siebenmann committed Sep 14, 2015
1 parent fe0e515 commit f4f1301
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions wikirend.py
Expand Up @@ -1219,11 +1219,21 @@ def cont_list_cond(tok):
def p_handler(self, tok):
ntxt = tok[3].group(1)
tok = self.pull()
if tok and tok[0] == 'p':
txt = [ntxt, tok[3].group(1)]
if tok and (tok[0] == 'p' or \
(tok[0] == 'ol' and tok[1][0] != '#')):
if tok[0] == 'p':
txt = [ntxt, tok[3].group(1)]
else:
txt = [ntxt, tok[1]]
tok = self.pull()
while tok and tok[0] == 'p':
txt.append(tok[3].group(1))
#while tok and tok[0] == 'p':
while tok:
if tok[0] == 'p':
txt.append(tok[3].group(1))
elif tok[0] == 'ol' and tok[1][0] != '#':
txt.append(tok[1])
else:
break
tok = self.pull()
self.pushBack(tok)
ntxt = '\n'.join(txt)
Expand Down

0 comments on commit f4f1301

Please sign in to comment.