DocBook: fix float tags (was unduly overridden).

The output was not valid for floats without title.
This commit is contained in:
Thibaut Cuvelier 2020-08-29 22:58:23 +02:00
parent 39ad6e84f0
commit 78a361778f
7 changed files with 22 additions and 25 deletions

View File

@ -6,6 +6,11 @@
cmake_minimum_required(VERSION 3.1.0) cmake_minimum_required(VERSION 3.1.0)
set(CMAKE_CXX_STANDARD 20)
set(GNUWIN32_DIR D:/LyX/lyx-unstable/lyx-windows-deps-msvc2017)
set(LYX_USE_QT "QT5")
set(LYX_REQUIRE_SPELLCHECK true)
set(LYX_PROJECT LyX) set(LYX_PROJECT LyX)
# Instruct cmake to not use gnu extensions, # Instruct cmake to not use gnu extensions,

View File

@ -164,7 +164,7 @@ I am a second line of code.
</tr> </tr>
</tbody> </tbody>
</table> </table>
<table> <informaltable>
<tbody> <tbody>
<tr> <tr>
<td align='center' valign='top'>Table that has no caption 1</td> <td align='center' valign='top'>Table that has no caption 1</td>
@ -182,7 +182,7 @@ I am a second line of code.
<td align='center' valign='top'>Col 3, row 2</td> <td align='center' valign='top'>Col 3, row 2</td>
</tr> </tr>
</tbody> </tbody>
</table> </informaltable>
<para>Then, one figure: </para> <para>Then, one figure: </para>
<figure> <figure>

View File

@ -20,7 +20,6 @@ Float
UsesFloatPkg false UsesFloatPkg false
ListCommand listoftables ListCommand listoftables
RefPrefix tab RefPrefix tab
DocBookTag table
End End
@ -36,7 +35,6 @@ Float
UsesFloatPkg false UsesFloatPkg false
ListCommand listoffigures ListCommand listoffigures
RefPrefix fig RefPrefix fig
DocBookTag figure
End End
@ -51,7 +49,6 @@ Float
IsPredefined false IsPredefined false
UsesFloatPkg true UsesFloatPkg true
RefPrefix alg RefPrefix alg
DocBookTag figure # TODO: No DocBook tag really corresponds...
End End

View File

@ -40,8 +40,7 @@ Floating::Floating(string const & type, string const & placement,
usesfloatpkg_(usesfloat), ispredefined_(ispredefined), usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
allowswide_(allowswide), allowssideways_(allowssideways), allowswide_(allowswide), allowssideways_(allowssideways),
html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle), html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle),
docbook_tag_(docbookTag), docbook_attr_(docbookAttr), docbook_attr_(docbookAttr), docbook_tag_type_(docbookTagType)
docbook_tag_type_(docbookTagType)
{} {}
@ -89,22 +88,18 @@ string const & Floating::docbookAttr() const
} }
string const & Floating::docbookTag(bool hasTitle) const string Floating::docbookTag(bool hasTitle) const
{ {
if (docbook_tag_.empty()) {
docbook_tag_ = "";
if (floattype_ == "figure") { if (floattype_ == "figure") {
docbook_tag_ = hasTitle ? "figure" : "informalfigure"; return hasTitle ? "figure" : "informalfigure";
} else if (floattype_ == "table") { } else if (floattype_ == "table") {
docbook_tag_ = hasTitle ? "table" : "informaltable"; return hasTitle ? "table" : "informaltable";
} else if (floattype_ == "algorithm") { } else if (floattype_ == "algorithm") {
// TODO: no good translation for now! Figures are the closest match, as they can contain text. // TODO: no good translation for now! Figures are the closest match, as they can contain text.
// Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer.
docbook_tag_ = "figure"; return "figure";
} }
} }
return docbook_tag_;
}
string const & Floating::docbookTagType() const string const & Floating::docbookTagType() const

View File

@ -81,7 +81,7 @@ public:
/// tag type, defaults to "div" /// tag type, defaults to "div"
std::string const & htmlTag() const; std::string const & htmlTag() const;
/// ///
std::string const & docbookTag(bool hasTitle = false) const; std::string docbookTag(bool hasTitle = false) const;
/// ///
std::string const & docbookAttr() const; std::string const & docbookAttr() const;
/// ///
@ -129,8 +129,8 @@ private:
mutable std::string defaultcssclass_; mutable std::string defaultcssclass_;
/// ///
docstring html_style_; docstring html_style_;
/// DocBook tag // There is no way to override the DocBook tag based on the layouts: half of it is determined by whether the float
mutable std::string docbook_tag_; // has a title or not, an information that is not available in the layouts.
/// attribute (mostly, role) /// attribute (mostly, role)
mutable std::string docbook_caption_; mutable std::string docbook_caption_;
/// caption tag (mostly, either caption or title) /// caption tag (mostly, either caption or title)

View File

@ -654,7 +654,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
xs << xml::StartTag(ftype.docbookTag(caption != nullptr), attr); xs << xml::StartTag(ftype.docbookTag(caption != nullptr), attr);
xs << xml::CR(); xs << xml::CR();
if (caption != nullptr) { if (caption) {
xs << xml::StartTag(titleTag); xs << xml::StartTag(titleTag);
caption->getCaptionAsDocBook(xs, rpNoLabel); caption->getCaptionAsDocBook(xs, rpNoLabel);
xs << xml::EndTag(titleTag); xs << xml::EndTag(titleTag);

View File

@ -2429,7 +2429,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
} }
// DocBook also has <equation>, but it comes with a title. // DocBook also has <equation>, but it comes with a title.
// TODO: recognise \tag from amsmath? // TODO: recognise \tag from amsmath? This would allow having <equation> with a proper title.
docstring attr; docstring attr;
for (row_type i = 0; i < nrows(); ++i) { for (row_type i = 0; i < nrows(); ++i) {