Add buffer param to opt-out fragile content movement

Fixes #11714

File format change
This commit is contained in:
Juergen Spitzmueller 2020-01-10 10:21:09 +01:00
parent 09130d7a62
commit c77999a5f3
12 changed files with 469 additions and 120 deletions

View File

@ -7,6 +7,10 @@ changes happened in particular if possible. A good example would be
-----------------------
2020-01-10 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 591: Add buffer param \postpone_fragile_content
(option to disable the mobement of labels and stuff of moving arguments).
2019-12-24 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 590: Add native changebar solution via buffer param
\change_bars.

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 590
\lyxformat 591
\begin_document
\begin_header
\save_transient_properties true
@ -150,6 +150,7 @@ logicalmkup
\tracking_changes true
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict true
@ -47725,25 +47726,105 @@ reference "sec:File-Formats"
\end_layout
\begin_layout Description
\change_inserted -712698321 1578647276
Allow
\begin_inset space ~
\end_inset
running
\begin_inset space ~
\end_inset
external
\begin_inset space ~
\end_inset
programs If this is switched on, \SpecialChar LaTeX
is run with the
\family typewriter
-shell-escape
\family default
option which is needed with some packages.
Note that this comes with security risks, so please use this only when
really necessary and if you know what you are doing.
\end_layout
\begin_layout Description
\change_inserted -712698321 1578647006
LaTeX
\begin_inset space ~
\end_inset
Output
\begin_inset space ~
\end_inset
Options offers settings for the
\family sans
LaTeX
\family default
export.
\end_layout
\begin_deeper
\begin_layout Itemize
\family sans
Synchronize
\change_inserted -712698321 1578646679
\change_deleted -712698321 1578646679
\begin_inset space ~
\end_inset
\change_unchanged
with
\change_deleted -712698321 1578646686
\begin_inset space ~
\end_inset
Output settings for the menu
\change_inserted -712698321 1578646686
\change_unchanged
Output
\family default
\change_inserted -712698321 1578646719
enables
\change_deleted -712698321 1578646729
settings for the menu
\family sans
Navigate\SpecialChar menuseparator
\change_unchanged
Forward
\begin_inset space ~
\end_inset
search
\change_inserted -712698321 1578646752
\family default
and allows to customize the macro used in this process
\change_deleted -712698321 1578646757
.
For a detailed description see section
\change_unchanged
\change_inserted -712698321 1578646759
(
\change_deleted -712698321 1578646759
F
\change_inserted -712698321 1578646759
f
\change_unchanged
or a detailed description see section
\emph on
Reverse DVI/PDF search
\emph default
@ -47755,9 +47836,55 @@ Additional
Features
\emph default
manual.
manual
\change_inserted -712698321 1578646762
)
\change_unchanged
.
\change_inserted -712698321 1578647009
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1578647929
\family sans
Put fragile content out of moving arguments
\family default
determines whether so-called
\begin_inset Quotes els
\end_inset
fragile
\begin_inset Quotes ers
\end_inset
\SpecialChar LaTeX
constructs (such as labels or index entries) are placed outside of so-called
\begin_inset Quotes els
\end_inset
moving arguments
\begin_inset Quotes ers
\end_inset
in \SpecialChar LaTeX
(such as sections or captions), even if the corresponding insets are
placed in such context in \SpecialChar LyX
.
This setting is on by default, since it prevents nasty \SpecialChar LaTeX
errors.
If you rely on labels or index entries being kept inside the problematic
macros, you can uncheck this.
If you don't know what we are talking about here, worry not: just leave
it checked.
\change_unchanged
\end_layout
\end_deeper
\begin_layout Description
XHTML
\begin_inset space ~

View File

