[wmlparser2] Fixed issue with .plain file parsing
For example defined strings with empty lines would not work. The problem was a direct check for newlines which failed if there were chr(254) commands on the same line.
This commit is contained in:
parent
855ffbe358
commit
5ad589066c
1 changed files with 23 additions and 4 deletions
|
@ -351,6 +351,17 @@ class Parser:
|
|||
else:
|
||||
for i, segment in enumerate(line.split("+")):
|
||||
segment = segment.lstrip(" ")
|
||||
empty = not segment.strip()
|
||||
|
||||
# if a plus sign is followed by only whitespace on that line,
|
||||
# we need to ignore the following empty lines to find the
|
||||
# continuation
|
||||
|
||||
if i > 0 and empty:
|
||||
self.skip_newlines = True
|
||||
elif not empty:
|
||||
self.skip_newlines = False
|
||||
|
||||
if not segment: continue
|
||||
|
||||
if segment[0] == "_":
|
||||
|
@ -358,10 +369,6 @@ class Parser:
|
|||
segment = segment[1:].lstrip(" ")
|
||||
if not segment: continue
|
||||
|
||||
if i > 0 and segment == "\n":
|
||||
self.skip_newlines = True
|
||||
elif segment != "\n":
|
||||
self.skip_newlines = False
|
||||
self.handle_value(segment)
|
||||
|
||||
def handle_tag(self, line):
|
||||
|
@ -702,6 +709,18 @@ foo="bar"+
|
|||
foo='bar' .. 'baz'
|
||||
""", "multi line string")
|
||||
|
||||
test(
|
||||
"""
|
||||
#define baz
|
||||
|
||||
"baz"
|
||||
#enddef
|
||||
foo="bar"+{baz}
|
||||
""",
|
||||
"""
|
||||
foo='bar' .. 'baz'
|
||||
""", "defined multi line string")
|
||||
|
||||
test2(
|
||||
"""
|
||||
[test]
|
||||
|
|
Loading…
Add table
Reference in a new issue