[LyX/master] DocBook: implement Mathematical Monthly.

Thibaut Cuvelier tcuvelier at lyx.org
Fri Nov 27 01:20:20 UTC 2020


commit 587f1f5571ca0ef26bdef8201491475c1e69c91e
Author: Thibaut Cuvelier <tcuvelier at lyx.org>
Date:   Fri Nov 27 01:54:00 2020 +0100

    DocBook: implement Mathematical Monthly.
---
 autotests/export/docbook/maam.lyx   |  174 +++++++++++++++++++++++++++++++++++
 autotests/export/docbook/maam.xml   |   27 ++++++
 development/autotests/invertedTests |    2 +
 lib/layouts/maa-monthly.layout      |   94 ++++++++++++-------
 src/output_docbook.cpp              |    3 +
 5 files changed, 264 insertions(+), 36 deletions(-)

diff --git a/autotests/export/docbook/maam.lyx b/autotests/export/docbook/maam.lyx
new file mode 100644
index 0000000..406a95c
--- /dev/null
+++ b/autotests/export/docbook/maam.lyx
@@ -0,0 +1,174 @@
+#LyX 2.4 created this file. For more info see https://www.lyx.org/
+\lyxformat 599
+\begin_document
+\begin_header
+\save_transient_properties true
+\origin unavailable
+\textclass maa-monthly
+\use_default_options true
+\maintain_unincluded_children no
+\language english
+\language_package default
+\inputencoding utf8
+\fontencoding auto
+\font_roman "default" "default"
+\font_sans "default" "default"
+\font_typewriter "default" "default"
+\font_math "auto" "auto"
+\font_default_family default
+\use_non_tex_fonts false
+\font_sc false
+\font_roman_osf false
+\font_sans_osf false
+\font_typewriter_osf false
+\font_sf_scale 100 100
+\font_tt_scale 100 100
+\use_microtype false
+\use_dash_ligatures false
+\graphics default
+\default_output_format default
+\output_sync 0
+\bibtex_command default
+\index_command default
+\paperfontsize default
+\spacing single
+\use_hyperref false
+\papersize default
+\use_geometry true
+\use_package amsmath 1
+\use_package amssymb 1
+\use_package cancel 2
+\use_package esint 1
+\use_package mathdots 1
+\use_package mathtools 0
+\use_package mhchem 1
+\use_package stackrel 0
+\use_package stmaryrd 0
+\use_package undertilde 0
+\cite_engine basic
+\cite_engine_type default
+\biblio_style plain
+\use_bibtopic false
+\use_indices false
+\paperorientation portrait
+\suppress_date false
+\justification true
+\use_refstyle 1
+\use_minted 0
+\use_lineno 0
+\index Index
+\shortcut idx
+\color #008000
+\end_index
+\secnumdepth 3
+\tocdepth 3
+\paragraph_separation indent
+\paragraph_indentation default
+\is_math_indent 0
+\math_numbering_side default
+\quotes_style english
+\dynamic_quotes 0
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tablestyle default
+\tracking_changes false
+\output_changes false
+\change_bars false
+\postpone_fragile_content false
+\html_math_output 0
+\html_css_as_file 0
+\html_be_strict false
+\docbook_table_output 0
+\end_header
+
+\begin_body
+
+\begin_layout Title
+Sample Article Title
+\end_layout
+
+\begin_layout Author
+Woodrow Wilson and Herbert Hoover
+\end_layout
+
+\begin_layout Abstract
+An abstract should not contain concrete mathematics.
+\end_layout
+
+\begin_layout Section
+First-level section heading.
+\end_layout
+
+\begin_layout Standard
+Section heading.
+\end_layout
+
+\begin_layout Standard
+\begin_inset Separator plain
+\end_inset
+
+
+\end_layout
+
+\begin_layout Biographies
+
+\end_layout
+
+\begin_deeper
+\begin_layout Author Biography
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+Woodrow Wilson
+\end_layout
+
+\end_inset
+
+received his Ph.D.
+ in history and political science from Johns Hopkins University.
+ He held visiting positions at Cornell and Wesleyan before joining the faculty
+ at Princeton, where he was eventually appointed president of the university.
+ Among his proudest accomplishments was the abolition of eating clubs at
+ Princeton on the grounds that they were elitist.
+\end_layout
+
+\begin_layout Affiliation
+Office of the President, Princeton University, Princeton NJ 08544
+\begin_inset Newline newline
+\end_inset
+
+twoodwilson at princeton.edu
+\end_layout
+
+\begin_layout Author Biography
+\begin_inset Argument 1
+status open
+
+\begin_layout Plain Layout
+Herbert Hoover
+\end_layout
+
+\end_inset
+
+entered Stanford University in 1891, after failing all of the entrance exams
+ except mathematics.
+ He received his B.S.
+ degree in geology in 1895, spent time as a mining engineer, then was appointed
+ by his co-author to the U.S.
+ Food Administration and the Supreme Economic Council, where he orchestrated
+ the greatest famine relief efforts of all time.
+\end_layout
+
+\begin_layout Affiliation
+Hoover Institution, Stanford University, Stanford CA 94305
+\begin_inset Newline newline
+\end_inset
+
+herbhoover at stanford.edu
+\end_layout
+
+\end_deeper
+\end_body
+\end_document
diff --git a/autotests/export/docbook/maam.xml b/autotests/export/docbook/maam.xml
new file mode 100644
index 0000000..0fbe638
--- /dev/null
+++ b/autotests/export/docbook/maam.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This DocBook file was created by LyX 2.4.0dev
+  See http://www.lyx.org/ for more information -->
+<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>Sample Article Title</title>
+<author>
+<personname>Woodrow Wilson and Herbert Hoover</personname>
+</author>
+<abstract>
+<para>An abstract should not contain concrete mathematics.</para>
+</abstract>
+</info>
+<section>
+<title>First-level section heading.</title>
+<para>Section heading.</para>
+</section>
+<section>
+<title></title>
+<para><emphasis role='name'>Woodrow Wilson</emphasis>
+received his Ph.D. in history and political science from Johns Hopkins University. He held visiting positions at Cornell and Wesleyan before joining the faculty at Princeton, where he was eventually appointed president of the university. Among his proudest accomplishments was the abolition of eating clubs at Princeton on the grounds that they were elitist.</para>
+<para role='affiliation'>Office of the President, Princeton University, Princeton NJ 08544twoodwilson at princeton.edu</para>
+<para><emphasis role='name'>Herbert Hoover</emphasis>
+entered Stanford University in 1891, after failing all of the entrance exams except mathematics. He received his B.S. degree in geology in 1895, spent time as a mining engineer, then was appointed by his co-author to the U.S. Food Administration and the Supreme Economic Council, where he orchestrated the greatest famine relief efforts of all time.</para>
+<para role='affiliation'>Hoover Institution, Stanford University, Stanford CA 94305herbhoover at stanford.edu</para>
+</section>
+</article>
\ No newline at end of file
diff --git a/development/autotests/invertedTests b/development/autotests/invertedTests
index d494973..36682ea 100644
--- a/development/autotests/invertedTests
+++ b/development/autotests/invertedTests
@@ -508,6 +508,8 @@ export/templates/Articles/REVTeX_%28V._4.1%29_docbook5
 export/templates/Articles/Kluwer_docbook5
 # - Empty bibliography, broken references, empty figures.
 export/templates/Articles/Journal_of_the_Acoustical_Society_of_America_%28JASA%29_docbook5
