commit 4405f0164a7a2596f76f6c3c8462b4be1cca910a
Author: Thibaut Cuvelier <[email protected]>
Date: Sun Oct 25 15:38:08 2020 +0100
DocBook: implement algorithm floats.
Now that https://github.com/docbook/docbook/pull/185 has been merged into
DocBook 5.2.
---
src/Floating.cpp | 25 +++++++++----------------
src/Floating.h | 2 +-
2 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/src/Floating.cpp b/src/Floating.cpp
index 6ae52b4..ff1667f 100644
--- a/src/Floating.cpp
+++ b/src/Floating.cpp
@@ -52,8 +52,6 @@ std::string Floating::docbookFloatType() const
} else if (floattype_ == "table" || floattype_ == "tableau") {
return "table";
} 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 "algorithm";
} else {
// If nothing matches, return something that will not be valid.
@@ -101,23 +99,23 @@ string Floating::defaultCSSClass() const
}
-string const & Floating::docbookAttr() const
+string Floating::docbookAttr() const
{
- return docbook_attr_;
+ // For algorithms, a type attribute must be mentioned, if not already
present in docbook_attr_.
+ if (docbookFloatType() == "algorithm" && docbook_attr_.find("type=") !=
std::string::npos)
+ return docbook_attr_ + " type='algorithm'";
+ else
+ return docbook_attr_;
}
string Floating::docbookTag(bool hasTitle) const
{
// TODO: configure this in the layouts?
- if (docbookFloatType() == "figure") {
+ if (docbookFloatType() == "figure" || docbookFloatType() ==
"algorithm") {
return hasTitle ? "figure" : "informalfigure";
} else if (docbookFloatType() == "table") {
return hasTitle ? "table" : "informaltable";
- } else if (docbookFloatType() == "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";
} else {
// If nothing matches, return something that will not be valid.
LYXERR0("Unrecognised float type: " + floattype());
@@ -137,15 +135,10 @@ string const & Floating::docbookTagType() const
string const & Floating::docbookCaption() const
{
docbook_caption_ = "";
- if (floattype_ == "figure") {
+ if (floattype_ == "figure" || floattype_ == "algorithm")
docbook_caption_ = "title";
- } else if (floattype_ == "table" || floattype_ == "tableau") {
+ else if (floattype_ == "table" || floattype_ == "tableau")
docbook_caption_ = "caption";
- } 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_caption_ = "title";
- }
return docbook_caption_;
}
diff --git a/src/Floating.h b/src/Floating.h
index 0a2eb50..a6f2ec3 100644
--- a/src/Floating.h
+++ b/src/Floating.h
@@ -85,7 +85,7 @@ public:
///
std::string docbookTag(bool hasTitle = false) const;
///
- std::string const & docbookAttr() const;
+ std::string docbookAttr() const;
///
std::string const & docbookTagType() const;
///
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs