]> git.lyx.org Git - lyx.git/commitdiff
DocBook: InsetText supports items and wrappers.
authorThibaut Cuvelier <tcuvelier@lyx.org>
Wed, 18 Nov 2020 03:34:58 +0000 (04:34 +0100)
committerThibaut Cuvelier <tcuvelier@lyx.org>
Fri, 20 Nov 2020 17:41:02 +0000 (18:41 +0100)
autotests/export/docbook/svglo.lyx
autotests/export/docbook/svglo.xml
lib/layouts/stdinsets.inc
lib/layouts/svglobal3.layout
src/insets/InsetERT.cpp
src/insets/InsetLayout.cpp
src/insets/InsetLayout.h
src/insets/InsetText.cpp

index 397f144cb9de7f5187d2642a8e9307d1b054304c..8ffc7f93c437833799862395af5744f1e4b3e375 100644 (file)
@@ -208,7 +208,7 @@ more
 
 \begin_layout Standard
 Your text comes here.
- Separate text sections with
 \end_layout
 
 \end_body
index 9615ca9917763c6ffbe51e0f38cae2e8b29310a0..47c242a877a8660e176e27b3f0f1e646c6050fd4 100644 (file)
@@ -4,16 +4,16 @@
 <article xml:lang="en_US" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:xi="http://www.w3.org/2001/XInclude" version="5.2">
 <info>
 <title>Title</title>
-<subjectset role='pacs'><subject>PACS code1 <!-- \and  -->
+<subjectset role='pacs'><subject><subjectterm>PACS code1 <!-- \and  -->
 PACS code2 <!-- \and  -->
-more</subject></subjectset><subjectset role='mcs'><subject>MSC code1 <!-- \and  -->
+more</subjectterm></subject></subjectset><subjectset role='mcs'><subject><subjectterm>MSC code1 <!-- \and  -->
 MSC code2 <!-- \and  -->
-more</subject></subjectset><keywordset><keyword>First keyword <!-- \and  -->
+more</subjectterm></subject></subjectset><keywordset><keyword>First keyword <!-- \and  -->
 Second keyword <!-- \and  -->
 More</keyword></keywordset><abstract>
 <para>Abstract text.   </para>
 </abstract>
 
 </info>
-<para>Your text comes here. Separate text sections with</para>
+<para>Your text comes here. </para>
 </article>
\ No newline at end of file
index 1147fa5094347a9d455bcf55c0bbe539c1241c37..2a842ab45d7230ef07080f216d560d73454bbde2 100644 (file)
@@ -89,6 +89,7 @@ InsetLayout Foot
        AddToToc              footnote
        IsTocCaption          true
        DocBookTag            footnote
+       DocBookTagType        inline
 End
 
 InsetLayout Foot:InTitle
index 7a9083ae592d42ae52e338738b32fdd565b38803..3e9503d3b37be3a4c918932ded4d8dc450b52b92 100644 (file)
@@ -72,10 +72,14 @@ InsetLayout Flex:PACS
        CopyStyle       Flex:Keywords
        LatexName       PACS
        LabelString     "PACS"
-       DocBookTag          subject
-       DocBookTagType      paragraph
-       DocBookWrapperTag   subjectset
-       DocBookWrapperAttr  role='pacs'
+       DocBookTag          subjectset
+       DocBookAttr         role='pacs'
+       DocBookItemWrapperTag      subject
+       DocBookItemWrapperTagType  paragraph
+       DocBookItemTag      subjectterm
+       DocBookItemTagType  inline
+       DocBookWrapperTag   NONE
+       DocBookWrapperAttr  ""
        DocBookInInfo       always
 End
 
@@ -83,10 +87,14 @@ InsetLayout Flex:Subclass
        CopyStyle       Flex:Keywords
        LatexName       subclass
        LabelString     "Mathematics Subject Classification"
-       DocBookTag          subject
-       DocBookTagType      paragraph
-       DocBookWrapperTag   subjectset
-       DocBookWrapperAttr  role='mcs'
+       DocBookTag          subjectset
+       DocBookAttr         role='mcs'
+       DocBookItemWrapperTag      subject
+       DocBookItemWrapperTagType  paragraph
+       DocBookItemTag      subjectterm
+       DocBookItemTagType  inline
+       DocBookWrapperTag   NONE
+       DocBookWrapperAttr  ""
        DocBookInInfo       always
 End
 
@@ -94,10 +102,14 @@ InsetLayout Flex:CRSC
        CopyStyle       Flex:PACS
        LatexName       CRclass
        LabelString     "CR Subject Classification"
