]> git.lyx.org Git - features.git/commitdiff
DocBook: fix float tags (was unduly overridden).
authorThibaut Cuvelier <tcuvelier@lyx.org>
Sat, 29 Aug 2020 20:58:23 +0000 (22:58 +0200)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Sat, 19 Sep 2020 18:43:38 +0000 (20:43 +0200)
The output was not valid for floats without title.

CMakeLists.txt
autotests/export/docbook/basic.xml
lib/layouts/stdfloats.inc
src/Floating.cpp
src/Floating.h
src/insets/InsetFloat.cpp
src/mathed/InsetMathHull.cpp

index d3aa1928fb81bd7a9bf38653fe52e56c5a1dd674..90853559a82efc4eef4b400dd2ec9c247acb8d7a 100644 (file)
@@ -6,6 +6,11 @@
 
 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)
 
 # Instruct cmake to not use gnu extensions,
index 430611e490e729b941245cdd4e8aa23240ad7198..a4dc27655173655bc9e600674d8154a0b4187cd3 100644 (file)
@@ -164,7 +164,7 @@ I am a second line of code.
 </tr>
 </tbody>
 </table>
-<table>
+<informaltable>
 <tbody>
 <tr>
 <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>
 </tr>
 </tbody>
-</table>
+</informaltable>
 
 <para>Then, one figure: </para>
 <figure>
index cd6614a8da58ad40298a0947a9a0742adc874857..044fcb2c5cbad367c1fcbe181b61fea7a427ed60 100644 (file)
@@ -20,7 +20,6 @@ Float
        UsesFloatPkg          false
        ListCommand           listoftables
        RefPrefix             tab
-       DocBookTag            table
 End
 
 
@@ -36,7 +35,6 @@ Float
        UsesFloatPkg          false
        ListCommand           listoffigures
        RefPrefix             fig
-       DocBookTag            figure
 End
 
 
@@ -51,7 +49,6 @@ Float
        IsPredefined          false
        UsesFloatPkg          true
        RefPrefix             alg
-       DocBookTag            figure # TODO: No DocBook tag really corresponds...
 End
 
 
index d44afc3a73499b2bf20d56474b85cc9ae3381b4f..19fbf5f49baa6d77ec4d0280e9c08e72707389f5 100644 (file)
@@ -40,8 +40,7 @@ Floating::Floating(string const & type, string const & placement,
          usesfloatpkg_(usesfloat), ispredefined_(ispredefined),
          allowswide_(allowswide), allowssideways_(allowssideways),
          html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle),
-         docbook_tag_(docbookTag), docbook_attr_(docbookAttr),
-         docbook_tag_type_(docbookTagType)
+         docbook_attr_(docbookAttr), docbook_tag_type_(docbookTagType)
 {}
 
 
@@ -89,21 +88,17 @@ 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") {
-                       docbook_tag_ = hasTitle ? "figure" : "informalfigure";
-               } else if (floattype_ == "table") {
-                       docbook_tag_ = hasTitle ? "table" : "informaltable";
-               } else if (floattype_ == "algorithm") {
-                       // 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.
-                       docbook_tag_ = "figure";
-               }
+       if (floattype_ == "figure") {
+               return hasTitle ? "figure" : "informalfigure";
+       } else if (floattype_ == "table") {
+               return hasTitle ? "table" : "informaltable";
+       } else if (floattype_ == "algorithm") {
+               // 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.
+               return "figure";
        }
-       return docbook_tag_;
 }
 
 
index 5cfea080e6d6490074e3a348b399652d65792e66..977958bc15a62a08fbb6ecd7e580fa12d69c0e1d 100644 (file)
@@ -81,7 +81,7 @@ public:
        /// tag type, defaults to "div"
        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;
        ///
@@ -129,8 +129,8 @@ private:
        mutable std::string defaultcssclass_;
        ///
        docstring html_style_;
-       /// DocBook tag
-       mutable std::string docbook_tag_;
+       // There is no way to override the DocBook tag based on the layouts: half of it is determined by whether the float
+       // has a title or not, an information that is not available in the layouts.
        /// attribute (mostly, role)
        mutable std::string docbook_caption_;
        /// caption tag (mostly, either caption or title)
index 24e06b548c2ead6dc7d1da2f92534b68f06f63fb..86bcf9d474fb577c8113943f7dc70dd39d5cb690 100644 (file)
@@ -654,7 +654,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
 
        xs << xml::StartTag(ftype.docbookTag(caption != nullptr), attr);
        xs << xml::CR();
-       if (caption != nullptr) {
+       if (caption) {
                xs << xml::StartTag(titleTag);
                caption->getCaptionAsDocBook(xs, rpNoLabel);
                xs << xml::EndTag(titleTag);
index 58471210698aa5da58d029ffcedab1046f47f06d..af30e8eea7f05aa8fc6c28e4ad6c62505873d122 100644 (file)
@@ -2429,7 +2429,7 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons
        }
 
        // 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;
        for (row_type i = 0; i < nrows(); ++i) {