[LyX/master] DocBook: implement Copernicus.

Thibaut Cuvelier tcuvelier at lyx.org
Sat Nov 28 03:28:01 UTC 2020


commit 633a617841f6a5fe1ca79ee28e555ec75985998e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Sat Nov 28 01:23:22 2020 +0100

    DocBook: implement Copernicus.
    
    Includes a fix when wrappers are used with empty paragraphs. The logic is probably wrong if two legit wrapped paragraphs have one empty paragraph in the middle. This is only for slightly convoluted cases... Wrapping decisions should rather be taken for a series of paragraphs at once, but it would be more complex to implement and would only solve very peculiar cases like these ones.
---
 development/autotests/invertedTests |    1 +
 lib/layouts/copernicus.layout       |   62 +++++++++++++++++++++++++++++++++++
 src/output_docbook.cpp              |    8 ++++
 3 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/development/autotests/invertedTests b/development/autotests/invertedTests
index 9e8ec54..3f8f72b 100644
--- a/development/autotests/invertedTests
+++ b/development/autotests/invertedTests
@@ -519,6 +519,7 @@ export/templates/Articles/Hebrew_Article_%28KOMA-Script%29_docbook5
 # - Empty figure. Broken references. Float notes not implemented (how to do it?).
 export/templates/Articles/American_Economic_Association_%28AEA%29_docbook5
 export/templates/Articles/American_Psychological_Association_%28APA%29,_v._7_docbook5
+# - No author name.
 
 Sublabel: docbook poster
 # Posters cannot be properly exported, the LyX documents are too far from
diff --git a/lib/layouts/copernicus.layout b/lib/layouts/copernicus.layout
index dd6e67c..8eff50b 100644
--- a/lib/layouts/copernicus.layout
+++ b/lib/layouts/copernicus.layout
@@ -93,6 +93,12 @@ Style Affil
 		LabelString     "Affiliation Mark"
 		ToolTip         "identify the author with the corresponding affiliation. 1, 2, 3, etc. should be inserted."
 	EndArgument
+	DocBookTag            address
+	DocBookTagType        block
+	DocBookWrapperTag     author
+	DocBookWrapperTagType inline
+	DocBookWrapperMergeWithPrevious  true
+	DocBookInInfo         always
 End
 
 Style Running_Title
@@ -101,6 +107,9 @@ Style Running_Title
 	CopyStyle       InFrontmatter
 	LatexName       runningtitle
 	LabelString     "Running title:"
+	DocBookTag            titleabbrev
+	DocBookTagType        paragraph
+	DocBookInInfo         maybe
 End
 
 Style FirstPage
@@ -114,6 +123,8 @@ Style FirstPage
 		Shape           Italic
 		Color           Red
 	EndFont
+	DocBookTag            IGNORE
+	DocBookInInfo         maybe
 End
 
 Style RunningAuthor
@@ -122,6 +133,9 @@ Style RunningAuthor
 	CopyStyle       InFrontmatter
 	LatexName       runningauthor
 	LabelString     "Running author:"
+	DocBookTag            authorinitials
+	DocBookTagType        paragraph
+	DocBookInInfo         maybe
 End
 
 Style Publications
@@ -151,6 +165,9 @@ Style Correspondence
 	CopyStyle       Publications
 	LatexName       correspondence
 	LabelString     "Correspondence:"
+	DocBookTag      address
+	DocBookAttr     role='correspondence'
+	DocBookInInfo   always
 End
 
 Style Received
@@ -159,6 +176,9 @@ Style Received
 	CopyStyle       Publications
 	LatexName       received
 	LabelString     "Received:"
+	DocBookTag      date
+	DocBookAttr     role='received'
+	DocBookInInfo   always
 End
 
 Style Accepted
@@ -167,6 +187,9 @@ Style Accepted
 	CopyStyle       Publications
 	LatexName       accepted
 	LabelString     "Accepted:"
+	DocBookTag      date
+	DocBookAttr     role='accepted'
+	DocBookInInfo   always
 End
 
 Style Pubdiscuss
@@ -176,6 +199,9 @@ Style Pubdiscuss
 	CopyStyle       Publications
 	LatexName       pubdiscuss
 	LabelString     "Pubdiscuss:"
+	DocBookTag      date
+	DocBookAttr     role='pubdiscuss'
+	DocBookInInfo   always
 End
 
 Style Revised
@@ -185,6 +211,9 @@ Style Revised
 	CopyStyle       Publications
 	LatexName       revised
 	LabelString     "Revised:"
+	DocBookTag      date
+	DocBookAttr     role='revised'
+	DocBookInInfo   always
 End
 
 Style Published
