mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
tex2lyx: Add a newline at the end of comment if not at the end of a paragraph.
When importing TeX code like %comment TEXT the LyX document currently becomes [ERT %comment] TEXT so that TEXT is now part of the comment. Now output_comment adds a trailing newline if the token after the comment is not a newline. Note that the newline that marks the end of the comment has already been parsed at this point. tex2lyx tests have been checked manually and updated. Fixes ticket #9551.
This commit is contained in:
parent
154e76d4d3
commit
2811f76039
@ -167,6 +167,10 @@ status collapsed
|
|||||||
% The following Bg5 encoded text cannot be processed as is by latex.
|
% The following Bg5 encoded text cannot be processed as is by latex.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -177,6 +181,10 @@ status collapsed
|
|||||||
% It needs to be preprocessed by bg5conv or bg5latex needs to be used.
|
% It needs to be preprocessed by bg5conv or bg5latex needs to be used.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -213,6 +221,10 @@ status collapsed
|
|||||||
% The following SJIS encoded text cannot be processed as is by latex.
|
% The following SJIS encoded text cannot be processed as is by latex.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +235,10 @@ status collapsed
|
|||||||
% It needs to be preprocessed by sjisconv or sjislatex needs to be used.
|
% It needs to be preprocessed by sjisconv or sjislatex needs to be used.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -175,6 +175,10 @@ status collapsed
|
|||||||
%empty language paragraph
|
%empty language paragraph
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -2400,6 +2400,10 @@ status collapsed
|
|||||||
%set back to justified
|
%set back to justified
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -663,6 +663,10 @@ status collapsed
|
|||||||
bibliography since LaTeX throws an error.
|
bibliography since LaTeX throws an error.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -675,6 +679,10 @@ status collapsed
|
|||||||
bibliographystyle{unsrt}
|
bibliographystyle{unsrt}
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -4348,6 +4356,10 @@ status collapsed
|
|||||||
% some comment
|
% some comment
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -6753,6 +6765,10 @@ status collapsed
|
|||||||
% and another
|
% and another
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,6 +112,10 @@ status collapsed
|
|||||||
%stupid stuff
|
%stupid stuff
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -639,6 +643,10 @@ status collapsed
|
|||||||
bibliography since LaTeX throws an error.
|
bibliography since LaTeX throws an error.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -651,6 +659,10 @@ status collapsed
|
|||||||
bibliographystyle{unsrt}
|
bibliographystyle{unsrt}
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -4401,6 +4413,10 @@ status collapsed
|
|||||||
% some comment
|
% some comment
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
@ -7192,6 +7208,10 @@ status collapsed
|
|||||||
% and another
|
% and another
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,6 +124,10 @@ status collapsed
|
|||||||
% this should be recognized as empty date:
|
% this should be recognized as empty date:
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +120,10 @@ status collapsed
|
|||||||
%Midline comment
|
%Midline comment
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
@ -580,6 +580,16 @@ void output_ert_inset(ostream & os, string const & s, Context & context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void output_comment(Parser & p, ostream & os, string const & s,
|
||||||
|
Context & context)
|
||||||
|
{
|
||||||
|
if (p.next_token().cat() == catNewline)
|
||||||
|
output_ert_inset(os, '%' + s, context);
|
||||||
|
else
|
||||||
|
output_ert_inset(os, '%' + s + '\n', context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Layout const * findLayout(TextClass const & textclass, string const & name, bool command)
|
Layout const * findLayout(TextClass const & textclass, string const & name, bool command)
|
||||||
{
|
{
|
||||||
Layout const * layout = findLayoutWithoutModule(textclass, name, command);
|
Layout const * layout = findLayoutWithoutModule(textclass, name, command);
|
||||||
@ -1189,13 +1199,13 @@ void parse_box(Parser & p, ostream & os, unsigned outer_flags,
|
|||||||
// LyX puts a % after the end of the minipage
|
// LyX puts a % after the end of the minipage
|
||||||
if (p.next_token().cat() == catNewline && p.next_token().cs().size() > 1) {
|
if (p.next_token().cat() == catNewline && p.next_token().cs().size() > 1) {
|
||||||
// new paragraph
|
// new paragraph
|
||||||
//output_ert_inset(os, "%dummy", parent_context);
|
//output_comment(p, os, "dummy", parent_context);
|
||||||
p.get_token();
|
p.get_token();
|
||||||
p.skip_spaces();
|
p.skip_spaces();
|
||||||
parent_context.new_paragraph(os);
|
parent_context.new_paragraph(os);
|
||||||
}
|
}
|
||||||
else if (p.next_token().cat() == catSpace || p.next_token().cat() == catNewline) {
|
else if (p.next_token().cat() == catSpace || p.next_token().cat() == catNewline) {
|
||||||
//output_ert_inset(os, "%dummy", parent_context);
|
//output_comment(p, os, "dummy", parent_context);
|
||||||
p.get_token();
|
p.get_token();
|
||||||
p.skip_spaces();
|
p.skip_spaces();
|
||||||
// We add a protected space if something real follows
|
// We add a protected space if something real follows
|
||||||
@ -1880,7 +1890,7 @@ void parse_comment(Parser & p, ostream & os, Token const & t, Context & context)
|
|||||||
LASSERT(t.cat() == catComment, return);
|
LASSERT(t.cat() == catComment, return);
|
||||||
if (!t.cs().empty()) {
|
if (!t.cs().empty()) {
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
output_ert_inset(os, '%' + t.cs(), context);
|
output_comment(p, os, t.cs(), context);
|
||||||
if (p.next_token().cat() == catNewline) {
|
if (p.next_token().cat() == catNewline) {
|
||||||
// A newline after a comment line starts a new
|
// A newline after a comment line starts a new
|
||||||
// paragraph
|
// paragraph
|
||||||
@ -2826,8 +2836,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
// FIXME: This is a hack to prevent paragraph
|
// FIXME: This is a hack to prevent paragraph
|
||||||
// deletion if it is empty. Handle this better!
|
// deletion if it is empty. Handle this better!
|
||||||
output_ert_inset(os,
|
output_comment(p, os,
|
||||||
"%dummy comment inserted by tex2lyx to "
|
"dummy comment inserted by tex2lyx to "
|
||||||
"ensure that this paragraph is not empty",
|
"ensure that this paragraph is not empty",
|
||||||
context);
|
context);
|
||||||
// Both measures above may generate an additional
|
// Both measures above may generate an additional
|
||||||
|
Loading…
Reference in New Issue
Block a user