commit 2b451f01f50cf4f69200f2cd5ec646b1917156c1
Author: Günter Milde <mi...@lyx.org>
Date:   Sun Feb 4 10:16:54 2018 +0100

    Add newlines around \backslash in put_cmd_in_ert.
    
    Fix for 2fce4d49ee.
---
 lib/lyx2lyx/lyx2lyx_tools.py      |    2 +-
 lib/lyx2lyx/test_lyx2lyx_tools.py |   23 +++++++++++++----------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/lib/lyx2lyx/lyx2lyx_tools.py b/lib/lyx2lyx/lyx2lyx_tools.py
index 2f75cdc..7aac890 100644
--- a/lib/lyx2lyx/lyx2lyx_tools.py
+++ b/lib/lyx2lyx/lyx2lyx_tools.py
@@ -146,7 +146,7 @@ def put_cmd_in_ert(cmd):
     else:
         cmd = u"%s" % cmd # ensure it is an unicode instance
     cmd = cmd.translate(licr_table)
-    cmd = cmd.replace("\\", "\\backslash\n")
+    cmd = cmd.replace("\\", "\n\\backslash\n")
     ret += cmd.splitlines()
     ret += ["\\end_layout", "", "\\end_inset"]
     return ret
diff --git a/lib/lyx2lyx/test_lyx2lyx_tools.py 
b/lib/lyx2lyx/test_lyx2lyx_tools.py
index 9988d8d..186c0ba 100644
--- a/lib/lyx2lyx/test_lyx2lyx_tools.py
+++ b/lib/lyx2lyx/test_lyx2lyx_tools.py
@@ -25,18 +25,21 @@ import unittest
 class TestParserTools(unittest.TestCase):
 
     def test_put_cmd_in_ert(self):
-        ert =  ['\\begin_inset ERT',
-                'status collapsed',
-                '',
-                '\\begin_layout Plain Layout',
-                '',
+        ert =  [u'\\begin_inset ERT',
+                u'status collapsed',
+                u'',
+                u'\\begin_layout Plain Layout',
+                u'',
+                u'',
+                u'\\backslash',
+                u'texttt{Gr',
+                u'\\backslash',
+                u'"{u}',
                 u'\\backslash',
-                u'texttt{Gr\\backslash',
-                u'"{u}\\backslash',
                 u'ss{}e}',
-                '\\end_layout',
-                '',
-                '\\end_inset']
+                u'\\end_layout',
+                u'',
+                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)
 

Reply via email to