mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
tex2lyx: add support for lstinputlisting
This commit is contained in:
parent
11e4a24e6e
commit
d325f79f5c
@ -4632,12 +4632,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (t.cs() == "input" || t.cs() == "include"
|
if (t.cs() == "input" || t.cs() == "include"
|
||||||
|| t.cs() == "verbatiminput") {
|
|| t.cs() == "verbatiminput"
|
||||||
|
|| t.cs() == "lstinputlisting") {
|
||||||
string name = t.cs();
|
string name = t.cs();
|
||||||
if (t.cs() == "verbatiminput"
|
if (name == "verbatiminput"
|
||||||
&& p.next_token().asInput() == "*")
|
&& p.next_token().asInput() == "*")
|
||||||
name += p.get_token().asInput();
|
name += p.get_token().asInput();
|
||||||
context.check_layout(os);
|
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 filename(normalize_filename(p.getArg('{', '}')));
|
||||||
string const path = getMasterFilePath(true);
|
string const path = getMasterFilePath(true);
|
||||||
// We want to preserve relative / absolute filenames,
|
// 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, "\"", "\\\"");
|
outname = subst(outname, "\"", "\\\"");
|
||||||
os << "preview false\n"
|
os << "preview false\n"
|
||||||
"filename \"" << outname << "\"\n";
|
"filename \"" << outname << "\"\n";
|
||||||
|
if (!lstparams.empty())
|
||||||
|
os << "lstparams \"" << lstparams << "\"\n";
|
||||||
|
os << "literal " << lit << "\n";
|
||||||
if (t.cs() == "verbatiminput")
|
if (t.cs() == "verbatiminput")
|
||||||
preamble.registerAutomaticallyLoadedPackage("verbatim");
|
preamble.registerAutomaticallyLoadedPackage("verbatim");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user