@ -1,5 +1,5 @@
#LyX 2.4 created this file. For more info see https://www.lyx.org/
\lyxformat 590
\lyxformat 591
\begin_document
\begin_header
\save_transient_properties true
@ -155,6 +155,7 @@ logicalmkup
\tracking_changes false
\output_changes false
\change_bars false
\postpone_fragile_content false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
@ -45050,6 +45051,106 @@ reference "sec:Dateiformate"
.
\end_layout
\begin_layout Description
Erlaube
\begin_inset space ~
\end_inset
den
\begin_inset space ~
\end_inset
Aufruf
\begin_inset space ~
\end_inset
externer
\begin_inset space ~
\end_inset
Programme Wenn dies aktiviert ist, wird \SpecialChar LaTeX
mit der Option
\family typewriter
-shell-escape
\family default
ausgeführt.
Dies ist zur Nutzung mancher Pakete nötig.
Beachten Sie, dass dies Sicherheitsrisiken birgt! Aktivieren Sie dies also
nur wenn unbedingt nötig und Sie absolut sicher sind, was Sie tun.
\end_layout
\begin_layout Description
LaTeX-Ausgabe-Optionen bietet Einstellmöglichkeiten für den
\family sans
LaTeX
\family default
-Export.
\end_layout
\begin_deeper
\begin_layout Itemize
\family sans
Mit der Ausgabe synchronisieren
\family default
aktiviert die
\family sans
Vorwärtssuche
\family default
und ermöglicht die Anpassung der dabei verwendeten Makros.
Siehe Abschnitt
\emph on
DVI/PDF Rückwärtssuche
\emph default
der
\emph on
Handbuchergänzungen
\emph default
für eine detaillierte Beschreibung.
\end_layout
\begin_layout Itemize
\family sans
Zerbrechlichen Inhalt aus beweglichen Argumenten verschieben
\family default
bestimmt, ob so genannte
\begin_inset Quotes gls
\end_inset
zerbrechliche
\begin_inset Quotes grs
\end_inset
\SpecialChar LaTeX
-Konstrukte (z.
\begin_inset space \thinspace{}
\end_inset
B.
Marken oder Stichworteinträge) in der \SpecialChar LaTeX
-Ausgabe außerhalb von so genannten
\begin_inset Quotes gls
\end_inset
beweglichen Argumenten
\begin_inset Quotes grs
\end_inset
(wie Legenden oder Überschriften) gesetzt werden, auch wenn die entsprechenden
Einfügungen in \SpecialChar LyX
in dieses Umfeld platziert werden.
Diese Einstellung ist per Voreinstellung aktiviert, da sie unangenehme
\SpecialChar LaTeX
-Fehler verhindert.
Falls Sie darauf angewiesen sind, dass Marken oder Stichworteinträge innerhalb
der problematischen Umgebungen verbleiben, können Sie dies deaktivieren.
Falls Sie keine Ahnung haben, wovon wir hier überhaupt reden, kein Problem:
Lassen Sie es einfach aktiviert.
\end_layout
\end_deeper
\begin_layout Description
Mit
\begin_inset space ~

View File

