mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
DocBook: in InsetInfo, ensure that no db:date is inserted within a db:date.
This commit is contained in:
parent
78b157b61e
commit
43921861b9
@ -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
|
||||
|
@ -2,6 +2,9 @@
|
||||
<!-- This DocBook file was created by LyX 2.4.0~RC1.devel
|
||||
See https://www.lyx.org/ for more information -->
|
||||
<article xml:lang="en-US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
|
||||
<info>
|
||||
<title>Test: InsetInfo</title>
|
||||
<date>2023-10-08</date>
|
||||
</info>
|
||||
<para>Véase la <emphasis><phrase role="localized">User's Guide</phrase></emphasis> o <emphasis><phrase role="localized">Additional Features</phrase></emphasis> para más detalles.</para>
|
||||
</article>
|
@ -3669,6 +3669,7 @@ std::tuple<std::vector<docstring>, std::vector<docstring>, std::vector<docstring
|
||||
}
|
||||
}
|
||||
}
|
||||
rp.lastid = id();
|
||||
|
||||
// State variables for the main loop.
|
||||
auto xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution
|
||||
|
@ -1726,8 +1726,19 @@ void InsetInfo::docbook(XMLStream & xs, OutputParams const & rp) const
|
||||
break;
|
||||
}
|
||||
|
||||
// A db:date cannot be nested within a db:date. This case typically happens when the document class defines a
|
||||
// Date layout. In this case, avoid outputting a new db:date. This means that InsetInfo cannot add a role on top
|
||||
// of the previous db:date, hence add it as a comment. (Another solution would be an XML processing instruction,
|
||||
// but this case is not common enough.) Adding the role to the already output tag might have consequences for
|
||||
// some document classes where the layout already has a role or uses the same role for another purpose.
|
||||
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("<!-- ") + role + " -->");
|
||||
xs << qstring_to_ucs4(parseDate(buffer(), params_).toString(Qt::ISODate));
|
||||
if (!isWithinDate)
|
||||
xml::closeTag(xs, "date", "inline");
|
||||
break;
|
||||
}
|
||||
@ -1752,8 +1763,16 @@ 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("<!-- ") + role + " -->");
|
||||
xs << qstring_to_ucs4(parseTime(buffer(), params_).toString(Qt::ISODate));
|
||||
if (!isWithinDate)
|
||||
xml::closeTag(xs, "date", "inline");
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user