[LyX/master] DocBook: fix file inclusion.
Thibaut Cuvelier
tcuvelier at lyx.org
Tue Oct 20 00:05:51 UTC 2020
commit d1b9af3b1dede776f92910378f538f881a68d28e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date: Sun Oct 18 09:05:49 2020 +0200
DocBook: fix file inclusion.
Previously, nothing was output. Special care was needed for when new paragraphs should be open (this work is probably not finished yet).
---
src/Buffer.cpp | 2 +-
src/OutputParams.cpp | 4 ++--
src/OutputParams.h | 4 ++++
src/insets/InsetInclude.cpp | 1 +
src/output_docbook.cpp | 6 +++++-
5 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 1ccb263..53ff15b 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -2136,7 +2136,7 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os,
bool const output_preamble =
output == FullSource || output == OnlyPreamble;
bool const output_body =
- output == FullSource || output == OnlyBody;
+ output == FullSource || output == OnlyBody || output == IncludedFile;
if (output_preamble) {
// XML preamble, no doctype needed.
diff --git a/src/OutputParams.cpp b/src/OutputParams.cpp
index a7e0fd5..95d9cbc 100644
--- a/src/OutputParams.cpp
+++ b/src/OutputParams.cpp
@@ -26,8 +26,8 @@ OutputParams::OutputParams(Encoding const * enc)
use_hyperref(false), use_CJK(false),
use_indices(false), use_japanese(false), linelen(0), depth(0),
exportdata(new ExportData), postpone_fragile_stuff(false), inDisplayMath(false),
- wasDisplayMath(false), inComment(false), openbtUnit(false), only_childbibs(false),
- inTableCell(NO), inFloat(NONFLOAT),
+ wasDisplayMath(false), inComment(false), inInclude(false), openbtUnit(false),
+ only_childbibs(false), inTableCell(NO), inFloat(NONFLOAT),
inIndexEntry(false), inIPA(false), inDeletedInset(0),
changeOfDeletedInset(Change::UNCHANGED), ctObject(CT_NORMAL),
par_begin(0), par_end(0), lastid(-1), lastpos(0), isLastPar(false),
diff --git a/src/OutputParams.h b/src/OutputParams.h
index 31a7059..a165638 100644
--- a/src/OutputParams.h
+++ b/src/OutputParams.h
@@ -260,6 +260,10 @@ public:
*/
bool inComment;
+ /** Whether we are inside an include inset.
+ */
+ bool inInclude;
+
/** Whether a btUnit (for multiple biblographies) is open.
*/
mutable bool openbtUnit;
diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp
index 9ab4b98..be9e418 100644
--- a/src/insets/InsetInclude.cpp
+++ b/src/insets/InsetInclude.cpp
@@ -1102,6 +1102,7 @@ void InsetInclude::docbook(XMLStream & xs, OutputParams const & rp) const
if (all_pars) {
op.par_begin = 0;
op.par_end = 0;
+ op.inInclude = true;
ibuf->writeDocBookSource(xs.os(), op, Buffer::IncludedFile);
} else {
xs << XMLStream::ESCAPE_NONE << "<!-- Included file: ";
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index e402319..0c06b87 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -473,6 +473,10 @@ void makeParagraph(
special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
return inset.inset->lyxCode() == BOX_CODE;
});
+ // Includes should not have a paragraph.
+ special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) {
+ return inset.inset->lyxCode() == INCLUDE_CODE;
+ });
bool const open_par = runparams.docbook_make_pars
&& !runparams.docbook_in_par
@@ -922,7 +926,7 @@ void outputDocBookInfo(
// If there is no title, generate one (required for the document to be valid).
// This code is called for the main document, for table cells, etc., so be precise in this condition.
- if (text.isMainText() && info.shouldBeInInfo.empty()) {
+ if (text.isMainText() && info.shouldBeInInfo.empty() && !runparams.inInclude) {
xs << xml::StartTag("title");
xs << "Untitled Document";
xs << xml::EndTag("title");
More information about the lyx-cvs
mailing list