mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Improve roundtrip of Customization.lyx:
The lstlistings environment is no longer be unknown. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37355 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b2e1eb0dda
commit
9b4ee44620
@ -26,7 +26,7 @@ Format LaTeX feature LyX feature
|
||||
266 armenian \language, \lang
|
||||
267 XeTeX utf8 encoding
|
||||
268 CJK.sty CJK encodings, languages
|
||||
269 listings.sty InsetListings
|
||||
269 listings.sty (inline, with args) InsetListings
|
||||
270 \alert, \structure (beamer) layout
|
||||
281 ? modules
|
||||
284 wrapfig.sty InsetWrap
|
||||
|
@ -925,6 +925,33 @@ void parse_outer_box(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
}
|
||||
|
||||
|
||||
void parse_listings(Parser & p, ostream & os, Context & parent_context)
|
||||
{
|
||||
parent_context.check_layout(os);
|
||||
begin_inset(os, "listings\n");
|
||||
os << "inline false\n"
|
||||
<< "status collapsed\n";
|
||||
Context context(true, parent_context.textclass);
|
||||
context.layout = &parent_context.textclass.plainLayout();
|
||||
context.check_layout(os);
|
||||
string const s = p.verbatimEnvironment("lstlisting");
|
||||
for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
|
||||
if (*it == '\\')
|
||||
os << "\n\\backslash\n";
|
||||
else if (*it == '\n') {
|
||||
// avoid adding an empty paragraph at the end
|
||||
if (it + 1 != et) {
|
||||
context.new_paragraph(os);
|
||||
context.check_layout(os);
|
||||
}
|
||||
} else
|
||||
os << *it;
|
||||
}
|
||||
context.check_end_layout(os);
|
||||
end_inset(os);
|
||||
}
|
||||
|
||||
|
||||
/// parse an unknown environment
|
||||
void parse_unknown_environment(Parser & p, string const & name, ostream & os,
|
||||
unsigned flags, bool outer,
|
||||
@ -1030,6 +1057,17 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
||||
p.skip_spaces();
|
||||
}
|
||||
|
||||
else if (name == "lstlisting") {
|
||||
eat_whitespace(p, os, parent_context, false);
|
||||
// FIXME handle listings with parameters
|
||||
if (p.hasOpt())
|
||||
parse_unknown_environment(p, name, os, FLAG_END,
|
||||
outer, parent_context);
|
||||
else
|
||||
parse_listings(p, os, parent_context);
|
||||
p.skip_spaces();
|
||||
}
|
||||
|
||||
else if (!parent_context.new_layout_allowed)
|
||||
parse_unknown_environment(p, name, os, FLAG_END, outer,
|
||||
parent_context);
|
||||
|
Loading…
Reference in New Issue
Block a user