[voltLib] Unescape new line in lookup comments
This commit is contained in:
parent
18886da333
commit
3c4f5a75bf
@ -242,7 +242,7 @@ class Parser(object):
|
|||||||
comments = None
|
comments = None
|
||||||
if self.next_token_ == "COMMENTS":
|
if self.next_token_ == "COMMENTS":
|
||||||
self.expect_keyword_("COMMENTS")
|
self.expect_keyword_("COMMENTS")
|
||||||
comments = self.expect_string_()
|
comments = self.expect_string_().replace(r'\n', '\n')
|
||||||
context = []
|
context = []
|
||||||
while self.next_token_ in ("EXCEPT_CONTEXT", "IN_CONTEXT"):
|
while self.next_token_ in ("EXCEPT_CONTEXT", "IN_CONTEXT"):
|
||||||
context = self.parse_context_()
|
context = self.parse_context_()
|
||||||
|
@ -473,6 +473,21 @@ class ParserTest(unittest.TestCase):
|
|||||||
'END_SUBSTITUTION\n'
|
'END_SUBSTITUTION\n'
|
||||||
).statements
|
).statements
|
||||||
|
|
||||||
|
def test_lookup_comments(self):
|
||||||
|
[lookup] = self.parse(
|
||||||
|
'DEF_LOOKUP "test" PROCESS_BASE PROCESS_MARKS ALL DIRECTION LTR\n'
|
||||||
|
'COMMENTS "Hello\\nWorld"\n'
|
||||||
|
'IN_CONTEXT\n'
|
||||||
|
'END_CONTEXT\n'
|
||||||
|
'AS_SUBSTITUTION\n'
|
||||||
|
'SUB GLYPH "a"\n'
|
||||||
|
'WITH GLYPH "b"\n'
|
||||||
|
'END_SUB\n'
|
||||||
|
'END_SUBSTITUTION'
|
||||||
|
).statements
|
||||||
|
self.assertEqual(lookup.name, "test")
|
||||||
|
self.assertEqual(lookup.comments, "Hello\nWorld")
|
||||||
|
|
||||||
def test_substitution_empty(self):
|
def test_substitution_empty(self):
|
||||||
with self.assertRaisesRegex(
|
with self.assertRaisesRegex(
|
||||||
VoltLibError,
|
VoltLibError,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user