@ -3668,6 +3668,28 @@ def revert_changebars(document):
del document.header[i]
def convert_postpone_fragile(document):
" Adds false \\postpone_fragile_content buffer param "
i = find_token(document.header, "\\output_changes", 0)
if i == -1:
document.warning("Malformed LyX document! Missing \\output_changes header.")
return
# Set this to false for old documents (see #2154)
document.header.insert(i, "\\postpone_fragile_content false")
def revert_postpone_fragile(document):
" Remove \\postpone_fragile_content buffer param "
i = find_token(document.header, "\\postpone_fragile_content", 0)
if i == -1:
document.warning("Malformed LyX document! Missing \\postpone_fragile_content.")
return
del document.header[i]
##
# Conversion hub
#
@ -3719,10 +3741,12 @@ convert = [
[587, [convert_pagesizenames]],
[588, []],
[589, [convert_totalheight]],
[590, [convert_changebars]]
[590, [convert_changebars]],
[591, [convert_postpone_fragile]]
]
revert = [[589, [revert_changebars]],
revert = [[590, [revert_postpone_fragile]],
[589, [revert_changebars]],
[588, [revert_totalheight]],
[587, [revert_memoir_endnotes,revert_enotez,revert_theendnotes]],
[586, [revert_pagesizenames]],

View File

@ -411,6 +411,7 @@ BufferParams::BufferParams()
track_changes = false;
output_changes = false;
change_bars = false;
postpone_fragile_content = true;
use_default_options = true;
maintain_unincluded_children = false;
secnumdepth = 3;
@ -954,6 +955,8 @@ string BufferParams::readToken(Lexer & lex, string const & token,
lex >> output_changes;
} else if (token == "\\change_bars") {
lex >> change_bars;
} else if (token == "\\postpone_fragile_content") {
lex >> postpone_fragile_content;
} else if (token == "\\branch") {
lex.eatLine();
docstring branch = lex.getDocString();
@ -1475,6 +1478,8 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
<< (save_transient_properties ? convert<string>(change_bars) : "false")
<< '\n';
os << "\\postpone_fragile_content " << convert<string>(postpone_fragile_content) << '\n';
os << "\\html_math_output " << html_math_output << '\n'
<< "\\html_css_as_file " << html_css_as_file << '\n'
<< "\\html_be_strict " << convert<string>(html_be_strict) << '\n';

View File

@ -437,6 +437,8 @@ public:
bool change_bars;
///
bool compressed;
///
bool postpone_fragile_content;
/// the author list for the document
AuthorList & authors();

View File

@ -913,8 +913,8 @@ GuiDocument::GuiDocument(GuiView & lv)
connect(outputModule->shellescapeCB, SIGNAL(stateChanged(int)),
this, SLOT(shellescapeChanged()));
connect(outputModule->outputsyncCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(outputModule->outputsyncCB, SIGNAL(toggled(bool)),
this, SLOT(setOutputSync(bool)));
connect(outputModule->synccustomCB, SIGNAL(editTextChanged(QString)),
this, SLOT(change_adaptor()));
outputModule->synccustomCB->addItem("");
@ -926,7 +926,9 @@ GuiDocument::GuiDocument(GuiView & lv)
outputModule->synccustomCB));
connect(outputModule->saveTransientPropertiesCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
this, SLOT(change_adaptor()));
connect(outputModule->postponeFragileCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
// language & quote
@ -3682,6 +3684,8 @@ void GuiDocument::applyView()
bp_.save_transient_properties =
outputModule->saveTransientPropertiesCB->isChecked();
bp_.postpone_fragile_content =
outputModule->postponeFragileCB->isChecked();
// fonts
bp_.fonts_roman[nontexfonts] =
@ -4313,6 +4317,8 @@ void GuiDocument::paramsToDialog()
outputModule->shellescapeCB->setChecked(bp_.shell_escape);
outputModule->outputsyncCB->setChecked(bp_.output_sync);
outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro));
outputModule->synccustomCB->setEnabled(bp_.output_sync);
outputModule->synccustomLA->setEnabled(bp_.output_sync);
outputModule->mathimgSB->setValue(bp_.html_math_img_scale);
outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output);
@ -4321,6 +4327,8 @@ void GuiDocument::paramsToDialog()
outputModule->saveTransientPropertiesCB
->setChecked(bp_.save_transient_properties);
outputModule->postponeFragileCB
->setChecked(bp_.postpone_fragile_content);
// paper
bool const extern_geometry =
@ -5154,6 +5162,13 @@ void GuiDocument::outputChangesToggled(bool on)
change_adaptor();
}
void GuiDocument::setOutputSync(bool on)
{
outputModule->synccustomCB->setEnabled(on);
outputModule->synccustomLA->setEnabled(on);
change_adaptor();
}
Dialog * createGuiDocument(GuiView & lv) { return new GuiDocument(lv); }

View File

@ -165,6 +165,7 @@ private Q_SLOTS:
void resetModuleFilter();
void linenoToggled(bool);
void outputChangesToggled(bool);
void setOutputSync(bool);
private:
/// validate listings parameters and return an error message, if any
QString validateListingsParameters();

View File