+# - Biographies after bibliography: DocBook does not allow content after a bibliography.
+export/templates/Articles/Mathematical_Monthly_docbook5
 
 Sublabel: docbook poster
 # Posters cannot be properly exported, the LyX documents are too far from
diff --git a/lib/layouts/maa-monthly.layout b/lib/layouts/maa-monthly.layout
index 3caa4f6..452c181 100644
--- a/lib/layouts/maa-monthly.layout
+++ b/lib/layouts/maa-monthly.layout
@@ -33,16 +33,18 @@ End
 
 Style Abstract
   Font
-    Size Normal
+    Size     Normal
   EndFont
-  LabelType Static
+  LabelType  Static
   LabelFont
-    Size Normal
-    Series Bold
+    Size     Normal
+    Series   Bold
   EndFont
-  LabelString "Abstract:"
-  LabelSep " "
-  Margin Dynamic
+  LabelString      "Abstract:"
+  LabelSep         " "
+  Margin           Dynamic
+  DocBookTag       para
+  DocBookAbstract  true
 End
 
 Style Standard
@@ -55,6 +57,7 @@ Style Standard
 	Align                 Block
 	AlignPossible         Block Center
 	LabelType             No_Label
+	DocBookTag            para
 End
 
 Style Author
@@ -62,48 +65,60 @@ Style Author
 End
 
 Style Abbreviated_Title
