Beautify documents created by writer2latex (see bug #5187).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40235 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-11-20 20:30:12 +00:00
parent 3f8a615477
commit 76e90badc0

View File

@ -2079,8 +2079,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
os << t.cs();
}
else if (t.cat() == catBegin &&
p.next_token().cat() == catEnd) {
else if (t.cat() == catBegin) {
Token const next = p.next_token();
Token const end = p.next_next_token();
if (next.cat() == catEnd) {
// {}
Token const prev = p.prev_token();
p.get_token();
@ -2090,14 +2092,19 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
; // ignore it in {}`` or -{}-
else
handle_ert(os, "{}", context);
}
else if (t.cat() == catBegin) {
} else if (next.cat() == catEscape &&
is_known(next.cs(), known_quotes) &&
end.cat() == catEnd) {
// Something like {\textquoteright} (e.g.
// from writer2latex). LyX writes
// \textquoteright{}, so we may skip the
// braces here for better readability.
parse_text_snippet(p, os, FLAG_BRACE_LAST,
outer, context);
} else {
context.check_layout(os);
// special handling of font attribute changes
Token const prev = p.prev_token();
Token const next = p.next_token();
TeXFont const oldFont = context.font;
if (next.character() == '[' ||
next.character() == ']' ||
@ -2172,6 +2179,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
handle_ert(os, "}", context);
}
}
}
else if (t.cat() == catEnd) {
if (flags & FLAG_BRACE_LAST) {