From a25569ebb3e739779ff458b287e403c3bf79777a Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 1 Dec 2014 14:56:47 +0100 Subject: [PATCH] Add a layout tag ForceOwnlines that assures an inset is started and terminated by a line break in the LaTeX output. Fixes: #8875. --- lib/doc/Customization.lyx | 59 ++++++++++++++++++++++++++++++++++-- lib/layouts/litinsets.inc | 19 ++++++------ lib/scripts/layout2layout.py | 7 +++-- src/TextClass.cpp | 2 +- src/insets/InsetLayout.cpp | 5 +++ src/insets/InsetLayout.h | 4 +++ src/insets/InsetText.cpp | 6 +++- 7 files changed, 86 insertions(+), 16 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 14199577f8..96f47300de 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -1,5 +1,5 @@ -#LyX 2.1 created this file. For more info see http://www.lyx.org/ -\lyxformat 476 +#LyX 2.2 created this file. For more info see http://www.lyx.org/ +\lyxformat 479 \begin_document \begin_header \textclass scrbook @@ -17019,6 +17019,59 @@ g. in TeX code or URL. A kludge. +\change_inserted -712698321 1417441977 + +\end_layout + +\begin_layout Description + +\change_inserted -712698321 1417442090 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1417441983 +ForceOwnlines +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1417441978 + +\emph on +0 +\end_layout + +\end_inset + +, +\begin_inset space \thinspace{} +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted -712698321 1417441978 +1 +\end_layout + +\end_inset + +] Force a a line break in the LaTeX output before the inset starts and after + the inset ends. + This assures the inset itself is output on its own lines, for parsing purposes. +\change_unchanged + \end_layout \begin_layout Description @@ -23533,7 +23586,7 @@ name "chap:List-of-functions" \align center \begin_inset Tabular - + diff --git a/lib/layouts/litinsets.inc b/lib/layouts/litinsets.inc index 05440cbfe2..c83b6a3085 100644 --- a/lib/layouts/litinsets.inc +++ b/lib/layouts/litinsets.inc @@ -6,7 +6,7 @@ # Note that this file is included in sweave.module, # knitr.module and noweb.module. -Format 49 +Format 52 Counter chunk PrettyFormat "Chunk ##" @@ -23,15 +23,15 @@ InsetLayout "Flex:Chunk" Color latex Family typewriter EndFont - #LabelFont - #Color latex - #Size Small - #EndFont - MultiPar true +# LabelFont +# Color latex +# Size Small +# EndFont + MultiPar true CustomPars false ForcePlain true - PassThru 1 - ParbreakIsNewline 1 + PassThru 1 + ParbreakIsNewline 1 KeepEmpty true Spellcheck 0 FreeSpacing true @@ -43,5 +43,6 @@ InsetLayout "Flex:Chunk" LeftDelim << RightDelim >>=
EndArgument - ResetsFont false + ResetsFont false + ForceOwnlines true End diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index d269d585d7..10811e73b4 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -171,6 +171,9 @@ import os, re, string, sys # Incremented to format 51, 29 May 2014 by spitz # New Style tag "ToggleIndent" +# Incremented to format 52, 1 December 2014 by spitz +# New InsetLayout tag "ForceOwnlines" + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). @@ -178,7 +181,7 @@ import os, re, string, sys # development/tools/updatelayouts.py script to update all # layout files to the new format. -currentFormat = 51 +currentFormat = 52 def usage(prog_name): @@ -402,7 +405,7 @@ def convert(lines): i += 1 continue - if format == 50: + if format == 50 or format == 51: # nothing to do. i += 1 continue diff --git a/src/TextClass.cpp b/src/TextClass.cpp index e0e302a9ac..113cddb7fd 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -61,7 +61,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // to update the format of all of our layout files. // -int const LAYOUT_FORMAT = 51; //spitz: add ToggleIndent tag +int const LAYOUT_FORMAT = 52; //spitz: add ForceOwnlines tag namespace { diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index d579132a21..4a6d0a8225 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -89,6 +89,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) IL_FONT, IL_FORCE_LOCAL_FONT_SWITCH, IL_FORCELTR, + IL_FORCEOWNLINES, IL_FORCEPLAIN, IL_FREESPACING, IL_HTMLTAG, @@ -139,6 +140,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) { "font", IL_FONT }, { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH }, { "forceltr", IL_FORCELTR }, + { "forceownlines", IL_FORCEOWNLINES }, { "forceplain", IL_FORCEPLAIN }, { "freespacing", IL_FREESPACING }, { "htmlattr", IL_HTMLATTR }, @@ -256,6 +258,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass) case IL_FORCELTR: lex >> forceltr_; break; + case IL_FORCEOWNLINES: + lex >> forceownlines_; + break; case IL_INTOC: lex >> intoc_; break; diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 9398e91582..2ef6be4fdf 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -164,6 +164,8 @@ public: /// bool forceLTR() const { return forceltr_; } /// + bool forceOwnlines() const { return forceownlines_; } + /// bool isInToc() const { return intoc_; } /// bool spellcheck() const { return spellcheck_; } @@ -262,6 +264,8 @@ private: /// bool forceltr_; /// + bool forceownlines_; + /// bool needprotect_; /// should the contents be written to TOC strings? bool intoc_; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index de251e770b..e0cd894a4a 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -433,6 +433,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const // environment. Standard collapsable insets should not // redefine this, non-standard ones may call this. InsetLayout const & il = getLayout(); + if (il.forceOwnlines()) + os << breakln; if (!il.latexname().empty()) { if (il.latextype() == InsetLayout::COMMAND) { // FIXME UNICODE @@ -495,11 +497,13 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const os << breakln; else os << safebreakln; - os << "\\end{" << from_utf8(il.latexname()) << "}\n"; + os << "\\end{" << from_utf8(il.latexname()) << "}" << breakln; if (!il.isDisplay()) os.protectSpace(true); } } + if (il.forceOwnlines()) + os << breakln; } -- 2.39.2