From 5bfba3e564f7aa60bbc8ebdef31bfc63dc46123a Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 22 Oct 2011 16:58:32 +0000 Subject: [PATCH] Increase tex2lyx output format to 401. 400: Convert \lyxline to new InsetLine syntax 401: Nothing to do (empty lyx2lyx conversion) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39919 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/TODO.txt | 2 ++ src/tex2lyx/preamble.cpp | 2 +- src/tex2lyx/tex2lyx.h | 3 ++- src/tex2lyx/text.cpp | 24 +++++++++++++++++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index eac7c41b59..8cb0e6929b 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -93,4 +93,6 @@ Format LaTeX feature LyX feature 395 page sizes C0-6 \papersize 396 nameref.sty InsetRef 399 automatic mathdots loading \use_mathdots +400 other rules than \lyxline InsetLine +401 feyn.sty InsetMathDiagram diff --git a/src/tex2lyx/preamble.cpp b/src/tex2lyx/preamble.cpp index 6af9b64c9e..cbdbb5de6e 100644 --- a/src/tex2lyx/preamble.cpp +++ b/src/tex2lyx/preamble.cpp @@ -49,6 +49,7 @@ const char * const modules_placeholder = "\001modules\001"; // needed to handle encodings with babel bool one_language = true; string h_inputencoding = "auto"; +string h_paragraph_separation = "indent"; namespace { @@ -207,7 +208,6 @@ string h_paperorientation = "portrait"; string h_notefontcolor; string h_secnumdepth = "3"; string h_tocdepth = "3"; -string h_paragraph_separation = "indent"; string h_defskip = "medskip"; string h_paragraph_indentation = "default"; string h_quotes_language = "english"; diff --git a/src/tex2lyx/tex2lyx.h b/src/tex2lyx/tex2lyx.h index d2b84cb14b..546c9211a8 100644 --- a/src/tex2lyx/tex2lyx.h +++ b/src/tex2lyx/tex2lyx.h @@ -53,6 +53,7 @@ extern std::string babel2lyx(std::string const & language); extern std::map > used_packages; extern const char * const modules_placeholder; extern std::string h_inputencoding; +extern std::string h_paragraph_separation; /// in text.cpp std::string translate_len(std::string const &); @@ -165,7 +166,7 @@ extern bool noweb_mode; /// Did we recognize any pdflatex-only construct? extern bool pdflatex; /// LyX format that is created by tex2lyx -int const LYX_FORMAT = 399; +int const LYX_FORMAT = 401; /// path of the master .tex file extern std::string getMasterFilePath(); diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 85df00324a..930b318c53 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -2427,8 +2427,30 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } else if (t.cs() == "lyxline") { + // swallow size argument (it is not used anyway) + p.getArg('{', '}'); + if (!context.atParagraphStart()) { + // so our line is in the middle of a paragraph + // we need to add a new line, lest this line + // follow the other content on that line and + // run off the side of the page + // FIXME: This may create an empty paragraph, + // but without that it would not be + // possible to set noindent below. + // Fortunately LaTeX does not care + // about the empty paragraph. + context.new_paragraph(os); + } + if (h_paragraph_separation == "indent") { + // we need to unindent, lest the line be too long + context.add_par_extra_stuff("\\noindent\n"); + } context.check_layout(os); - os << "\\lyxline"; + begin_command_inset(os, "line", "rule"); + os << "offset \"0.5ex\"\n" + "width \"100line%\"\n" + "height \"1pt\"\n"; + end_inset(os); } else if (is_known(t.cs(), known_phrases) || -- 2.39.2