mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Track whether title has been issued via OutputParams.
When branches are used in the title, we may need to track whether we've issued the title across branch insets. So we put the relevant variables into OutputParams.
This commit is contained in:
parent
7af6575cf6
commit
b536759c07
@ -33,7 +33,8 @@ OutputParams::OutputParams(Encoding const * enc)
|
|||||||
dryrun(false), silent(false), pass_thru(false),
|
dryrun(false), silent(false), pass_thru(false),
|
||||||
html_disable_captions(false), html_in_par(false),
|
html_disable_captions(false), html_in_par(false),
|
||||||
html_make_pars(true), for_toc(false), for_tooltip(false),
|
html_make_pars(true), for_toc(false), for_tooltip(false),
|
||||||
for_search(false), for_preview(false), includeall(false)
|
for_search(false), for_preview(false), includeall(false),
|
||||||
|
already_title(false), issued_title_cmd(false)
|
||||||
{
|
{
|
||||||
// Note: in PreviewLoader::Impl::dumpPreamble
|
// Note: in PreviewLoader::Impl::dumpPreamble
|
||||||
// OutputParams runparams(0);
|
// OutputParams runparams(0);
|
||||||
|
@ -357,6 +357,12 @@ public:
|
|||||||
|
|
||||||
/// Explicit output folder, if any is desired
|
/// Explicit output folder, if any is desired
|
||||||
std::string export_folder;
|
std::string export_folder;
|
||||||
|
|
||||||
|
/// Have we already output the title?
|
||||||
|
mutable bool already_title;
|
||||||
|
/// Used to signal we need to output \end{TITLEBLOCK} when title
|
||||||
|
/// environment is used.
|
||||||
|
mutable bool issued_title_cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1593,8 +1593,6 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
// lastpit is for the language check after the loop.
|
// lastpit is for the language check after the loop.
|
||||||
pit_type lastpit = pit;
|
pit_type lastpit = pit;
|
||||||
// variables used in the loop:
|
// variables used in the loop:
|
||||||
bool was_title = false;
|
|
||||||
bool already_title = false;
|
|
||||||
DocumentClass const & tclass = bparams.documentClass();
|
DocumentClass const & tclass = bparams.documentClass();
|
||||||
|
|
||||||
// Did we already warn about inTitle layout mixing? (we only warn once)
|
// Did we already warn about inTitle layout mixing? (we only warn once)
|
||||||
@ -1609,7 +1607,7 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
tclass.plainLayout() : par->layout();
|
tclass.plainLayout() : par->layout();
|
||||||
|
|
||||||
if (layout.intitle) {
|
if (layout.intitle) {
|
||||||
if (already_title) {
|
if (runparams.already_title) {
|
||||||
if (!gave_layout_warning && !runparams.dryrun) {
|
if (!gave_layout_warning && !runparams.dryrun) {
|
||||||
gave_layout_warning = true;
|
gave_layout_warning = true;
|
||||||
frontend::Alert::warning(_("Error in latexParagraphs"),
|
frontend::Alert::warning(_("Error in latexParagraphs"),
|
||||||
@ -1619,15 +1617,16 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
"could lead to missing or incorrect output."
|
"could lead to missing or incorrect output."
|
||||||
), layout.name()));
|
), layout.name()));
|
||||||
}
|
}
|
||||||
} else if (!was_title) {
|
} else if (!runparams.issued_title_cmd) {
|
||||||
was_title = true;
|
runparams.issued_title_cmd = true;
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
os << "\\begin{"
|
os << "\\begin{"
|
||||||
<< from_ascii(tclass.titlename())
|
<< from_ascii(tclass.titlename())
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (was_title && !already_title && !layout.inpreamble) {
|
} else if (runparams.issued_title_cmd &&
|
||||||
|
!runparams.already_title && !layout.inpreamble) {
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
os << "\\end{" << from_ascii(tclass.titlename())
|
os << "\\end{" << from_ascii(tclass.titlename())
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
@ -1636,8 +1635,8 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
os << "\\" << from_ascii(tclass.titlename())
|
os << "\\" << from_ascii(tclass.titlename())
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
already_title = true;
|
runparams.already_title = true;
|
||||||
was_title = false;
|
runparams.issued_title_cmd = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (layout.isCommand() && !layout.latexname().empty()
|
if (layout.isCommand() && !layout.latexname().empty()
|
||||||
@ -1692,14 +1691,17 @@ void latexParagraphs(Buffer const & buf,
|
|||||||
// But if we're in a branch, this is not the end of
|
// But if we're in a branch, this is not the end of
|
||||||
// the document. (There may be some other checks of this
|
// the document. (There may be some other checks of this
|
||||||
// kind that are needed.)
|
// kind that are needed.)
|
||||||
if (was_title && !already_title && !runparams.inbranch) {
|
if (runparams.issued_title_cmd &&
|
||||||
|
!runparams.already_title && !runparams.inbranch) {
|
||||||
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
if (tclass.titletype() == TITLE_ENVIRONMENT) {
|
||||||
os << "\\end{" << from_ascii(tclass.titlename())
|
os << "\\end{" << from_ascii(tclass.titlename())
|
||||||
<< "}\n";
|
<< "}\n";
|
||||||
|
runparams.issued_title_cmd = false;
|
||||||
} else {
|
} else {
|
||||||
os << "\\" << from_ascii(tclass.titlename())
|
os << "\\" << from_ascii(tclass.titlename())
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
runparams.already_title = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maintext && !is_child && runparams.openbtUnit)
|
if (maintext && !is_child && runparams.openbtUnit)
|
||||||
|
Loading…
Reference in New Issue
Block a user