@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>388</width>
<height>413</height>
<width>510</width>
<height>504</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="outputFormatGB">
<property name="title">
@ -22,7 +22,7 @@
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout">
<layout class="QGridLayout" name="gridlayout8">
<property name="leftMargin">
<number>9</number>
</property>
@ -75,36 +75,24 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QGroupBox" name="savingGB">
<property name="title">
<string>LyX Format</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="saveTransientPropertiesCB">
<property name="toolTip">
<string>Save all parameters in the LyX file, including ones that are frequently switched or that are specific to the user (such as the output of the tracked changes, or the document directory path). Disabling this option plays nicer in collaborative settings and with version control systems.</string>
</property>
<property name="text">
<string>Save &amp;transient properties</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="shellescapeCB">
<property name="toolTip">
@ -115,51 +103,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="outputsyncCB">
<property name="toolTip">
<string>Enable forward/reverse search between editor and output (e.g., SyncTeX)</string>
</property>
<property name="title">
<string>S&amp;ynchronize with output</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>C&amp;ustom macro:</string>
</property>
<property name="buddy">
<cstring>synccustomCB</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="synccustomCB">
<property name="toolTip">
<string>Custom LaTeX preamble macro</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QGroupBox" name="xhtmlGB">
<property name="title">
@ -169,32 +112,6 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="outGridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="strictCB">
<property name="toolTip">
<string>Whether to comply strictly with XHTML 1.1.</string>
</property>
<property name="text">
<string>&amp;Strict XHTML 1.1</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mathoutLA">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>&amp;Math output:</string>
</property>
<property name="buddy">
<cstring>mathoutCB</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mathoutCB">
<property name="font">
@ -228,6 +145,29 @@
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cssCB">
<property name="text">
<string>Write CSS to file</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mathoutLA">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>&amp;Math output:</string>
</property>
<property name="buddy">
<cstring>mathoutCB</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mathimgLA">
<property name="font">
@ -244,6 +184,16 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="strictCB">
<property name="toolTip">
<string>Whether to comply strictly with XHTML 1.1.</string>
</property>
<property name="text">
<string>&amp;Strict XHTML 1.1</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mathimgSB">
<property name="font">
@ -269,17 +219,48 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cssCB">
<item row="1" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="savingGB">
<property name="title">
<string>LyX Format</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout7">
<item row="0" column="0">
<widget class="QCheckBox" name="saveTransientPropertiesCB">
<property name="toolTip">
<string>Save all parameters in the LyX file, including ones that are frequently switched or that are specific to the user (such as the output of the tracked changes, or the document directory path). Disabling this option plays nicer in collaborative settings and with version control systems.</string>
</property>
<property name="text">
<string>Write CSS to file</string>
<string>Save &amp;transient properties</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -292,6 +273,92 @@
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="latexOutputGB">
<property name="title">
<string>LaTeX Output Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="outputsyncCB">
<property name="toolTip">
<string>Enable forward/reverse search between editor and output (e.g., SyncTeX)</string>
</property>
<property name="text">
<string>S&amp;ynchronize with output</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="synccustomLA">
<property name="text">
<string>C&amp;ustom macro:</string>
</property>
<property name="buddy">
<cstring>synccustomCB</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="synccustomCB">
<property name="toolTip">
<string>Custom LaTeX preamble macro</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="postponeFragileCB">
<property name="toolTip">
<string>If this is checked, fragile items such as labels and index entries are moved out of moving arguments such as sections and captions. This prevents LaTeX errors that can happen in such cases. It is recommended to keep this on.</string>
</property>
<property name="text">
<string>Put fra&amp;gile content out of moving arguments</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<includes>

View File

@ -260,7 +260,7 @@ void InsetCaption::latex(otexstream & os,
OutputParams runparams = runparams_in;
// Some fragile commands (labels, index entries)
// are output after the caption (#2154)
runparams.postpone_fragile_stuff = true;
runparams.postpone_fragile_stuff = buffer().masterParams().postpone_fragile_content;
InsetText::latex(os, runparams);
if (!runparams.post_macro.empty()) {
// Output the stored fragile commands (labels, indices etc.)

View File

@ -818,7 +818,8 @@ void TeXOnePar(Buffer const & buf,
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
runparams.postpone_fragile_stuff = true;
runparams.postpone_fragile_stuff =
bparams.postpone_fragile_content;
if (intitle_command)
os << '{';
@ -932,7 +933,8 @@ void TeXOnePar(Buffer const & buf,
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
runparams.postpone_fragile_stuff = true;
runparams.postpone_fragile_stuff =
bparams.postpone_fragile_content;
os << '{';
}
@ -1149,7 +1151,8 @@ void TeXOnePar(Buffer const & buf,
// Due to the moving argument, some fragile
// commands (labels, index entries)
// are output after this command (#2154)
runparams.postpone_fragile_stuff = true;
runparams.postpone_fragile_stuff =
bparams.postpone_fragile_content;
}
Font const outerfont = text.outerFont(pit);

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 590 // spitz: changebars
#define LYX_FORMAT_TEX2LYX 590
#define LYX_FORMAT_LYX 591 // spitz: postpone_fragile_content
#define LYX_FORMAT_TEX2LYX 591
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER