From 3762e3604aac18ec4e794e4e6fa0833bb8fbcefa Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 28 Dec 2015 09:15:21 +0100 Subject: [PATCH] Assure backslash is on its own line in verbatim mode in get_ert Also document the method --- lib/lyx2lyx/lyx2lyx_tools.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/lyx2lyx/lyx2lyx_tools.py b/lib/lyx2lyx/lyx2lyx_tools.py index 3ac8391bb6..14732296cc 100644 --- a/lib/lyx2lyx/lyx2lyx_tools.py +++ b/lib/lyx2lyx/lyx2lyx_tools.py @@ -47,6 +47,13 @@ put_cmd_in_ert(arg): ert = put_cmd_in_ert(content) document.body[i:j+1] = ert +get_ert(lines, i[, verbatim]): + Here, lines is a list of lines of LyX material containing an ERT inset, + whose content we want to convert to LaTeX. The ERT starts at index i. + If the optional (by default: False) bool verbatim is True, the content + of the ERT is returned verbatim, that is in LyX syntax (not LaTeX syntax) + for the use in verbatim insets. + lyx2latex(document, lines): Here, lines is a list of lines of LyX material we want to convert to LaTeX. We do the best we can and return a string containing @@ -161,8 +168,11 @@ def get_ert(lines, i, verbatim = False): elif lines[i] == "\\end_layout": while i + 1 < j and lines[i+1] == "": i = i + 1 - elif lines[i] == "\\backslash" and not verbatim: - ret = ret + "\\" + elif lines[i] == "\\backslash": + if verbatim: + ret = ret + "\n" + lines[i] + "\n" + else: + ret = ret + "\\" else: ret = ret + lines[i] i = i + 1 -- 2.39.2