DocBook: introduce Floating::docbookFloatType.

This ensures that all comparisons for DocBook are made on the same normalised version of the float type. This cased a strange bug where <table> was output within <informaltable> for Linguistics Tableaux.
This commit is contained in:
Thibaut Cuvelier 2020-09-03 00:48:55 +02:00
parent 8ed8d36595
commit 2cd7a94f8b
4 changed files with 26 additions and 7 deletions

View File

@ -140,7 +140,6 @@ EndPreamble</programlisting>
<para>Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es ausgewählt ist, finden Sie unter <emphasis role='sans'>Einfügen&#x21D2;Gleitobjekte</emphasis> zusätzlich ein Tableau-Gleitobjekt (siehe Tableau&#xA0;<xref linkend="tab.Beispiel-Tableau" /> für ein Beispiel).</para>
<table xml:id="tab.Beispiel-Tableau">
<caption>Beispiel-Tableau</caption>
<informaltable>
<tbody>
<tr>
<td align='right' valign='top'>/atikap/</td>
@ -205,7 +204,6 @@ EndPreamble</programlisting>
<td align='center' valign='top'></td>
</tr>
</tbody>
</informaltable>
</table>
<para>Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code in <emphasis role='sans'>Dokument&#x21D2;Einstellungen&#x21D2;Präambel </emphasis>eingeben:</para>

View File

@ -44,6 +44,25 @@ Floating::Floating(string const & type, string const & placement,
{}
std::string Floating::docbookFloatType() const
{
// TODO: configure this in the layouts?
if (floattype_ == "figure") {
return "figure";
} 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.
LYXERR0("Unrecognised float type: " + floattype_);
return "unknown";
}
}
string const & Floating::htmlAttrib() const
{
if (html_attrib_.empty())
@ -91,17 +110,17 @@ string const & Floating::docbookAttr() const
string Floating::docbookTag(bool hasTitle) const
{
// TODO: configure this in the layouts?
if (floattype_ == "figure") {
if (docbookFloatType() == "figure") {
return hasTitle ? "figure" : "informalfigure";
} else if (floattype_ == "table" || floattype_ == "tableau") {
} else if (docbookFloatType() == "table") {
return hasTitle ? "table" : "informaltable";
} else if (floattype_ == "algorithm") {
} 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_);
LYXERR0("Unrecognised float type: " + floattype());
return "float";
}
}

View File

@ -44,6 +44,8 @@ public:
///
std::string const & floattype() const { return floattype_; }
///
std::string docbookFloatType() const;
///
std::string const & placement() const { return placement_; }
///
std::string const & ext() const {return ext_; }

View File

@ -639,7 +639,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I
// captions, they cannot appear at the end of the float, albeit LyX is happy with that).
OutputParams rpNoTitle = runparams;
rpNoTitle.docbook_in_float = true;
if (ftype.floattype() == "table")
if (ftype.docbookFloatType() == "table")
rpNoTitle.docbook_in_table = true;
// Organisation: <float> <title if any/> <contents without title/> </float>.