]> git.lyx.org Git - features.git/commitdiff
tex2lyx: add support for lstinputlisting
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 10 Mar 2018 14:40:51 +0000 (15:40 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 17 Mar 2018 16:14:11 +0000 (17:14 +0100)
(cherry picked from commit d325f79f5c782edcfa32e87579fb102763d8d29b)

src/tex2lyx/text.cpp

index ce357ea0315a14e6524077acce7e27e1c55e44cd..1bee520b0ed8c730d8dc717ef43374f749dc15e5 100644 (file)
@@ -4764,12 +4764,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<bool, string> 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,
@@ -4877,6 +4888,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");
                        }