Add newlines around \backslash in put_cmd_in_ert.

Fix for 2fce4d49ee.
This commit is contained in:
Günter Milde 2018-02-04 10:16:54 +01:00
parent 8caa9701b9
commit 2b451f01f5
2 changed files with 14 additions and 11 deletions

View File

@ -146,7 +146,7 @@ def put_cmd_in_ert(cmd):
else: else:
cmd = u"%s" % cmd # ensure it is an unicode instance cmd = u"%s" % cmd # ensure it is an unicode instance
cmd = cmd.translate(licr_table) cmd = cmd.translate(licr_table)
cmd = cmd.replace("\\", "\\backslash\n") cmd = cmd.replace("\\", "\n\\backslash\n")
ret += cmd.splitlines() ret += cmd.splitlines()
ret += ["\\end_layout", "", "\\end_inset"] ret += ["\\end_layout", "", "\\end_inset"]
return ret return ret

View File

@ -25,18 +25,21 @@ import unittest
class TestParserTools(unittest.TestCase): class TestParserTools(unittest.TestCase):
def test_put_cmd_in_ert(self): def test_put_cmd_in_ert(self):
ert = ['\\begin_inset ERT', ert = [u'\\begin_inset ERT',
'status collapsed', u'status collapsed',
'', u'',
'\\begin_layout Plain Layout', u'\\begin_layout Plain Layout',
'', u'',
u'',
u'\\backslash',
u'texttt{Gr',
u'\\backslash',
u'"{u}',
u'\\backslash', u'\\backslash',
u'texttt{Gr\\backslash',
u'"{u}\\backslash',
u'ss{}e}', u'ss{}e}',
'\\end_layout', u'\\end_layout',
'', u'',
'\\end_inset'] u'\\end_inset']
self.assertEqual(put_cmd_in_ert(u"\\texttt{Grüße}"), ert) self.assertEqual(put_cmd_in_ert(u"\\texttt{Grüße}"), ert)
self.assertEqual(put_cmd_in_ert([u"\\texttt{Grüße}"]), ert) self.assertEqual(put_cmd_in_ert([u"\\texttt{Grüße}"]), ert)