@@ -194,6 +223,9 @@ Style Published
 	CopyStyle       Publications
 	LatexName       published
 	LabelString     "Published:"
+	DocBookTag      date
+	DocBookAttr     role='published'
+	DocBookInInfo   always
 End
 
 Style Abstract
@@ -224,12 +256,19 @@ Style Statements
 	LatexType       Command
 	Margin          Dynamic
 	KeepEmpty       0
+	DocBookTag      para
+	DocBookAttr     role='statements'
 End
 
 Style Copyrightstatement
 	CopyStyle       Statements
 	LatexName       copyrightstatement
 	LabelString     "Copyright:"
+	DocBookTag            para
+	DocBookWrapperTag     legalnotice
+	DocBookWrapperTagType block
+	DocBookWrapperMergeWithPrevious  true
+	DocBookInInfo         maybe
 End
 
 Style Introduction
@@ -238,6 +277,8 @@ Style Introduction
 	LabelString     "\thesection Introduction"
 	KeepEmpty       1
 	LabelSep        ""
+	DocBookSection  true
+	DocBookSectionTag  section
 End
 
 Style Conclusions
@@ -246,6 +287,8 @@ Style Conclusions
 	LabelString     "\thesection Conclusions"
 	KeepEmpty       1
 	LabelSep        ""
+	DocBookSection  true
+	DocBookSectionTag  section
 End
 
 Counter appendix
@@ -308,24 +351,32 @@ Style CodeAvailability
 	CopyStyle       Statements
 	LabelString     "Code availability."
 	LatexName       codeavailability
+	DocBookTag      para
+	DocBookAttr     role='codeavailability'
 End
 
 Style DataAvailability
 	CopyStyle       Statements
 	LabelString     "Data availability."
 	LatexName       dataavailability
+	DocBookTag      para
+	DocBookAttr     role='dataavailability'
 End
 
 Style CodeAndDataAvailability
 	CopyStyle       Statements
 	LabelString     "Code and data availability."
 	LatexName       codedataavailability
+	DocBookTag      para
+	DocBookAttr     role='codedataavailability'
 End
 
 Style SampleAvailability
 	CopyStyle       Statements
 	LabelString     "Sample availability."
 	LatexName       sampleavailability
+	DocBookTag      para
+	DocBookAttr     role='sampleavailability'
 End
 
 Style Statements2
@@ -334,30 +385,41 @@ Style Statements2
 	TopSep          1.3
 	BottomSep       0.7
 	ParSep          0.7
+	DocBookTag      para
+	DocBookAttr     role='statements'
 End
 
 Style AuthorContribution
 	CopyStyle       Statements2
 	LabelString     "Author contributions."
 	LatexName       authorcontribution
+	DocBookTag      para
+	DocBookAttr     role='authorcontribution'
 End
 
 Style CompetingInterests
 	CopyStyle       Statements2
 	LatexName       competinginterests
 	LabelString     "Competing Interests."
+	DocBookTag      para
+	DocBookAttr     role='competinginterests'
 End
 
 Style Disclaimer
 	CopyStyle       Statements2
 	LatexName       disclaimer
 	LabelString     "Disclaimer."
+	DocBookTag      para
+	DocBookAttr     role='disclaimer'
 End
 
 Style Acknowledgements
 	CopyStyle       Statements2
 	LatexName       acknowledgements
 	LabelString     "Acknowledgements."
+	DocBookTag            para
+	DocBookWrapperTag     acknowledgements
+	DocBookSection        true
 End
 
 Style Bibliography
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index 96e83b2..ec11481 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -175,6 +175,10 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
 	if (par == prevpar)
 		prevpar = nullptr;
 
+	// If the previous paragraph is empty, don't consider it when opening wrappers.
+	if (prevpar && prevpar->empty() && !prevpar->allowEmpty())
+		prevpar = nullptr;
+
 	// When should the wrapper be opened here? Only if the previous paragraph has the SAME wrapper tag
 	// (usually, they won't have the same layout) and the CURRENT one allows merging.
 	// The main use case is author information in several paragraphs: if the name of the author is the
@@ -221,6 +225,10 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa
 	if (par == nextpar)
 		nextpar = nullptr;
 
+	// If the next paragraph is empty, don't consider it when closing wrappers.
+	if (nextpar && nextpar->empty() && !nextpar->allowEmpty())
+		nextpar = nullptr;
+
 	// See comment in openParTag.
 	Layout const & lay = par->layout();
 	bool closeWrapper = lay.docbookwrappertag() != "NONE" && !runparams.docbook_ignore_wrapper;


More information about the lyx-cvs mailing list