From ffa1b1dcc7f526247ef3fa2f7a3a49dd8605d53f Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 21 Sep 2021 01:21:13 +0200 Subject: [PATCH] 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. --- lib/layouts/lilypond.module | 1 + src/insets/InsetLayout.cpp | 23 +++++++++++++++++++++++ src/insets/InsetLayout.h | 12 ++++++++++++ src/insets/InsetText.cpp | 6 ++++++ 4 files changed, 42 insertions(+) diff --git a/lib/layouts/lilypond.module b/lib/layouts/lilypond.module index b4978bda1b..6c98f14b45 100644 --- a/lib/layouts/lilypond.module +++ b/lib/layouts/lilypond.module @@ -45,6 +45,7 @@ InsetLayout "Flex:LilyPond" LabelFont Color foreground EndFont + DocBookTag IGNORE EndArgument DocBookNotInPara true DocBookWrapperTag mediaobject diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index b6056cd098..769a77402b 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -107,6 +107,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, IL_DOCBOOKITEMWRAPPERTAG, IL_DOCBOOKITEMWRAPPERTAGTYPE, IL_DOCBOOKITEMWRAPPERATTR, + IL_DOCBOOKINNERTAG, + IL_DOCBOOKINNERTAGTYPE, + IL_DOCBOOKINNERATTR, IL_DOCBOOKNOFONTINSIDE, IL_INTOC, IL_ISTOCCAPTION, @@ -156,6 +159,9 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, { "docbookargumentbeforemaintag", IL_DOCBOOKARGUMENTBEFOREMAINTAG }, { "docbookattr", IL_DOCBOOKATTR }, { "docbookininfo", IL_DOCBOOKININFO }, + { "docbookinnerattr", IL_DOCBOOKINNERATTR }, + { "docbookinnertag", IL_DOCBOOKINNERTAG }, + { "docbookinnertagtype", IL_DOCBOOKINNERTAGTYPE }, { "docbookitemattr", IL_DOCBOOKITEMATTR }, { "docbookitemtag", IL_DOCBOOKITEMTAG }, { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE }, @@ -521,6 +527,15 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, case IL_DOCBOOKTAGTYPE: lex >> docbooktagtype_; break; + case IL_DOCBOOKINNERTAG: + lex >> docbookinnertag_; + break; + case IL_DOCBOOKINNERATTR: + lex >> docbookinnerattr_; + break; + case IL_DOCBOOKINNERTAGTYPE: + lex >> docbookinnertagtype_; + break; case IL_DOCBOOKININFO: lex >> docbookininfo_; 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 { if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline") diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index b48fde7f0a..da003a95b0 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -156,6 +156,12 @@ public: /// 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; /// bool docbooksection() const { return docbooksection_; } @@ -319,6 +325,12 @@ private: /// std::string docbookattr_; /// + std::string docbookinnertag_; + /// + mutable std::string docbookinnertagtype_; + /// + std::string docbookinnerattr_; + /// mutable std::string docbookininfo_; /// bool docbooknotinpara_ = false; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 95d55b765b..635a83f7f7 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -686,6 +686,9 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\""); 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. @@ -733,6 +736,9 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op if (!il.docbookitemwrappertag().empty() && il.docbookitemwrappertag() != "NONE" && il.docbookitemwrappertag() != "IGNORE") 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") xml::closeTag(xs, il.docbooktag(), il.docbooktagtype());