-  CopyStyle Title
-  LatexType command
-  LatexName markright
+  CopyStyle   Title
+  LatexType   command
+  LatexName   markright
   Font
-    Size  Large
+    Size      Large
   EndFont
-  Align Center
+  Align       Center
+  DocBookTag  titleabbrev
 End
 
 Style Biographies
   Align Left
-  Category BackMatter
+  Category    BackMatter
   LabelString "Biographies"
-  LabelType Centered
+  LabelType   Centered
   LabelFont
-    Color Blue
-    Shape Italic
+    Color  Blue
+    Shape  Italic
     Family Roman
   EndFont
   LatexType Environment
   LatexName biog
   KeepEmpty 1
+  # Cannot work properly, as toclevel is set to NOT_IN_TOC.
+  DocBookSection     true
+  # DocBookSectionTag  section
+  DocBookTag         title
+  DocBookTagType     paragraph
+  DocBookWrapperTag  section
 End
 
 Style Author_Biography
-  Align Left
+  Align    Left
   Category BackMatter
   Argument 1
     LabelString "Name"
-    Mandatory 0
+    Mandatory   0
+	DocBookTag  emphasis
+	DocBookAttr role='name'
   EndArgument
   LabelString "Author Biography"
-  LabelSep " "
-  LabelType Static
+  LabelSep    " "
+  LabelType   Static
   LabelFont
-    Color Blue
-    Shape Italic
+    Color  Blue
+    Shape  Italic
     Family Roman
   EndFont
-  LatexType Command
-  LatexName item
-  Margin Dynamic
+  LatexType  Command
+  LatexName  item
+  Margin     Dynamic
+  DocBookTag         para
+  DocBookWrapperTag  section
+  DocBookWrapperMergeWithPrevious  true
 End
 
 Style Affiliation
@@ -120,24 +135,31 @@ Style Affiliation
   LatexType Environment
   LatexName affil
   Margin Dynamic
+  DocBookTag         para
+  DocBookAttr        role='affiliation'
+  DocBookWrapperTag  section
+  DocBookWrapperMergeWithPrevious  true
 End
 
 Style Acknowledgments
-  Category  BackMatter
+  Category       BackMatter
   Argument 1
-    LabelString "Title of acknowledgment"
-    Mandatory 1
+    LabelString  "Title of acknowledgment"
+    Mandatory    1
   EndArgument
-  LabelString "Acknowledgments"
-  LabelType Static
-  LabelSep " "
+  LabelString    "Acknowledgments"
+  LabelType      Static
+  LabelSep       " "
   LabelFont
-    Series Bold
-    Size Large
+    Series       Bold
+    Size         Large
   EndFont
-  LatexName acknowledgment
-  LatexType   Environment
-  Margin Dynamic
+  LatexName      acknowledgment
+  LatexType      Environment
+  Margin         Dynamic
+  DocBookTag            para
+  DocBookWrapperTag     acknowledgements
+  DocBookSection        true
 End
 
 InsetLayout Flex:URL
diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp
index bcd04bc..0deed24 100644
--- a/src/output_docbook.cpp
+++ b/src/output_docbook.cpp
@@ -1108,6 +1108,9 @@ void docbookParagraphs(Text const &text,
 			// <h2> after a <h2>, <h3>, <h4>, <h5> or <h6>). More examples:
 			//   - current: h2; back: h1; do not close any <section>
 			//   - current: h1; back: h2; close two <section> (first the <h2>, then the <h1>, so a new <h1> can come)
+			// Some layouts require that Layout::NOT_IN_TOC sections still cause closing of previous sections. This is
+			// mostly to ensure that the section is positioned at a DocBook-compatible level (acknowledgements: cannot
+			// be under a section!).
 			while (!headerLevels.empty() && level <= headerLevels.top().first) {
 				// Output the tag only if it corresponds to a legit section.
 				int stackLevel = headerLevels.top().first;


More information about the lyx-cvs mailing list