diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx index 897859e421..70a523cffb 100644 --- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx +++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx @@ -1350,12 +1350,12 @@ status collapsed \begin_layout Plain Layout \backslash -raggedleft +raggedleft \end_layout \end_inset - + \begin_inset Box Frameless position "t" hor_pos "c" @@ -1376,7 +1376,7 @@ status open \begin_layout Plain Layout -www + www \end_layout \end_inset diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index d510c0010e..ffeac41df3 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -4289,7 +4289,6 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, || t.cs() == "shadowsize" || t.cs() == "raggedleft" || t.cs() == "centering" || t.cs() == "raggedright") { - p.skip_spaces(true); if (t.cs() == "fboxrule") fboxrule = ""; if (t.cs() == "fboxsep") @@ -4298,6 +4297,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, shadow_size = ""; if (t.cs() != "raggedleft" && t.cs() != "centering" && t.cs() != "raggedright") { + p.skip_spaces(true); while (p.good() && p.next_token().cat() != catSpace && p.next_token().cat() != catNewline && p.next_token().cat() != catEscape) { @@ -4310,8 +4310,14 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } } else { // we only handle them if they are in a box - if (!wasBoxAlign) - output_ert_inset(os, '\\' + t.cs() + ' ', context); + if (wasBoxAlign) { + // LyX will add a space after outputting the + // alignment command, so eat any space which + // might follow. Otherwise the paragraph + // might start with an unneeded space. + p.skip_spaces(true); + } else + output_ert_inset(os, t.asInput(), context); } wasBoxAlign = false; }