commit f426e458c4b0167c32abf4198d676fcd072b14ca
Author: Thibaut Cuvelier <[email protected]>
Date: Wed Nov 18 04:34:58 2020 +0100
DocBook: InsetText supports items and wrappers.
---
autotests/export/docbook/svglo.lyx | 2 +-
autotests/export/docbook/svglo.xml | 8 ++--
lib/layouts/stdinsets.inc | 1 +
lib/layouts/svglobal3.layout | 36 ++++++++++++++-------
src/insets/InsetERT.cpp | 5 +++
src/insets/InsetLayout.cpp | 62 ++++++++++++++++++++++++++++++++++++
src/insets/InsetLayout.h | 32 ++++++++++++++++--
src/insets/InsetText.cpp | 12 +++++++
8 files changed, 137 insertions(+), 21 deletions(-)
diff --git a/autotests/export/docbook/svglo.lyx
b/autotests/export/docbook/svglo.lyx
index 397f144..8ffc7f9 100644
--- a/autotests/export/docbook/svglo.lyx
+++ b/autotests/export/docbook/svglo.lyx
@@ -208,7 +208,7 @@ more
\begin_layout Standard
Your text comes here.
- Separate text sections with
+
\end_layout
\end_body
diff --git a/autotests/export/docbook/svglo.xml
b/autotests/export/docbook/svglo.xml
index 9615ca9..47c242a 100644
--- a/autotests/export/docbook/svglo.xml
+++ b/autotests/export/docbook/svglo.xml
@@ -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
diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc
index 1147fa5..2a842ab 100644
--- a/lib/layouts/stdinsets.inc
+++ b/lib/layouts/stdinsets.inc
@@ -89,6 +89,7 @@ InsetLayout Foot
AddToToc footnote
IsTocCaption true
DocBookTag footnote
+ DocBookTagType inline
End
InsetLayout Foot:InTitle
diff --git a/lib/layouts/svglobal3.layout b/lib/layouts/svglobal3.layout
index 7a9083a..3e9503d 100644
--- a/lib/layouts/svglobal3.layout
+++ b/lib/layouts/svglobal3.layout
@@ -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
diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp
index 1af67e1..e86724d 100644
--- a/src/insets/InsetERT.cpp
+++ b/src/insets/InsetERT.cpp
@@ -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();
diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp
index dcb863c..62030d0 100644
--- a/src/insets/InsetLayout.cpp
+++ b/src/insets/InsetLayout.cpp
@@ -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;
diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h
index 6f2f3dd..09abe71 100644
--- a/src/insets/InsetLayout.h
+++ b/src/insets/InsetLayout.h
@@ -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;
diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp
index 99ddfee..d33a43b 100644
--- a/src/insets/InsetText.cpp
+++ b/src/insets/InsetText.cpp
@@ -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());
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs