From 43921861b9b14c2b4f5b2cef8e482a43776fc982 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 8 Oct 2023 21:06:46 +0200 Subject: [PATCH] DocBook: in InsetInfo, ensure that no db:date is inserted within a db:date. --- autotests/export/docbook/insetinfo.lyx | 11 +++++++++++ autotests/export/docbook/insetinfo.xml | 3 +++ src/Paragraph.cpp | 11 ++++++----- src/insets/InsetInfo.cpp | 27 ++++++++++++++++++++++---- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/autotests/export/docbook/insetinfo.lyx b/autotests/export/docbook/insetinfo.lyx index 1ae6c30760..a1b04a54f9 100644 --- a/autotests/export/docbook/insetinfo.lyx +++ b/autotests/export/docbook/insetinfo.lyx @@ -91,6 +91,17 @@ Test: InsetInfo \end_layout +\begin_layout Date + +\lang japanese-cjk +\begin_inset Info +type "moddate" +arg "long" +\end_inset + + +\end_layout + \begin_layout Standard \lang spanish diff --git a/autotests/export/docbook/insetinfo.xml b/autotests/export/docbook/insetinfo.xml index 48ba1d802d..dd0dd6630c 100644 --- a/autotests/export/docbook/insetinfo.xml +++ b/autotests/export/docbook/insetinfo.xml @@ -2,6 +2,9 @@
+ Test: InsetInfo +2023-10-08 + Véase la User's Guide o Additional Features para más detalles.
\ No newline at end of file diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 333aeb8862..5ac03fa474 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3635,11 +3635,11 @@ std::tuple, vector> computeDocBookFontSwit std::tuple, std::vector, std::vector> Paragraph::simpleDocBookOnePar(Buffer const & buf, - OutputParams const & runparams, - Font const & outerfont, - pos_type initial, - bool is_last_par, - bool ignore_fonts) const + OutputParams const & runparams, + Font const & outerfont, + pos_type initial, + bool is_last_par, + bool ignore_fonts) const { // Return values: segregation of the content of this paragraph. std::vector prependedParagraphs; // Anything that must be output before the main tag of this paragraph. @@ -3669,6 +3669,7 @@ std::tuple, std::vector, std::vector"); xs << qstring_to_ucs4(parseDate(buffer(), params_).toString(Qt::ISODate)); - xml::closeTag(xs, "date", "inline"); + if (!isWithinDate) + xml::closeTag(xs, "date", "inline"); break; } @@ -1752,9 +1763,17 @@ void InsetInfo::docbook(XMLStream & xs, OutputParams const & rp) const } // DocBook has no specific element for time, so use a date. - xml::openTag(xs, "date", "(role=\"" + role + "\"", "inline"); + // See the discussion above (DATE_INFO, MODDATE_INFO, and FIXDATE_INFO) for a discussion about the choices that + // have been made. + const bool isWithinDate = buffer().getParFromID(rp.lastid).top().paragraph().layout().docbooktag() == "date"; + + if (!isWithinDate) + xml::openTag(xs, "date", "role=\"" + role + "\"", "inline"); + else + xs << XMLStream::ESCAPE_NONE << from_ascii(std::string(""); xs << qstring_to_ucs4(parseTime(buffer(), params_).toString(Qt::ISODate)); - xml::closeTag(xs, "date", "inline"); + if (!isWithinDate) + xml::closeTag(xs, "date", "inline"); break; }