-       DocBookTag          subject
-       DocBookTagType      paragraph
-       DocBookWrapperTag   subjectset
-       DocBookWrapperAttr  role='crsc'
+       DocBookTag          subjectset
+       DocBookAttr         role='crsc'
+       DocBookItemWrapperTag      subject
+       DocBookItemWrapperTagType  paragraph
+       DocBookItemTag      subjectterm
+       DocBookItemTagType  inline
+       DocBookWrapperTag   NONE
+       DocBookWrapperAttr  ""
        DocBookInInfo       always
 End
 
index 1af67e1e31d3b5c8e994fa1e1dffa17bf8cf4bbd..e86724dc63a43b5fce6d831210aa3e0a7048e5d8 100644 (file)
@@ -122,6 +122,11 @@ void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const
                        break;
        }
 
+//     // Implement the special case of \and: split the current item.
+//     if (os.str() == "\\and" || os.str() == "\\and ") {
+//             auto lay = getLayout();
+//     }
+
        // Output the ERT as a comment with the appropriate escaping.
        xs << XMLStream::ESCAPE_NONE << "<!-- ";
        xs << XMLStream::ESCAPE_COMMENTS << os.str();
index dcb863c8cd511265ae5d91887e1d9ad428f39786..62030d063f93d954fee34a6cfdfb14b8b3442da4 100644 (file)
@@ -98,6 +98,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                IL_DOCBOOKWRAPPERTAG,
                IL_DOCBOOKWRAPPERTAGTYPE,
                IL_DOCBOOKWRAPPERATTR,
+               IL_DOCBOOKITEMTAG,
+               IL_DOCBOOKITEMTAGTYPE,
+               IL_DOCBOOKITEMATTR,
+               IL_DOCBOOKITEMWRAPPERTAG,
+               IL_DOCBOOKITEMWRAPPERTAGTYPE,
+               IL_DOCBOOKITEMWRAPPERATTR,
                IL_INTOC,
                IL_ISTOCCAPTION,
                IL_LABELFONT,
@@ -144,6 +150,12 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                { "display", IL_DISPLAY },
                { "docbookattr", IL_DOCBOOKATTR },
                { "docbookininfo", IL_DOCBOOKININFO },
+               { "docbookitemattr", IL_DOCBOOKITEMATTR },
+               { "docbookitemtag", IL_DOCBOOKITEMTAG },
+               { "docbookitemtagtype", IL_DOCBOOKITEMTAGTYPE },
+               { "docbookitemwrapperattr", IL_DOCBOOKITEMWRAPPERATTR },
+               { "docbookitemwrappertag", IL_DOCBOOKITEMWRAPPERTAG },
+               { "docbookitemwrappertagtype", IL_DOCBOOKITEMWRAPPERTAGTYPE },
                { "docbooksection", IL_DOCBOOKSECTION },
                { "docbooktag", IL_DOCBOOKTAG },
                { "docbooktagtype", IL_DOCBOOKTAGTYPE },
@@ -505,6 +517,24 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass,
                case IL_DOCBOOKSECTION:
                        lex >> docbooksection_;
                        break;
+               case IL_DOCBOOKITEMTAG:
+                       lex >> docbookitemtag_;
+                       break;
+               case IL_DOCBOOKITEMTAGTYPE:
+                       lex >> docbookitemtagtype_;
+                       break;
+               case IL_DOCBOOKITEMATTR:
+                       lex >> docbookitemattr_;
+                       break;
+               case IL_DOCBOOKITEMWRAPPERTAG:
+                       lex >> docbookitemwrappertag_;
+                       break;
+               case IL_DOCBOOKITEMWRAPPERTAGTYPE:
+                       lex >> docbookitemwrappertagtype_;
+                       break;
+               case IL_DOCBOOKITEMWRAPPERATTR:
+                       lex >> docbookitemwrapperattr_;
+                       break;
                case IL_DOCBOOKWRAPPERTAG:
                        lex >> docbookwrappertag_;
                        break;
@@ -654,6 +684,38 @@ std::string const & InsetLayout::docbookininfo() const
 }
 
 
