Add a layout tag ForceOwnlines that assures an inset is started and terminated by a line break in the LaTeX output.

Fixes: #8875.
This commit is contained in:
Juergen Spitzmueller 2014-12-01 14:56:47 +01:00
parent e5e8bff75b
commit a25569ebb3
7 changed files with 86 additions and 16 deletions

View File

@ -1,5 +1,5 @@
#LyX 2.1 created this file. For more info see http://www.lyx.org/ #LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 476 \lyxformat 479
\begin_document \begin_document
\begin_header \begin_header
\textclass scrbook \textclass scrbook
@ -17019,6 +17019,59 @@ g.
in TeX code or URL. in TeX code or URL.
A kludge. 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 \end_layout
\begin_layout Description \begin_layout Description
@ -23533,7 +23586,7 @@ name "chap:List-of-functions"
\align center \align center
\begin_inset Tabular \begin_inset Tabular
<lyxtabular version="3" rows="11" columns="8"> <lyxtabular version="3" rows="11" columns="8">
<features rotate="0" tabularvalignment="middle"> <features tabularvalignment="middle">
<column alignment="left" valignment="top"> <column alignment="left" valignment="top">
<column alignment="left" valignment="top"> <column alignment="left" valignment="top">
<column alignment="left" valignment="top"> <column alignment="left" valignment="top">

View File

@ -6,7 +6,7 @@
# Note that this file is included in sweave.module, # Note that this file is included in sweave.module,
# knitr.module and noweb.module. # knitr.module and noweb.module.
Format 49 Format 52
Counter chunk Counter chunk
PrettyFormat "Chunk ##" PrettyFormat "Chunk ##"
@ -23,15 +23,15 @@ InsetLayout "Flex:Chunk"
Color latex Color latex
Family typewriter Family typewriter
EndFont EndFont
#LabelFont # LabelFont
#Color latex # Color latex
#Size Small # Size Small
#EndFont # EndFont
MultiPar true MultiPar true
CustomPars false CustomPars false
ForcePlain true ForcePlain true
PassThru 1 PassThru 1
ParbreakIsNewline 1 ParbreakIsNewline 1
KeepEmpty true KeepEmpty true
Spellcheck 0 Spellcheck 0
FreeSpacing true FreeSpacing true
@ -43,5 +43,6 @@ InsetLayout "Flex:Chunk"
LeftDelim << LeftDelim <<
RightDelim >>=<br/> RightDelim >>=<br/>
EndArgument EndArgument
ResetsFont false ResetsFont false
ForceOwnlines true
End End

View File

@ -171,6 +171,9 @@ import os, re, string, sys
# Incremented to format 51, 29 May 2014 by spitz # Incremented to format 51, 29 May 2014 by spitz
# New Style tag "ToggleIndent" # 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 # Do not forget to document format change in Customization
# Manual (section "Declaring a new text class"). # Manual (section "Declaring a new text class").
@ -178,7 +181,7 @@ import os, re, string, sys
# development/tools/updatelayouts.py script to update all # development/tools/updatelayouts.py script to update all
# layout files to the new format. # layout files to the new format.
currentFormat = 51 currentFormat = 52
def usage(prog_name): def usage(prog_name):
@ -402,7 +405,7 @@ def convert(lines):
i += 1 i += 1
continue continue
if format == 50: if format == 50 or format == 51:
# nothing to do. # nothing to do.
i += 1 i += 1
continue continue

View File

@ -61,7 +61,7 @@ namespace lyx {
// You should also run the development/tools/updatelayouts.py script, // You should also run the development/tools/updatelayouts.py script,
// to update the format of all of our layout files. // 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 { namespace {

View File

@ -89,6 +89,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
IL_FONT, IL_FONT,
IL_FORCE_LOCAL_FONT_SWITCH, IL_FORCE_LOCAL_FONT_SWITCH,
IL_FORCELTR, IL_FORCELTR,
IL_FORCEOWNLINES,
IL_FORCEPLAIN, IL_FORCEPLAIN,
IL_FREESPACING, IL_FREESPACING,
IL_HTMLTAG, IL_HTMLTAG,
@ -139,6 +140,7 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
{ "font", IL_FONT }, { "font", IL_FONT },
{ "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH }, { "forcelocalfontswitch", IL_FORCE_LOCAL_FONT_SWITCH },
{ "forceltr", IL_FORCELTR }, { "forceltr", IL_FORCELTR },
{ "forceownlines", IL_FORCEOWNLINES },
{ "forceplain", IL_FORCEPLAIN }, { "forceplain", IL_FORCEPLAIN },
{ "freespacing", IL_FREESPACING }, { "freespacing", IL_FREESPACING },
{ "htmlattr", IL_HTMLATTR }, { "htmlattr", IL_HTMLATTR },
@ -256,6 +258,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass)
case IL_FORCELTR: case IL_FORCELTR:
lex >> forceltr_; lex >> forceltr_;
break; break;
case IL_FORCEOWNLINES:
lex >> forceownlines_;
break;
case IL_INTOC: case IL_INTOC:
lex >> intoc_; lex >> intoc_;
break; break;

View File

@ -164,6 +164,8 @@ public:
/// ///
bool forceLTR() const { return forceltr_; } bool forceLTR() const { return forceltr_; }
/// ///
bool forceOwnlines() const { return forceownlines_; }
///
bool isInToc() const { return intoc_; } bool isInToc() const { return intoc_; }
/// ///
bool spellcheck() const { return spellcheck_; } bool spellcheck() const { return spellcheck_; }
@ -262,6 +264,8 @@ private:
/// ///
bool forceltr_; bool forceltr_;
/// ///
bool forceownlines_;
///
bool needprotect_; bool needprotect_;
/// should the contents be written to TOC strings? /// should the contents be written to TOC strings?
bool intoc_; bool intoc_;

View File

@ -433,6 +433,8 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
// environment. Standard collapsable insets should not // environment. Standard collapsable insets should not
// redefine this, non-standard ones may call this. // redefine this, non-standard ones may call this.
InsetLayout const & il = getLayout(); InsetLayout const & il = getLayout();
if (il.forceOwnlines())
os << breakln;
if (!il.latexname().empty()) { if (!il.latexname().empty()) {
if (il.latextype() == InsetLayout::COMMAND) { if (il.latextype() == InsetLayout::COMMAND) {
// FIXME UNICODE // FIXME UNICODE
@ -495,11 +497,13 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
os << breakln; os << breakln;
else else
os << safebreakln; os << safebreakln;
os << "\\end{" << from_utf8(il.latexname()) << "}\n"; os << "\\end{" << from_utf8(il.latexname()) << "}" << breakln;
if (!il.isDisplay()) if (!il.isDisplay())
os.protectSpace(true); os.protectSpace(true);
} }
} }
if (il.forceOwnlines())
os << breakln;
} }