From d325f79f5c782edcfa32e87579fb102763d8d29b Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sat, 10 Mar 2018 15:40:51 +0100 Subject: [PATCH] tex2lyx: add support for lstinputlisting --- src/tex2lyx/text.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index e12e4eeb42..2ef3a9f286 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -4632,12 +4632,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } if (t.cs() == "input" || t.cs() == "include" - || t.cs() == "verbatiminput") { + || t.cs() == "verbatiminput" + || t.cs() == "lstinputlisting") { string name = t.cs(); - if (t.cs() == "verbatiminput" + if (name == "verbatiminput" && p.next_token().asInput() == "*") name += p.get_token().asInput(); context.check_layout(os); + string lstparams; + bool literal = false; + if (name == "lstinputlisting" && p.hasOpt()) { + lstparams = p.getArg('[', ']'); + pair oa = convert_latexed_command_inset_arg(lstparams); + literal = !oa.first; + if (literal) + lstparams = subst(lstparams, "\n", " "); + } + string lit = literal ? "\"true\"" : "\"false\""; string filename(normalize_filename(p.getArg('{', '}'))); string const path = getMasterFilePath(true); // We want to preserve relative / absolute filenames, @@ -4745,6 +4756,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, outname = subst(outname, "\"", "\\\""); os << "preview false\n" "filename \"" << outname << "\"\n"; + if (!lstparams.empty()) + os << "lstparams \"" << lstparams << "\"\n"; + os << "literal " << lit << "\n"; if (t.cs() == "verbatiminput") preamble.registerAutomaticallyLoadedPackage("verbatim"); } -- 2.39.5