+std::string InsetLayout::docbooktagtype() const
+{
+       if (docbooktagtype_ != "block" && docbooktagtype_ != "paragraph" && docbooktagtype_ != "inline")
+               docbooktagtype_ = "block";
+       return docbooktagtype_;
+}
+
+
+std::string InsetLayout::docbookwrappertagtype() const
+{
+       if (docbookwrappertagtype_ != "block" && docbookwrappertagtype_ != "paragraph" && docbookwrappertagtype_ != "inline")
+               docbookwrappertagtype_ = "block";
+       return docbookwrappertagtype_;
+}
+
+
+std::string InsetLayout::docbookitemtagtype() const
+{
+       if (docbookitemtagtype_ != "block" && docbookitemtagtype_ != "paragraph" && docbookitemtagtype_ != "inline")
+               docbookitemtagtype_ = "block";
+       return docbookitemtagtype_;
+}
+
+
+std::string InsetLayout::docbookitemwrappertagtype() const
+{
+       if (docbookitemwrappertagtype_ != "block" && docbookitemwrappertagtype_ != "paragraph" && docbookitemwrappertagtype_ != "inline")
+               docbookitemwrappertagtype_ = "block";
+       return docbookitemwrappertagtype_;
+}
+
+
 void InsetLayout::readArgument(Lexer & lex)
 {
        Layout::latexarg arg;
index 6f2f3ddfe02410a230f46c29be42c706ea40a5d9..09abe71e13d63c505e436a287153f816012d3c3a 100644 (file)
@@ -150,7 +150,7 @@ public:
        ///
        std::string docbooktag() const { return docbooktag_; }
        ///
-       std::string docbooktagtype() const { return docbooktagtype_; }
+       std::string docbooktagtype() const;
        ///
        std::string docbookattr() const { return docbookattr_; }
        ///
@@ -160,10 +160,22 @@ public:
        ///
        std::string docbookwrappertag() const { return docbookwrappertag_; }
        ///
-       std::string docbookwrappertagtype() const { return docbookwrappertagtype_; }
+       std::string docbookwrappertagtype() const;
        ///
        std::string docbookwrapperattr() const { return docbookwrapperattr_; }
        ///
+       std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
+       ///
+       std::string docbookitemwrappertagtype() const;
+       ///
+       std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
+       ///
+       std::string docbookitemtag() const { return docbookitemtag_; }
+       ///
+       std::string docbookitemtagtype() const;
+       ///
+       std::string docbookitemattr() const { return docbookitemattr_; }
+       ///
        std::set<std::string> required() const { return required_; }
        ///
        bool isMultiPar() const { return multipar_; }
@@ -293,7 +305,7 @@ private:
        ///
        std::string docbooktag_;
        ///
-       std::string docbooktagtype_;
+       mutable std::string docbooktagtype_;
        ///
        std::string docbookattr_;
        ///
@@ -303,10 +315,22 @@ private:
        ///
        std::string docbookwrappertag_;
        ///
-       std::string docbookwrappertagtype_;
+       mutable std::string docbookwrappertagtype_;
        ///
        std::string docbookwrapperattr_;
        ///
+       std::string docbookitemtag_;
+       ///
+       mutable std::string docbookitemtagtype_;
+       ///
+       std::string docbookitemattr_;
+       ///
+       std::string docbookitemwrappertag_;
+       ///
+       mutable std::string docbookitemwrappertagtype_;
+       ///
+       std::string docbookitemwrapperattr_;
+       ///
        std::set<std::string> required_;
        ///
        bool multipar_ = true;
index 99ddfeead286394bf6ce172ddc50e3a6802d7f3c..d33a43bcbea80a15fe135613a15fa06ee4cbf033 100644 (file)
@@ -635,6 +635,12 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op
                                attrs += from_ascii(" xlink:href=\"") + text_.asString() + from_ascii("\"");
                        xs << xml::StartTag(il.docbooktag(), attrs);
                }
+
+               if (!il.docbookitemwrappertag().empty() && il.docbookitemwrappertag() != "NONE" && il.docbookitemwrappertag() != "IGNORE")
+                       xs << xml::StartTag(il.docbookitemwrappertag(), il.docbookitemwrapperattr());
+
+               if (!il.docbookitemtag().empty() && il.docbookitemtag() != "NONE" && il.docbookitemtag() != "IGNORE")
+                       xs << xml::StartTag(il.docbookitemtag(), il.docbookitemattr());
        }
 
        // No need for labels that are generated from counters. They should be handled by the external DocBook processor.
@@ -650,6 +656,12 @@ void InsetText::docbook(XMLStream & xs, OutputParams const & rp, XHTMLOptions op
        xs.endDivision();
 
        if (opts & WriteOuterTag) {
+               if (!il.docbookitemtag().empty() && il.docbookitemtag() != "NONE" && il.docbookitemtag() != "IGNORE")
+                       xs << xml::EndTag(il.docbookitemtag());
+
+               if (!il.docbookitemwrappertag().empty() && il.docbookitemwrappertag() != "NONE" && il.docbookitemwrappertag() != "IGNORE")
+                       xs << xml::EndTag(il.docbookitemwrappertag());
+
                if (!il.docbooktag().empty() && il.docbooktag() != "NONE" && il.docbooktag() != "IGNORE")
                        xs << xml::EndTag(il.docbooktag());