DocBook: add inner tags for layouts.

This makes it possible to implement LilyPond as prescribed in https://lilypond.org/doc/v2.22/Documentation/usage/docbook.
This commit is contained in:
Thibaut Cuvelier 2021-09-21 01:21:13 +02:00
parent 7ee23ca885
commit ffa1b1dcc7
4 changed files with 42 additions and 0 deletions

View File

@ -45,6 +45,7 @@ InsetLayout "Flex:LilyPond"
LabelFont LabelFont
Color foreground Color foreground
EndFont EndFont
DocBookTag IGNORE
EndArgument EndArgument
DocBookNotInPara true DocBookNotInPara true
DocBookWrapperTag mediaobject DocBookWrapperTag mediaobject

View File

@ -107,6 +107,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
IL_DOCBOOKITEMWRAPPERTAG, IL_DOCBOOKITEMWRAPPERTAG,
IL_DOCBOOKITEMWRAPPERTAGTYPE, IL_DOCBOOKITEMWRAPPERTAGTYPE,
IL_DOCBOOKITEMWRAPPERATTR, IL_DOCBOOKITEMWRAPPERATTR,
IL_DOCBOOKINNERTAG,
IL_DOCBOOKINNERTAGTYPE,
IL_DOCBOOKINNERATTR,
IL_DOCBOOKNOFONTINSIDE, IL_DOCBOOKNOFONTINSIDE,
IL_INTOC, IL_INTOC,
IL_ISTOCCAPTION, IL_ISTOCCAPTION,
@ -156,6 +159,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
{ "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG }, { "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG },
{ "docbookattr", IL_DOCBOOKATTR }, { "docbookattr", IL_DOCBOOKATTR },
{ "docbookininfo", IL_DOCBOOKININFO }, { "docbookininfo", IL_DOCBOOKININFO },
{ "docbookinnerattr", IL_DOCBOOKINNERATTR },
{ "docbookinnertag", IL_DOCBOOKINNERTAG },
{ "docbookinnertagtype", IL_DOCBOOKINNERTAGTYPE },
{ "docbookitemattr", IL_DOCBOOKITEMATTR }, { "docbookitemattr", IL_DOCBOOKITEMATTR },
{ "docbookitemtag", IL_DOCBOOKITEMTAG }, { "docbookitemtag", IL_DOCBOOKITEMTAG },
{ "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE }, { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE },
@ -521,6 +527,15 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
case IL_DOCBOOKTAGTYPE: case IL_DOCBOOKTAGTYPE:
lex >> docbooktagtype_; lex >> docbooktagtype_;
break; break;
case IL_DOCBOOKINNERTAG:
lex >> docbookinnertag_;
break;
case IL_DOCBOOKINNERATTR:
lex >> docbookinnerattr_;
break;
case IL_DOCBOOKINNERTAGTYPE:
lex >> docbookinnertagtype_;
break;
case IL_DOCBOOKININFO: case IL_DOCBOOKININFO:
lex >> docbookininfo_; lex >> docbookininfo_;
break; break;
@ -714,6 +729,14 @@ std::string InsetLayout::docbooktagtype() const
} }
std::string InsetLayout::docbookinnertagtype() const
{
if (docbookinnertagtype_ != "block" && docbookinnertagtype_ != "paragraph" && docbookinnertagtype_ != "inline")
docbookinnertagtype_ = "block";
return docbookinnertagtype_;
}
std::string InsetLayout::docbookwrappertagtype() const std::string InsetLayout::docbookwrappertagtype() const
{ {
if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline") if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline")

View File

@ -156,6 +156,12 @@ public:
/// ///
std::string docbookattr() const { return docbookattr_; } std::string docbookattr() const { return docbookattr_; }
/// ///
std::string docbookinnertag() const { return docbookinnertag_; }
///
std::string docbookinnertagtype() const;
///
std::string docbookinnerattr() const { return docbookinnerattr_; }
///
std::string const & docbookininfo() const; std::string const & docbookininfo() const;
/// ///
bool docbooksection() const { return docbooksection_; } bool docbooksection() const { return docbooksection_; }
@ -319,6 +325,12 @@ private:
/// ///
std::string docbookattr_; std::string docbookattr_;
/// ///
std::string docbookinnertag_;
///
mutable std::string docbookinnertagtype_;
///
std::string docbookinnerattr_;
///
mutable std::string docbookininfo_; mutable std::string docbookininfo_;
/// ///
bool docbooknotinpara_ = false; bool docbooknotinpara_ = false;

View File

@ -686,6 +686,9 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op
attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\""); attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\"");
xml::openTag(xs, il.docbooktag(), attrs, il.docbooktagtype()); xml::openTag(xs, il.docbooktag(), attrs, il.docbooktagtype());
} }
if (!il.docbookinnertag().empty() && il.docbookinnertag() != "NONE" && il.docbookinnertag() != "IGNORE")
xml::openTag(xs, il.docbookinnertag(), il.docbookinnerattr(), il.docbookinnertagtype());
} }
// - Think about the arguments before the paragraph. // - Think about the arguments before the paragraph.
@ -733,6 +736,9 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op
if (!il.docbookitemwrappertag().empty() && il.docbookitemwrappertag() != "NONE" && il.docbookitemwrappertag() != "IGNORE") if (!il.docbookitemwrappertag().empty() && il.docbookitemwrappertag() != "NONE" && il.docbookitemwrappertag() != "IGNORE")
xml::closeTag(xs, il.docbookitemwrappertag(), il.docbookitemwrappertagtype()); xml::closeTag(xs, il.docbookitemwrappertag(), il.docbookitemwrappertagtype());
if (!il.docbookinnertag().empty() && il.docbookinnertag() != "NONE" && il.docbookinnertag() != "IGNORE")
xml::closeTag(xs, il.docbookinnertag(), il.docbookinnertagtype());
if (!il.docbooktag().empty() && il.docbooktag() != "NONE" && il.docbooktag() != "IGNORE") if (!il.docbooktag().empty() && il.docbooktag() != "NONE" && il.docbooktag() != "IGNORE")
xml::closeTag(xs, il.docbooktag(), il.docbooktagtype()); xml::closeTag(xs, il.docbooktag(), il.docbooktagtype());