Commit 121b1873 authored by Guido van Rossum's avatar Guido van Rossum

Add a nasty hack that allows me to suck a final newline plus optional

following whitespace back out of the instruction stream.  This can be
used to make the output for loops look nicer.
parent eefc1383
......@@ -213,6 +213,16 @@ class TALGenerator:
self.slots[slotName] = program
self.emit("fillSlot", slotName, program)
def unEmitNewlineWhitespace(self):
if self.program and self.program[-1][0] == "rawtext":
text = self.program[-1][1]
m = re.match(r"(?s)^(.*)(\n[ \t]*)$", text)
if m:
text, rest = m.group(1, 2)
self.program[-1] = ("rawtext", text)
return rest
return None
def test():
t = TALGenerator()
t.pushProgram()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment