From a852706bf07d9ee265754c639560a4346de623d8 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 16:52:33 +0200 Subject: [PATCH 01/88] DocBook: allow empty paragraphs before the section. --- .../docbook/bibliography_precooked_aastex.xml | 17 ++++++++++++++ src/output_docbook.cpp | 23 +++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index 89b1714bfe..37dada807b 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -3,6 +3,23 @@ See http://www.lyx.org/ for more information -->
+Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples +S. Djorgovski and Ivan R. King +Astronomy Department, University of California, Berkeley, CA 94720 +Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. +Society of Fellows, Harvard University. +present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 +C. D. Biemesderfer +National Optical Astronomy Observatories, Tucson, AZ 85719 +Visiting Programmer, Space Telescope Science Institute +Patron, Alonso's Bar and Grill +aastex-help@aas.org +R. J. Hanisch +Space Telescope Science Institute, Baltimore, MD 21218 +Patron, Alonso's Bar and Grill + +This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. +
Introduction diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 5e15edcee9..2199239f89 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -764,15 +764,34 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, } -DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type const bpit, pit_type const epit) { +bool hasOnlyNotes(Paragraph const & par) +{ + for (int i = 0; i < par.size(); ++i) + if (!par.isInset(i) || !dynamic_cast(par.insetList().get(i))) + return false; + return true; +} + + +DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type bpit, pit_type const epit) { set shouldBeInInfo; set mustBeInInfo; + // Find the first non empty paragraph by mutating bpit. + while (bpit < epit) { + Paragraph const &par = paragraphs[bpit]; + if (par.empty() || hasOnlyNotes(par)) + bpit += 1; + else + break; + } + + // Find the last info-like paragraph. pit_type cpit = bpit; while (cpit < epit) { // Skip paragraphs only containing one note. Paragraph const &par = paragraphs[cpit]; - if (par.size() == 1 && dynamic_cast(paragraphs[cpit].insetList().get(0))) { + if (hasOnlyNotes(par)) { cpit += 1; continue; } From ad18c194920fe8ed8f339ee5fc755e8f3473db51 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 17:07:38 +0200 Subject: [PATCH 02/88] DocBook: add new layout parameter DocBookWrapperMergeWithPrevious. --- lib/scripts/layout2layout.py | 5 ++++- src/Layout.cpp | 8 ++++++++ src/Layout.h | 4 ++++ src/TextClass.cpp | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 60d4593482..e69deba624 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -11,7 +11,7 @@ # This script will update a .layout file to current format # The latest layout format is also defined in src/TextClass.cpp -currentFormat = 82 +currentFormat = 83 # Incremented to format 4, 6 April 2007, lasgouttes @@ -281,6 +281,9 @@ currentFormat = 82 # - Removed tag Header from ClassOptionsClassOptions # - Removed tag Element for flex insets +# Incremented to format 83, 2 August 2020 by dourouc05 +# New tag DocBookWrapperMergeWithPrevious + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). diff --git a/src/Layout.cpp b/src/Layout.cpp index c45fd5c101..a7e80ea3f3 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -109,6 +109,7 @@ enum LayoutTags { LT_DOCBOOKININFO, LT_DOCBOOKWRAPPERTAG, LT_DOCBOOKWRAPPERATTR, + LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS, LT_DOCBOOKSECTIONTAG, LT_DOCBOOKITEMWRAPPERTAG, LT_DOCBOOKITEMWRAPPERATTR, @@ -176,6 +177,7 @@ Layout::Layout() htmllabelfirst_ = false; htmlforcecss_ = false; htmltitle_ = false; + docbookwrappermergewithprevious_ = false; spellcheck = true; forcelocal = 0; itemcommand_ = "item"; @@ -234,6 +236,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "docbooktag", LT_DOCBOOKTAG }, { "docbookwrapperattr", LT_DOCBOOKWRAPPERATTR }, { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG }, + { "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS }, { "end", LT_END }, { "endlabelstring", LT_ENDLABELSTRING }, { "endlabeltype", LT_ENDLABELTYPE }, @@ -743,6 +746,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookwrapperattr_; break; + case LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS: + lex >> docbookwrappermergewithprevious_; + break; + case LT_DOCBOOKSECTIONTAG: lex >> docbooksectiontag_; break; @@ -1610,6 +1617,7 @@ void Layout::write(ostream & os) const os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << '\n'; if(!docbookitemwrapperattr_.empty()) os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n'; + os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n'; if(!docbookitemlabeltag_.empty()) os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n'; if(!docbookitemlabelattr_.empty()) diff --git a/src/Layout.h b/src/Layout.h index 7e9409ad44..d9eb893c2e 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -203,6 +203,8 @@ public: /// std::string const & docbookwrapperattr() const; /// + bool docbookwrappermergewithprevious() const { return docbookwrappermergewithprevious_; } + /// std::string const & docbooksectiontag() const; /// std::string const & docbookitemwrappertag() const; @@ -512,6 +514,8 @@ private: mutable std::string docbookwrappertag_; /// Roles to add to docbookwrappertag_, if any (default: none). mutable std::string docbookwrapperattr_; + /// Whether this wrapper tag may be merged with the previously opened wrapper tag. + bool docbookwrappermergewithprevious_; /// Outer tag for this section, only if this layout represent a sectionning item, including chapters (default: section). mutable std::string docbooksectiontag_; /// Whether this tag must/can/can't go into an tag (default: never, as it only makes sense for metadata). diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 4cc5eba0ed..469cfafff4 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -62,7 +62,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // to update the format of all of our layout files. // -int const LAYOUT_FORMAT = 82; // dourouc05: DocBook additions. +int const LAYOUT_FORMAT = 83; // tcuvelier: DocBookWrapperMergeWithPrevious. // Layout format for the current lyx file format. Controls which format is From 4d78fe59577ab1f0aee03b4fe38bb76cdfec41be Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 17:17:25 +0200 Subject: [PATCH 03/88] Slight code-consistency improvements. --- src/output_docbook.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 2199239f89..5b788f3278 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -189,7 +189,7 @@ namespace { // convenience functions -void openParTag(XMLStream &xs, Layout const &lay) +void openParTag(XMLStream & xs, Layout const & lay) { if (lay.docbookwrappertag() != "NONE") { xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); @@ -203,7 +203,7 @@ void openParTag(XMLStream &xs, Layout const &lay) } -void closeTag(XMLStream &xs, Layout const &lay) +void closeTag(XMLStream & xs, Layout const & lay) { string tag = lay.docbooktag(); if (tag == "Plain Layout") @@ -228,14 +228,14 @@ void closeLabelTag(XMLStream & xs, Layout const & lay) } -void openItemTag(XMLStream &xs, Layout const &lay) +void openItemTag(XMLStream & xs, Layout const & lay) { xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); } // Return true when new elements are output in a paragraph, false otherwise. -bool openInnerItemTag(XMLStream &xs, Layout const &lay) +bool openInnerItemTag(XMLStream & xs, Layout const & lay) { if (lay.docbookiteminnertag() != "NONE") { xs << xml::CR(); @@ -249,7 +249,7 @@ bool openInnerItemTag(XMLStream &xs, Layout const &lay) } -void closeInnerItemTag(XMLStream &xs, Layout const &lay) +void closeInnerItemTag(XMLStream & xs, Layout const & lay) { if (lay.docbookiteminnertag()!= "NONE") { xs << xml::EndTag(lay.docbookiteminnertag()); @@ -258,7 +258,7 @@ void closeInnerItemTag(XMLStream &xs, Layout const &lay) } -inline void closeItemTag(XMLStream &xs, Layout const &lay) +inline void closeItemTag(XMLStream & xs, Layout const & lay) { xs << xml::EndTag(lay.docbookitemtag()); xs << xml::CR(); From 1a09086ec2a1e83e29437f8ba7d4115ce60eac10 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 17:23:37 +0200 Subject: [PATCH 04/88] Merge findLastParagraph and findLastBibliographyParagraph to lower code duplication. Maybe these functions should move to ParagraphList.h/cpp? --- src/output_docbook.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 5b788f3278..434148bc86 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -266,10 +266,11 @@ inline void closeItemTag(XMLStream & xs, Layout const & lay) // end of convenience functions -ParagraphList::const_iterator findLastParagraph( +ParagraphList::const_iterator findLast( ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend) { - for (++p; p != pend && p->layout().latextype == LATEX_PARAGRAPH; ++p); + ParagraphList::const_iterator const & pend, + LatexType type) { + for (++p; p != pend && p->layout().latextype == type; ++p); return p; } @@ -644,11 +645,11 @@ ParagraphList::const_iterator makeEnvironment( break; } case LATEX_PARAGRAPH: - send = findLastParagraph(par, pend); + send = findLast(par, pend, LATEX_PARAGRAPH); par = makeParagraphs(buf, xs, runparams, text, par, send); break; case LATEX_BIB_ENVIRONMENT: - send = findLastBibliographyParagraph(par, pend); + send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); par = makeParagraphBibliography(buf, xs, runparams, text, par, send); break; case LATEX_COMMAND: @@ -718,22 +719,19 @@ pair makeAny( } case LATEX_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: - case LATEX_ITEM_ENVIRONMENT: { + case LATEX_ITEM_ENVIRONMENT: // FIXME Same fix here. send = findEndOfEnvironment(par, pend); par = makeEnvironment(buf, xs, ourparams, text, par, send); break; - } - case LATEX_BIB_ENVIRONMENT: { - send = findLastBibliographyParagraph(par, pend); - par = makeParagraphBibliography(buf, xs, ourparams, text, par, send); - break; - } - case LATEX_PARAGRAPH: { - send = findLastParagraph(par, pend); + case LATEX_PARAGRAPH: + send = findLast(par, pend, LATEX_PARAGRAPH); par = makeParagraphs(buf, xs, ourparams, text, par, send); break; - } + case LATEX_BIB_ENVIRONMENT: + send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); + par = makeParagraphBibliography(buf, xs, ourparams, text, par, send); + break; } return make_pair(par, send); From c417253d0b07ba8d908a88351301fd6748977aee Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 17:28:50 +0200 Subject: [PATCH 05/88] DocBook: use DocBookItemTag within paragraphs. This is at least helpful for AAS, even though it slightly resembles a repurposition of that parameter. --- .../docbook/bibliography_precooked_aastex.xml | 22 +++++++++---------- lib/layouts/aastex.layout | 15 +++++++++++++ src/output_docbook.cpp | 9 ++++++-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index 37dada807b..b6638686ac 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -5,21 +5,21 @@ Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples S. Djorgovski and Ivan R. King -Astronomy Department, University of California, Berkeley, CA 94720 -Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. -Society of Fellows, Harvard University. -present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 +Astronomy Department, University of California, Berkeley, CA 94720 +Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. +Society of Fellows, Harvard University. +present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 C. D. Biemesderfer -National Optical Astronomy Observatories, Tucson, AZ 85719 -Visiting Programmer, Space Telescope Science Institute -Patron, Alonso's Bar and Grill +National Optical Astronomy Observatories, Tucson, AZ 85719 +Visiting Programmer, Space Telescope Science Institute +Patron, Alonso's Bar and Grill aastex-help@aas.org R. J. Hanisch -Space Telescope Science Institute, Baltimore, MD 21218 -Patron, Alonso's Bar and Grill - +Space Telescope Science Institute, Baltimore, MD 21218 +Patron, Alonso's Bar and Grill + This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. - +
Introduction diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 275018a83c..5db7deea01 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -155,6 +155,9 @@ Style Author Series Medium Shape SmallCaps EndFont + DocBookTag personname + DocBookWrapperTag author + DocBookInInfo always End @@ -172,6 +175,10 @@ Style Affiliation Family Roman Size Normal EndFont + DocBookTag affiliation + DocBookWrapperTag author + DocBookItemTag orgname + DocBookInInfo always End @@ -194,6 +201,11 @@ Style Altaffilation LabelFont Color green EndFont + DocBookTag affiliation + DocBookAttr role="alternate" + DocBookItemTag orgname + DocBookWrapperTag author + DocBookInInfo always End @@ -213,6 +225,9 @@ Style Email Size Normal Shape Italic EndFont + DocBookTag email + DocBookWrapperTag author + DocBookInInfo always End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 434148bc86..2e7b637969 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -191,20 +191,25 @@ namespace { void openParTag(XMLStream & xs, Layout const & lay) { - if (lay.docbookwrappertag() != "NONE") { + if (lay.docbookwrappertag() != "NONE") xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); - } string tag = lay.docbooktag(); if (tag == "Plain Layout") tag = "para"; xs << xml::ParTag(tag, lay.docbookattr()); + + if (lay.docbookitemtag() != "NONE") + xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); } void closeTag(XMLStream & xs, Layout const & lay) { + if (lay.docbookitemtag() != "NONE") + xs << xml::EndTag(lay.docbookitemtag()); + string tag = lay.docbooktag(); if (tag == "Plain Layout") tag = "para"; From 72c304a6297311086d8fe1a17622f7b79623d3bd Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 17:35:16 +0200 Subject: [PATCH 06/88] DocBook: make openParTag/closeTag use paragraphs instead of layouts. Not useful per se, but will be next with checking whether the wrapper tags should be opened/closed. --- src/output_docbook.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 2e7b637969..a081b2db79 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -189,8 +189,10 @@ namespace { // convenience functions -void openParTag(XMLStream & xs, Layout const & lay) +void openParTag(XMLStream & xs, Paragraph const & par) { + Layout const & lay = par.layout(); + if (lay.docbookwrappertag() != "NONE") xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); @@ -205,8 +207,10 @@ void openParTag(XMLStream & xs, Layout const & lay) } -void closeTag(XMLStream & xs, Layout const & lay) +void closeTag(XMLStream & xs, Paragraph const & par) { + Layout const & lay = par.layout(); + if (lay.docbookitemtag() != "NONE") xs << xml::EndTag(lay.docbookitemtag()); @@ -294,8 +298,8 @@ ParagraphList::const_iterator findEndOfEnvironment( ParagraphList::const_iterator const & pend) { ParagraphList::const_iterator p = pstart; - Layout const &bstyle = p->layout(); size_t const depth = p->params().depth(); + for (++p; p != pend; ++p) { Layout const &style = p->layout(); // It shouldn't happen that e.g. a section command occurs inside @@ -315,9 +319,10 @@ ParagraphList::const_iterator findEndOfEnvironment( // FIXME I am not sure about the first check. // Surely we *could* have different layouts that count as // LATEX_PARAGRAPH, right? - if (style.latextype == LATEX_PARAGRAPH || style != bstyle) + if (style.latextype == LATEX_PARAGRAPH || style != p->layout()) return p; } + return pend; } @@ -397,8 +402,6 @@ ParagraphList::const_iterator makeParagraphs( ParagraphList::const_iterator const begin = text.paragraphs().begin(); ParagraphList::const_iterator par = pbegin; for (; par != pend; ++par) { - Layout const &lay = par->layout(); - // We want to open the paragraph tag if: // (i) the current layout permits multiple paragraphs // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR @@ -428,7 +431,7 @@ ParagraphList::const_iterator makeParagraphs( } // Plain layouts must be ignored. - if (!special_case && buf.params().documentClass().isPlainLayout(lay) && !runparams.docbook_force_pars) + if (!special_case && buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars) special_case = true; // TODO: Could get rid of this with a DocBook equivalent to htmlisblock? if (!special_case && par->size() == 1 && par->getInset(0)) { @@ -481,12 +484,12 @@ ParagraphList::const_iterator makeParagraphs( if (!cleaned.empty()) { if (open_par) - openParTag(xs, lay); + openParTag(xs, *par); xs << XMLStream::ESCAPE_NONE << os2.str(); if (close_par) { - closeTag(xs, lay); + closeTag(xs, *par); xs << xml::CR(); } } @@ -510,13 +513,12 @@ ParagraphList::const_iterator makeEnvironment( ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pend) { - ParagraphList::const_iterator const begin = text.paragraphs().begin(); + auto const begin = text.paragraphs().begin(); ParagraphList::const_iterator par = pbegin; - Layout const &bstyle = par->layout(); depth_type const origdepth = pbegin->params().depth(); // open tag for this environment - openParTag(xs, bstyle); + openParTag(xs, *par); xs << xml::CR(); // we will on occasion need to remember a layout from before. @@ -535,7 +537,7 @@ ParagraphList::const_iterator makeEnvironment( // One is that we are still in the environment in which we // started---which we will be if the depth is the same. if (par->params().depth() == origdepth) { - LATTEST(bstyle == style); + LATTEST(par->layout() == style); if (lastlay != nullptr) { closeItemTag(xs, *lastlay); if (lastlay->docbookitemwrappertag() != "NONE") { @@ -670,7 +672,7 @@ ParagraphList::const_iterator makeEnvironment( xs << xml::CR(); } } - closeTag(xs, bstyle); + closeTag(xs, *par); xs << xml::CR(); return pend; } @@ -683,16 +685,15 @@ void makeCommand( Text const & text, ParagraphList::const_iterator const & pbegin) { - Layout const &style = pbegin->layout(); - // No need for labels, as they are handled by DocBook tags. - openParTag(xs, style); + openParTag(xs, *pbegin); - ParagraphList::const_iterator const begin = text.paragraphs().begin(); + auto const begin = text.paragraphs().begin(); pbegin->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, pbegin))); - closeTag(xs, style); + + closeTag(xs, *pbegin); xs << xml::CR(); } From c92e0bc5e7b275e599caa50b40a3038ca27bff87 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 18:07:07 +0200 Subject: [PATCH 07/88] DocBook: fix for ordering. --- src/Layout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Layout.cpp b/src/Layout.cpp index a7e80ea3f3..eeb58d0452 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -235,8 +235,8 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "docbooksectiontag", LT_DOCBOOKSECTIONTAG }, { "docbooktag", LT_DOCBOOKTAG }, { "docbookwrapperattr", LT_DOCBOOKWRAPPERATTR }, - { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG }, { "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS }, + { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG }, { "end", LT_END }, { "endlabelstring", LT_ENDLABELSTRING }, { "endlabeltype", LT_ENDLABELTYPE }, From 0f145c3ef0828dc7e06ff839a3ececf66edf5be6 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 18:58:36 +0200 Subject: [PATCH 08/88] DocBook: use DocBookWrapperMergeWithPrevious in the code. --- .../docbook/bibliography_precooked_aastex.xml | 42 ++++--- lib/layouts/aastex.layout | 27 +++-- src/output_docbook.cpp | 103 +++++++++++++++--- 3 files changed, 124 insertions(+), 48 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index b6638686ac..2c9f5bd32a 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -4,23 +4,27 @@
Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples -S. Djorgovski and Ivan R. King -Astronomy Department, University of California, Berkeley, CA 94720 -Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. -Society of Fellows, Harvard University. -present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 -C. D. Biemesderfer -National Optical Astronomy Observatories, Tucson, AZ 85719 -Visiting Programmer, Space Telescope Science Institute -Patron, Alonso's Bar and Grill -aastex-help@aas.org -R. J. Hanisch -Space Telescope Science Institute, Baltimore, MD 21218 -Patron, Alonso's Bar and Grill +S. Djorgovski and Ivan R. King +Astronomy Department, University of California, Berkeley, CA 94720 +Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. +Society of Fellows, Harvard University. +present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 +C. D. Biemesderfer +National Optical Astronomy Observatories, Tucson, AZ 85719 +Visiting Programmer, Space Telescope Science Institute +Patron, Alonso's Bar and Grill +aastex-help@aas.org +R. J. Hanisch +Space Telescope Science Institute, Baltimore, MD 21218 +Patron, Alonso's Bar and Grill This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. - - + + + + + +
Introduction A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades , , , but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 , seemed a unique anomaly. Then suggested a central peak in NGC 6397, and a limited photographic survey of ours found three more cases, including NGC 6624, whose sharp center had often been remarked on . @@ -688,7 +692,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - + +
@@ -964,8 +969,9 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi of the electronically submitted abstracts for AAS meetings are error-free. -We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. -IRAF, AIPS, Astropy, ... +We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. +IRAF, AIPS, Astropy, ... + Aurière, M. 1982, , 109, 301 diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 5db7deea01..445d25f536 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -175,10 +175,11 @@ Style Affiliation Family Roman Size Normal EndFont - DocBookTag affiliation - DocBookWrapperTag author - DocBookItemTag orgname - DocBookInInfo always + DocBookTag affiliation + DocBookWrapperTag author + DocBookWrapperMergeWithPrevious true + DocBookItemTag orgname + DocBookInInfo always End @@ -201,11 +202,12 @@ Style Altaffilation LabelFont Color green EndFont - DocBookTag affiliation - DocBookAttr role="alternate" - DocBookItemTag orgname - DocBookWrapperTag author - DocBookInInfo always + DocBookTag affiliation + DocBookAttr role="alternate" + DocBookWrapperTag author + DocBookWrapperMergeWithPrevious true + DocBookItemTag orgname + DocBookInInfo always End @@ -225,9 +227,10 @@ Style Email Size Normal Shape Italic EndFont - DocBookTag email - DocBookWrapperTag author - DocBookInInfo always + DocBookTag email + DocBookWrapperTag author + DocBookWrapperMergeWithPrevious true + DocBookInInfo always End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index a081b2db79..d0536eee3a 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -189,11 +189,30 @@ namespace { // convenience functions -void openParTag(XMLStream & xs, Paragraph const & par) +void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) { - Layout const & lay = par.layout(); + Layout const & lay = par->layout(); - if (lay.docbookwrappertag() != "NONE") + if (par == prevpar) + 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 + // first paragraph of an author, then merging with the previous tag does not make sense. Say the + // next paragraph is the affiliation, then it should be output in the same tag (different + // layout, same wrapper tag). + bool openWrapper = lay.docbookwrappertag() != "NONE"; + if (prevpar != nullptr) { + Layout const & prevlay = prevpar->layout(); + if (prevlay.docbookwrappertag() != "NONE") { + openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag() + && !lay.docbookwrappermergewithprevious(); + } + } + + // Main logic. + if (openWrapper) xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); string tag = lay.docbooktag(); @@ -207,10 +226,24 @@ void openParTag(XMLStream & xs, Paragraph const & par) } -void closeTag(XMLStream & xs, Paragraph const & par) +void closeTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) { - Layout const & lay = par.layout(); + Layout const & lay = par->layout(); + if (par == nextpar) + nextpar = nullptr; + + // See comment in openParTag. + bool closeWrapper = lay.docbookwrappertag() != "NONE"; + if (nextpar != nullptr) { + Layout const & nextlay = nextpar->layout(); + if (nextlay.docbookwrappertag() != "NONE") { + closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() + && !nextlay.docbookwrappermergewithprevious(); + } + } + + // Main logic. if (lay.docbookitemtag() != "NONE") xs << xml::EndTag(lay.docbookitemtag()); @@ -219,7 +252,7 @@ void closeTag(XMLStream & xs, Paragraph const & par) tag = "para"; xs << xml::EndTag(tag); - if (lay.docbookwrappertag() != "NONE") + if (closeWrapper) xs << xml::EndTag(lay.docbookwrappertag()); } @@ -399,9 +432,12 @@ ParagraphList::const_iterator makeParagraphs( ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pend) { - ParagraphList::const_iterator const begin = text.paragraphs().begin(); + auto const begin = text.paragraphs().begin(); + auto const end = text.paragraphs().end(); ParagraphList::const_iterator par = pbegin; - for (; par != pend; ++par) { + ParagraphList::const_iterator prevpar = pbegin; + + for (; par != pend; prevpar = par, ++par) { // We want to open the paragraph tag if: // (i) the current layout permits multiple paragraphs // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR @@ -417,7 +453,7 @@ ParagraphList::const_iterator makeParagraphs( // because of branches, e.g., a branch that contains an entire new section. // We do not really want to wrap that whole thing in a
...
. bool special_case = false; - Inset const *specinset = par->size() == 1 ? par->getInset(0) : 0; + Inset const *specinset = par->size() == 1 ? par->getInset(0) : nullptr; if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter? Layout const &style = par->layout(); FontInfo const first_font = style.labeltype == LABEL_MANUAL ? @@ -466,7 +502,7 @@ ParagraphList::const_iterator makeParagraphs( // or we're not in the last paragraph, anyway. // (ii) We didn't open it and docbook_in_par is true, // but we are in the first par, and there is a next par. - ParagraphList::const_iterator nextpar = par; + auto nextpar = par; ++nextpar; bool const close_par = ((open_par && (!runparams.docbook_in_par || nextpar != pend)) @@ -484,12 +520,12 @@ ParagraphList::const_iterator makeParagraphs( if (!cleaned.empty()) { if (open_par) - openParTag(xs, *par); + openParTag(xs, &*par, &*prevpar); xs << XMLStream::ESCAPE_NONE << os2.str(); if (close_par) { - closeTag(xs, *par); + closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); xs << xml::CR(); } } @@ -514,11 +550,24 @@ ParagraphList::const_iterator makeEnvironment( ParagraphList::const_iterator const & pend) { auto const begin = text.paragraphs().begin(); + auto const end = text.paragraphs().end(); ParagraphList::const_iterator par = pbegin; depth_type const origdepth = pbegin->params().depth(); + // Find the previous paragraph. + auto prevpar = begin; + if (prevpar != par) { + auto prevpar_next = prevpar; + ++prevpar_next; + + while (prevpar_next != par) { + ++prevpar_next; + ++prevpar; + } + } + // open tag for this environment - openParTag(xs, *par); + openParTag(xs, &*par, &*prevpar); xs << xml::CR(); // we will on occasion need to remember a layout from before. @@ -672,7 +721,9 @@ ParagraphList::const_iterator makeEnvironment( xs << xml::CR(); } } - closeTag(xs, *par); + auto nextpar = par; + ++nextpar; + closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); xs << xml::CR(); return pend; } @@ -686,14 +737,30 @@ void makeCommand( ParagraphList::const_iterator const & pbegin) { // No need for labels, as they are handled by DocBook tags. - - openParTag(xs, *pbegin); - auto const begin = text.paragraphs().begin(); + auto const end = text.paragraphs().end(); + auto nextpar = pbegin; + ++nextpar; + + // Find the previous paragraph. + auto prevpar = begin; + if (prevpar != pbegin) { + auto prevpar_next = prevpar; + ++prevpar_next; + + while (prevpar_next != pbegin) { + ++prevpar_next; + ++prevpar; + } + } + + // Generate this command. + openParTag(xs, &*pbegin, &*prevpar); + pbegin->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, pbegin))); - closeTag(xs, *pbegin); + closeTag(xs, &*pbegin, (nextpar != end) ? &*nextpar : nullptr); xs << xml::CR(); } From 7b0f9d95248820bc70b820dd6b558de4a6713bae Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 2 Aug 2020 20:43:39 +0200 Subject: [PATCH 09/88] DocBook: simplify code to handle abstracts. --- .../docbook/bibliography_precooked_aastex.xml | 4 +- lib/layouts/aastex.layout | 6 + src/output_docbook.cpp | 126 +++++++++++------- 3 files changed, 84 insertions(+), 52 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index 2c9f5bd32a..e15bfddc51 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -19,8 +19,10 @@ Patron, Alonso's Bar and Grill
This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. - + + +clusters: globular, peanut—bosons: bozos diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 445d25f536..97c8b64940 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -282,6 +282,9 @@ Style Abstract Series Bold Size Normal EndFont + DocBookTag abstract + DocBookItemTag para + DocBookInInfo always End @@ -331,6 +334,9 @@ Style Keywords Shape Italic Size Normal EndFont + DocBookTag keyword + DocBookWrapperTag keywordset + DocBookInInfo always End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index d0536eee3a..fd38940064 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -50,7 +50,7 @@ namespace lyx { namespace { -std::string const fontToDocBookTag(xml::FontTypes type) +std::string fontToDocBookTag(xml::FontTypes type) { switch (type) { case xml::FontTypes::FT_EMPH: @@ -90,6 +90,7 @@ std::string const fontToDocBookTag(xml::FontTypes type) } } + string fontToRole(xml::FontTypes type) { // Specific fonts are achieved with roles. The only common ones are "" for basic emphasis, @@ -103,14 +104,13 @@ string fontToRole(xml::FontTypes type) return ""; case xml::FontTypes::FT_BOLD: return "bold"; - case xml::FontTypes::FT_NOUN: - return ""; // Outputs a - case xml::FontTypes::FT_TYPE: - return ""; // Outputs a + case xml::FontTypes::FT_NOUN: // Outputs a + case xml::FontTypes::FT_TYPE: // Outputs a + return ""; case xml::FontTypes::FT_UBAR: return "underline"; - // All other roles are non-standard for DocBook. + // All other roles are non-standard for DocBook. case xml::FontTypes::FT_WAVE: return "wave"; @@ -814,7 +814,21 @@ pair makeAny( using DocBookDocumentSectioning = tuple; -using DocBookInfoTag = tuple, set, pit_type, pit_type>; + + +struct DocBookInfoTag +{ + const set shouldBeInInfo; + const set mustBeInInfo; + const set abstract; + pit_type bpit; + pit_type epit; + + DocBookInfoTag(const set & shouldBeInInfo, const set & mustBeInInfo, + const set & abstract, pit_type bpit, pit_type epit) : + shouldBeInInfo(shouldBeInInfo), mustBeInInfo(mustBeInInfo), abstract(abstract), + bpit(bpit), epit(epit) {} +}; DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, pit_type bpit, pit_type const epit) { @@ -847,6 +861,7 @@ bool hasOnlyNotes(Paragraph const & par) DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type bpit, pit_type const epit) { set shouldBeInInfo; set mustBeInInfo; + set abstract; // Find the first non empty paragraph by mutating bpit. while (bpit < epit) { @@ -859,14 +874,18 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b // Find the last info-like paragraph. pit_type cpit = bpit; + bool hasAbstractLayout = false; while (cpit < epit) { // Skip paragraphs only containing one note. - Paragraph const &par = paragraphs[cpit]; + Paragraph const & par = paragraphs[cpit]; if (hasOnlyNotes(par)) { cpit += 1; continue; } + if (par.layout().name() == from_ascii("Abstract")) + hasAbstractLayout = true; + // Based on layout information, store this paragraph in one set: should be in , must be. Layout const &style = par.layout(); @@ -876,42 +895,55 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b shouldBeInInfo.emplace(cpit); } else { // Hypothesis: the parts should be grouped together near the beginning bpit. + // There may be notes in between, but nothing else. break; } cpit += 1; } // Now, cpit points to the last paragraph that has things that could go in . - // bpit is still the beginning of the part. + // bpit is the beginning of the part. - return make_tuple(shouldBeInInfo, mustBeInInfo, bpit, cpit); -} + // Go once again through the list of paragraphs to find the abstract. If there is an abstract + // layout, only consider it. Otherwise, an abstract is just a sequence of paragraphs with text. + if (hasAbstractLayout) { + pit_type pit = bpit; + while (pit < cpit) { // Don't overshoot the part. + if (paragraphs[pit].layout().name() == from_ascii("Abstract")) + abstract.emplace(pit); + pit++; + } + } else { + pit_type lastAbstract = epit + 1; // A nonsensical value. + docstring lastAbstractLayout; + pit_type pit = bpit; + while (pit < cpit) { // Don't overshoot the part. + const Paragraph & par = paragraphs.at(pit); + if (!par.insetList().empty()) { + for (const auto &i : par.insetList()) { + if (i.inset->getText(0) != nullptr) { + if (lastAbstract == epit + 1) { + // First paragraph that matches the heuristic definition of abstract. + lastAbstract = pit; + lastAbstractLayout = par.layout().name(); + } else if (pit > lastAbstract + 1 || par.layout().name() != lastAbstractLayout) { + // This is either too far from the last abstract paragraph or doesn't + // have the right layout name, BUT there has already been an abstract + // in this document: done with detecting the abstract. + goto done; // Easier to get out of two nested loops. + } -bool hasAbstractBetween(ParagraphList const ¶graphs, pit_type const bpitAbstract, pit_type const epitAbstract) -{ - // Hypothesis: the paragraphs between bpitAbstract and epitAbstract can be considered an abstract because they - // are just after a document or part title. - if (epitAbstract - bpitAbstract <= 0) - return false; - - // If there is something between these paragraphs, check if it's compatible with an abstract (i.e. some text). - pit_type bpit = bpitAbstract; - while (bpit < epitAbstract) { - const Paragraph &p = paragraphs.at(bpit); - - if (p.layout().name() == from_ascii("Abstract")) - return true; - - if (!p.insetList().empty()) { - for (const auto &i : p.insetList()) { - if (i.inset->getText(0) != nullptr) { - return true; + abstract.emplace(pit); + break; + } } } + pit++; } - bpit++; } - return false; + + done: + return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit); } @@ -947,26 +979,18 @@ void outputDocBookInfo( XMLStream & xs, OutputParams const & runparams, ParagraphList const & paragraphs, - DocBookInfoTag const & info, - pit_type bpitAbstract, - pit_type const epitAbstract) + DocBookInfoTag const & info) { - // Consider everything between bpitAbstract and epitAbstract (excluded) as paragraphs for the abstract. - // Use bpitAbstract >= epitAbstract to indicate there is no abstract. - - set shouldBeInInfo; - set mustBeInInfo; - pit_type bpitInfo; - pit_type epitInfo; - tie(shouldBeInInfo, mustBeInInfo, bpitInfo, epitInfo) = info; - // Perform an additional check on the abstract. Sometimes, there are many paragraphs that should go // into the abstract, but none generates actual content. Thus, first generate to a temporary stream, // then only create the tag if these paragraphs generate some content. // This check must be performed *before* a decision on whether or not to output is made. - bool hasAbstract = hasAbstractBetween(paragraphs, bpitAbstract, epitAbstract); + bool hasAbstract = !info.abstract.empty(); docstring abstract; if (hasAbstract) { + pit_type bpitAbstract = *std::min_element(info.abstract.begin(), info.abstract.end()); + pit_type epitAbstract = *std::max_element(info.abstract.begin(), info.abstract.end()); + odocstringstream os2; XMLStream xs2(os2); generateDocBookParagraphWithoutSectioning(text, buf, xs2, runparams, paragraphs, bpitAbstract, epitAbstract); @@ -983,7 +1007,7 @@ void outputDocBookInfo( } // The abstract must go in . - bool needInfo = !mustBeInInfo.empty() || hasAbstract; + bool needInfo = !info.mustBeInInfo.empty() || hasAbstract; // Start the tag if required. if (needInfo) { @@ -993,10 +1017,10 @@ void outputDocBookInfo( } // Output the elements that should go in . - generateDocBookParagraphWithoutSectioning(text, buf, xs, runparams, paragraphs, bpitInfo, epitInfo); + generateDocBookParagraphWithoutSectioning(text, buf, xs, runparams, paragraphs, info.bpit, info.epit); if (hasAbstract && !abstract.empty()) { // The second test is probably superfluous. - string tag = paragraphs[bpitAbstract].layout().docbookforceabstracttag(); + string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); if (tag == "NONE") tag = "abstract"; @@ -1029,7 +1053,7 @@ void docbookFirstParagraphs( ParagraphList const ¶graphs = text.paragraphs(); pit_type bpit = runparams.par_begin; DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit); - outputDocBookInfo(text, buf, xs, runparams, paragraphs, info, get<3>(info), epit); + outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); } @@ -1056,8 +1080,8 @@ void docbookSimpleAllParagraphs( pit_type bpit = runparams.par_begin; pit_type const epit = runparams.par_end; DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit); - outputDocBookInfo(text, buf, xs, runparams, paragraphs, info, 0, 0); - bpit = get<3>(info); // Generate the content starting from the end of the part. + outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); + bpit = info.bpit; // Then, the content. ParagraphList::const_iterator const pend = From dab71087cf2954b77d3d2c0e67b868f9be82fba9 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 3 Aug 2020 16:04:26 +0200 Subject: [PATCH 10/88] DocBook: add a layout tag to tell whether an item is the abstract or not. --- .../docbook/bibliography_precooked_aastex.xml | 221 +++++++-------- lib/layouts/aastex.layout | 3 - lib/layouts/stdstruct.inc | 3 +- lib/scripts/layout2layout.py | 2 +- src/Layout.cpp | 8 + src/Layout.h | 9 +- src/output_docbook.cpp | 267 ++++++++++-------- 7 files changed, 282 insertions(+), 231 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index e15bfddc51..fe77b72494 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -3,8 +3,8 @@ See http://www.lyx.org/ for more information -->
-Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples -S. Djorgovski and Ivan R. King +Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples +S. Djorgovski and Ivan R. King Astronomy Department, University of California, Berkeley, CA 94720 Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. Society of Fellows, Harvard University. @@ -17,16 +17,11 @@ R. J. Hanisch Space Telescope Science Institute, Baltimore, MD 21218 Patron, Alonso's Bar and Grill - -This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. - - - clusters: globular, peanut—bosons: bozos - - - - + +This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. + +
Introduction A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades , , , but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 , seemed a unique anomaly. Then suggested a central peak in NGC 6397, and a limited photographic survey of ours found three more cases, including NGC 6624, whose sharp center had often been remarked on . @@ -112,7 +107,7 @@
Helicity Amplitudes -It has been realized that helicity amplitudes provide a convenient means for Feynman diagramFootnotes can be inserted like this. +It has been realized that helicity amplitudes provide a convenient means for Feynman diagramFootnotes can be inserted like this. evaluations. These amplitude-level techniques are particularly convenient for calculations involving many Feynman diagrams, where the usual trace techniques for the amplitude squared becomes unwieldy. Our calculations use the helicity techniques developed by other authors ; we briefly summarize below.
Formalism @@ -694,8 +689,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - - +
@@ -957,7 +951,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi -, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of . Roughly +, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of . Roughly \nicefrac{4}{5} @@ -971,14 +965,13 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi of the electronically submitted abstracts for AAS meetings are error-free. -We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. +We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. IRAF, AIPS, Astropy, ... - Aurière, M. 1982, , 109, 301 Canizares, C. R., Grindlay, J. E., Hiltner, W. A., Liller, W., and McClintock, J. E. 1978, , 224, 39 -Djorgovski, S., and King, I. R. 1984, , 277, L49 +Djorgovski, S., and King, I. R. 1984, , 277, L49 Hagiwara, K., and Zeppenfeld, D. 1986, Nucl.Phys., 274, 1 Harris, W. E., and van den Bergh, S. 1984, , 89, 1816 Hénon, M. 1961, Ann.d'Ap., 24, 369 @@ -986,19 +979,19 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi King, I. R. 1975, Dynamics of Stellar Systems, A. Hayli, Dordrecht: Reidel, 1975, 99 King, I. R., Hedemann, E., Hodge, S. M., and White, R. E. 1968, , 73, 456 Kron, G. E., Hewitt, A. V., and Wasserman, L. H. 1984, , 96, 198 -Lynden-Bell, D., and Wood, R. 1968, , 138, 495 +Lynden-Bell, D., and Wood, R. 1968, , 138, 495 Newell, E. B., and O'Neil, E. J. 1978, , 37, 27 Ortolani, S., Rosino, L., and Sandage, A. 1985, , 90, 473 Peterson, C. J. 1976, , 81, 617 Spitzer, L. 1985, Dynamics of Star Clusters, J. Goodman and P. Hut, Dordrecht: Reidel, 109 - - + + - - - + + - - - - - - - + - - - +b + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + +
Terribly relevant tabular information.Terribly relevant tabular information.
Star Height +Star Height d_{x} @@ -1012,7 +1005,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + d_{y} @@ -1026,7 +1019,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + n @@ -1034,7 +1027,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + \chi^{2} @@ -1048,7 +1041,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + R_{maj} @@ -1064,7 +1057,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + R_{min} @@ -1080,15 +1073,15 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + P P -a +a PR_{maj} @@ -1106,7 +1099,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + PR_{min} @@ -1124,105 +1117,105 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + \Theta Θ -bRef.Ref.
1 33472.5 -0.1 0.4 53 27.4 2.065 1.940 3.900 68.3 116.2 -27.6391,21 33472.5 -0.1 0.4 53 27.4 2.065 1.940 3.900 68.3 116.2 -27.6391,2
2 27802.4 -0.3 -0.2 60 3.7 1.628 1.510 2.156 6.8 7.5 -26.7643 2 27802.4 -0.3 -0.2 60 3.7 1.628 1.510 2.156 6.8 7.5 -26.7643
3 29210.6 0.9 0.3 60 3.4 1.622 1.551 2.159 6.7 7.3 -40.2724 3 29210.6 0.9 0.3 60 3.4 1.622 1.551 2.159 6.7 7.3 -40.2724
4 32733.8 -1.2c-0.5 41 54.8 2.282 2.156 4.313 117.4 78.2 -35.8475,6 4 32733.8 -1.2c-0.5 41 54.8 2.282 2.156 4.313 117.4 78.2 -35.8475,6
5 9607.4 -0.4 -0.4 60 1.4 1.669c1.574 2.343 8.0 8.9 -33.4177 5 9607.4 -0.4 -0.4 60 1.4 1.669c1.574 2.343 8.0 8.9 -33.4177
6 31638.6 1.6 0.1 39 315.2 3.433 3.075 7.488 92.1 25.3 -12.052 8 6 31638.6 1.6 0.1 39 315.2 3.433 3.075 7.488 92.1 25.3 -12.052 8
aSample footnote for table  that was generated with the LaTeX table environment
diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 97c8b64940..74d2ab6ade 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -282,9 +282,6 @@ Style Abstract Series Bold Size Normal EndFont - DocBookTag abstract - DocBookItemTag para - DocBookInInfo always End diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc index 83d46e9935..b02499ff51 100644 --- a/lib/layouts/stdstruct.inc +++ b/lib/layouts/stdstruct.inc @@ -49,9 +49,10 @@ Style Abstract font-weight: bold; } EndHTMLStyle + DocBookAbstract true + DocBookInInfo always DocBookTag abstract DocBookItemTag para - DocBookInInfo always End diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index e69deba624..2bb62e37c9 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -282,7 +282,7 @@ currentFormat = 83 # - Removed tag Element for flex insets # Incremented to format 83, 2 August 2020 by dourouc05 -# New tag DocBookWrapperMergeWithPrevious +# New tags DocBookWrapperMergeWithPrevious and DocBookAbstract # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). diff --git a/src/Layout.cpp b/src/Layout.cpp index eeb58d0452..50475061ed 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -107,6 +107,7 @@ enum LayoutTags { LT_DOCBOOKTAG, LT_DOCBOOKATTR, LT_DOCBOOKININFO, + LT_DOCBOOKABSTRACT, LT_DOCBOOKWRAPPERTAG, LT_DOCBOOKWRAPPERATTR, LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS, @@ -177,6 +178,7 @@ Layout::Layout() htmllabelfirst_ = false; htmlforcecss_ = false; htmltitle_ = false; + docbookabstract_ = false; docbookwrappermergewithprevious_ = false; spellcheck = true; forcelocal = 0; @@ -221,6 +223,7 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "commanddepth", LT_COMMANDDEPTH }, { "copystyle", LT_COPYSTYLE }, { "dependson", LT_DEPENDSON }, + { "docbookabstract", LT_DOCBOOKABSTRACT }, { "docbookattr", LT_DOCBOOKATTR }, { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG }, { "docbookininfo", LT_DOCBOOKININFO }, @@ -738,6 +741,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookininfo_; break; + case LT_DOCBOOKABSTRACT: + lex >> docbookabstract_; + break; + case LT_DOCBOOKWRAPPERTAG: lex >> docbookwrappertag_; break; @@ -1603,6 +1610,7 @@ void Layout::write(ostream & os) const os << "\tDocBookAttr " << docbookattr_ << '\n'; if(!docbookininfo_.empty()) os << "\tDocBookInInfo " << docbookininfo_ << '\n'; + os << "\tDocBookAbstract " << docbookabstract_ << '\n'; if(!docbookwrappertag_.empty()) os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n'; if(!docbookwrapperattr_.empty()) diff --git a/src/Layout.h b/src/Layout.h index d9eb893c2e..a894142a97 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -199,6 +199,8 @@ public: /// std::string const & docbookininfo() const; /// + bool docbookabstract() const { return docbookabstract_; } + /// std::string const & docbookwrappertag() const; /// std::string const & docbookwrapperattr() const; @@ -516,11 +518,14 @@ private: mutable std::string docbookwrapperattr_; /// Whether this wrapper tag may be merged with the previously opened wrapper tag. bool docbookwrappermergewithprevious_; - /// Outer tag for this section, only if this layout represent a sectionning item, including chapters (default: section). + /// Outer tag for this section, only if this layout represent a sectionning item, including chapters + /// (default: section). mutable std::string docbooksectiontag_; /// Whether this tag must/can/can't go into an tag (default: never, as it only makes sense for metadata). mutable std::string docbookininfo_; - /// whether this element (root or not) does not accept text without a section(i.e. the first text that is met + /// Wehther this paragraph should be considered as abstract. + bool docbookabstract_; + /// Whether this element (root or not) does not accept text without a section (i.e. the first text that is met /// in LyX must be considered as the abstract if this is true); this text must be output with the specific tag /// held by this attribute mutable std::string docbookforceabstracttag_; diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index fd38940064..4430041434 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -219,7 +219,8 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar if (tag == "Plain Layout") tag = "para"; - xs << xml::ParTag(tag, lay.docbookattr()); + if (!xs.isTagOpen(xml::ParTag(tag, lay.docbookattr()), 1)) // Don't nest a paragraph directly in a paragraph. + xs << xml::ParTag(tag, lay.docbookattr()); if (lay.docbookitemtag() != "NONE") xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); @@ -554,30 +555,38 @@ ParagraphList::const_iterator makeEnvironment( ParagraphList::const_iterator par = pbegin; depth_type const origdepth = pbegin->params().depth(); - // Find the previous paragraph. - auto prevpar = begin; - if (prevpar != par) { - auto prevpar_next = prevpar; - ++prevpar_next; - - while (prevpar_next != par) { + // Output the opening tag for this environment. + { + // Find the previous paragraph. + auto prevpar = begin; + if (prevpar != par) { + auto prevpar_next = prevpar; ++prevpar_next; - ++prevpar; - } - } - // open tag for this environment - openParTag(xs, &*par, &*prevpar); - xs << xml::CR(); + while (prevpar_next != par) { + ++prevpar_next; + ++prevpar; + } + } + + // Open tag for this environment. + openParTag(xs, &*par, &*prevpar); + xs << xml::CR(); + } // we will on occasion need to remember a layout from before. Layout const *lastlay = nullptr; + auto prevpar = par; while (par != pend) { Layout const & style = par->layout(); ParagraphList::const_iterator send; + auto parnext = par; + ++parnext; + // Actual content of this paragraph. + prevpar = par; switch (style.latextype) { case LATEX_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: @@ -701,15 +710,15 @@ ParagraphList::const_iterator makeEnvironment( break; } case LATEX_PARAGRAPH: - send = findLast(par, pend, LATEX_PARAGRAPH); - par = makeParagraphs(buf, xs, runparams, text, par, send); +// send = findLast(par, pend, LATEX_PARAGRAPH); + par = makeParagraphs(buf, xs, runparams, text, par, parnext); break; case LATEX_BIB_ENVIRONMENT: - send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); - par = makeParagraphBibliography(buf, xs, runparams, text, par, send); +// send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); + makeParagraphBibliography(buf, xs, runparams, text, par, parnext); break; case LATEX_COMMAND: - ++par; + par = parnext; break; } } @@ -721,9 +730,10 @@ ParagraphList::const_iterator makeEnvironment( xs << xml::CR(); } } - auto nextpar = par; - ++nextpar; - closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); +// auto nextpar = par; +// ++nextpar; + closeTag(xs, &*prevpar, &*par); +// closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); xs << xml::CR(); return pend; } @@ -773,43 +783,80 @@ pair makeAny( ParagraphList::const_iterator send, ParagraphList::const_iterator pend) { - Layout const & style = par->layout(); - - switch (style.latextype) { - case LATEX_COMMAND: { - // The files with which we are working never have more than - // one paragraph in a command structure. - // FIXME - // if (ourparams.docbook_in_par) - // fix it so we don't get sections inside standard, e.g. - // note that we may then need to make runparams not const, so we - // can communicate that back. - // FIXME Maybe this fix should be in the routines themselves, in case - // they are called from elsewhere. - makeCommand(buf, xs, ourparams, text, par); - ++par; - break; - } - case LATEX_ENVIRONMENT: - case LATEX_LIST_ENVIRONMENT: - case LATEX_ITEM_ENVIRONMENT: - // FIXME Same fix here. - send = findEndOfEnvironment(par, pend); - par = makeEnvironment(buf, xs, ourparams, text, par, send); - break; - case LATEX_PARAGRAPH: - send = findLast(par, pend, LATEX_PARAGRAPH); - par = makeParagraphs(buf, xs, ourparams, text, par, send); - break; - case LATEX_BIB_ENVIRONMENT: - send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); - par = makeParagraphBibliography(buf, xs, ourparams, text, par, send); - break; + switch (par->layout().latextype) { + case LATEX_COMMAND: { + // The files with which we are working never have more than + // one paragraph in a command structure. + // FIXME + // if (ourparams.docbook_in_par) + // fix it so we don't get sections inside standard, e.g. + // note that we may then need to make runparams not const, so we + // can communicate that back. + // FIXME Maybe this fix should be in the routines themselves, in case + // they are called from elsewhere. + makeCommand(buf, xs, ourparams, text, par); + ++par; + break; + } + case LATEX_ENVIRONMENT: + case LATEX_LIST_ENVIRONMENT: + case LATEX_ITEM_ENVIRONMENT: + // FIXME Same fix here. + send = findEndOfEnvironment(par, pend); + par = makeEnvironment(buf, xs, ourparams, text, par, send); + break; + case LATEX_PARAGRAPH: + send = findLast(par, pend, LATEX_PARAGRAPH); + par = makeParagraphs(buf, xs, ourparams, text, par, send); + break; + case LATEX_BIB_ENVIRONMENT: + send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); + par = makeParagraphBibliography(buf, xs, ourparams, text, par, send); + break; } return make_pair(par, send); } +ParagraphList::const_iterator makeAnySimple( + Text const &text, + Buffer const &buf, + XMLStream &xs, + OutputParams const &ourparams, + ParagraphList::const_iterator par) +{ + auto parnext = par; + ++parnext; + + switch (par->layout().latextype) { + case LATEX_COMMAND: { + // The files with which we are working never have more than + // one paragraph in a command structure. + // FIXME + // if (ourparams.docbook_in_par) + // fix it so we don't get sections inside standard, e.g. + // note that we may then need to make runparams not const, so we + // can communicate that back. + // FIXME Maybe this fix should be in the routines themselves, in case + // they are called from elsewhere. + makeCommand(buf, xs, ourparams, text, par); + return parnext; + } + case LATEX_ENVIRONMENT: + case LATEX_LIST_ENVIRONMENT: + case LATEX_ITEM_ENVIRONMENT: + // FIXME Same fix here. + return makeEnvironment(buf, xs, ourparams, text, par, parnext); + case LATEX_PARAGRAPH: + return makeParagraphs(buf, xs, ourparams, text, par, parnext); + case LATEX_BIB_ENVIRONMENT: + return makeParagraphBibliography(buf, xs, ourparams, text, par, parnext); + } + + // This should never happen. Return the next paragraph to avoid an infinite loop. + return parnext; +} + } // end anonymous namespace @@ -883,7 +930,7 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b continue; } - if (par.layout().name() == from_ascii("Abstract")) + if (par.layout().docbookabstract()) hasAbstractLayout = true; // Based on layout information, store this paragraph in one set: should be in , must be. @@ -908,7 +955,7 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b if (hasAbstractLayout) { pit_type pit = bpit; while (pit < cpit) { // Don't overshoot the part. - if (paragraphs[pit].layout().name() == from_ascii("Abstract")) + if (paragraphs[pit].layout().docbookabstract()) abstract.emplace(pit); pit++; } @@ -953,17 +1000,22 @@ pit_type generateDocBookParagraphWithoutSectioning( XMLStream & xs, OutputParams const & runparams, ParagraphList const & paragraphs, - pit_type bpit, - pit_type epit) + DocBookInfoTag const & info) { + auto bpit = info.bpit; auto par = paragraphs.iterator_at(bpit); auto lastStartedPar = par; ParagraphList::const_iterator send; auto const pend = - (epit == (int) paragraphs.size()) ? - paragraphs.end() : paragraphs.iterator_at(epit); + (info.epit == (int) paragraphs.size()) ? + paragraphs.end() : paragraphs.iterator_at(info.epit); + + while (bpit < info.epit) { + if (info.abstract.find(bpit) != info.abstract.end()) { + bpit += 1; + continue; + } - while (bpit < epit) { tie(par, send) = makeAny(text, buf, xs, runparams, par, send, pend); bpit += distance(lastStartedPar, par); lastStartedPar = par; @@ -988,18 +1040,25 @@ void outputDocBookInfo( bool hasAbstract = !info.abstract.empty(); docstring abstract; if (hasAbstract) { - pit_type bpitAbstract = *std::min_element(info.abstract.begin(), info.abstract.end()); - pit_type epitAbstract = *std::max_element(info.abstract.begin(), info.abstract.end()); - odocstringstream os2; - XMLStream xs2(os2); - generateDocBookParagraphWithoutSectioning(text, buf, xs2, runparams, paragraphs, bpitAbstract, epitAbstract); + { + XMLStream xs2(os2); + auto bpit = *std::min_element(info.abstract.begin(), info.abstract.end()); + auto epit = 1 + *std::max_element(info.abstract.begin(), info.abstract.end()); + // info.abstract is inclusive, epit is exclusive, hence +1 for looping. + + while (bpit < epit) { + makeAnySimple(text, buf, xs2, runparams, paragraphs.iterator_at(bpit)); + xs2 << XMLStream::ESCAPE_NONE << from_ascii(""); + bpit += 1; + } + } // Actually output the abstract if there is something to do. Don't count line feeds or spaces in this, // even though they must be properly output if there is some abstract. - docstring abstractContent = os2.str(); + abstract = os2.str(); static const lyx::regex reg("[ \\r\\n]*"); - abstractContent = from_utf8(lyx::regex_replace(to_utf8(abstractContent), reg, string(""))); + docstring abstractContent = from_utf8(lyx::regex_replace(to_utf8(abstract), reg, string(""))); // Nothing? Then there is no abstract! if (abstractContent.empty()) @@ -1016,19 +1075,29 @@ void outputDocBookInfo( xs << xml::CR(); } - // Output the elements that should go in . - generateDocBookParagraphWithoutSectioning(text, buf, xs, runparams, paragraphs, info.bpit, info.epit); + // Output the elements that should go in , before and after the abstract. + xs << XMLStream::ESCAPE_NONE << ""; + for (auto pit : info.shouldBeInInfo) // Typically, the title: these elements are so important and ubiquitous + // that mandating a wrapper like would repel users. + makeAnySimple(text, buf, xs, runparams, paragraphs.iterator_at(pit)); + xs << XMLStream::ESCAPE_NONE << ""; + for (auto pit : info.mustBeInInfo) + if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after. + makeAnySimple(text, buf, xs, runparams, paragraphs.iterator_at(pit)); + xs << XMLStream::ESCAPE_NONE << ""; - if (hasAbstract && !abstract.empty()) { // The second test is probably superfluous. - string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); - if (tag == "NONE") - tag = "abstract"; - - xs << xml::StartTag(tag); - xs << xml::CR(); + if (hasAbstract) { +// string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); +// if (tag == "NONE") +// tag = "abstract"; +// +// xs << xml::StartTag(tag); +// xs << xml::CR(); + xs << XMLStream::ESCAPE_NONE << ""; xs << XMLStream::ESCAPE_NONE << abstract; - xs << xml::EndTag(tag); - xs << xml::CR(); + xs << XMLStream::ESCAPE_NONE << ""; +// xs << xml::EndTag(tag); +// xs << xml::CR(); } // End the tag if it was started. @@ -1057,23 +1126,14 @@ void docbookFirstParagraphs( } -bool isParagraphEmpty(const Paragraph &par) -{ - InsetList const &insets = par.insetList(); - size_t insetsLength = distance(insets.begin(), insets.end()); - bool hasParagraphOnlyNote = insetsLength == 1 && insets.get(0) && insets.get(0)->asInsetCollapsible() && - dynamic_cast(insets.get(0)); - return hasParagraphOnlyNote; -} - - void docbookSimpleAllParagraphs( Text const & text, Buffer const & buf, XMLStream & xs, OutputParams const & runparams) { - // Handle the document, supposing it has no sections (i.e. a "simple" document). + // Handle the given text, supposing it has no sections (i.e. a "simple" text). The input may vary in length + // between a single paragraph to a whole document. // First, the tag. ParagraphList const ¶graphs = text.paragraphs(); @@ -1081,27 +1141,14 @@ void docbookSimpleAllParagraphs( pit_type const epit = runparams.par_end; DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit); outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); - bpit = info.bpit; - - // Then, the content. - ParagraphList::const_iterator const pend = - (epit == (int) paragraphs.size()) ? - paragraphs.end() : paragraphs.iterator_at(epit); + // Then, the content. It starts where the ends. + bpit = info.epit; while (bpit < epit) { auto par = paragraphs.iterator_at(bpit); - ParagraphList::const_iterator const lastStartedPar = par; - ParagraphList::const_iterator send; - - if (isParagraphEmpty(*par)) { - ++par; - bpit += distance(lastStartedPar, par); - continue; - } - - // Generate this paragraph. - tie(par, send) = makeAny(text, buf, xs, runparams, par, send, pend); - bpit += distance(lastStartedPar, par); + if (!hasOnlyNotes(*par)) + makeAnySimple(text, buf, xs, runparams, par); + bpit += 1; } } @@ -1155,7 +1202,7 @@ void docbookParagraphs(Text const &text, ParagraphList::const_iterator const lastStartedPar = par; ParagraphList::const_iterator send; - if (isParagraphEmpty(*par)) { + if (hasOnlyNotes(*par)) { ++par; bpit += distance(lastStartedPar, par); continue; @@ -1250,4 +1297,4 @@ void docbookParagraphs(Text const &text, } } -} // namespace lyx +} // namespace lyx \ No newline at end of file From 9184ae14f0e1925cc6c63b046a65157c08d65159 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 16 Aug 2020 19:07:14 +0200 Subject: [PATCH 11/88] A few more constants to avoid copies --- src/insets/InsetBibtex.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 876adea54b..34b22c1583 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1216,9 +1216,9 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const if (! delayedTags.empty()) { unsigned long remainingTags = delayedTags.size(); // Used as a workaround. With GCC 7, when erasing all // elements one by one, some elements may still pop in later on (even though they were deleted previously). - auto hasTag = [&delayedTags](string key) { return delayedTags.find(key) != delayedTags.end(); }; - auto getTag = [&delayedTags](string key) { return from_utf8(delayedTags[key]); }; - auto eraseTag = [&delayedTags, &remainingTags](string key) { + auto hasTag = [&delayedTags](const string & key) { return delayedTags.find(key) != delayedTags.end(); }; + auto getTag = [&delayedTags](const string & key) { return from_utf8(delayedTags[key]); }; + auto eraseTag = [&delayedTags, &remainingTags](const string & key) { remainingTags -= 1; delayedTags.erase(key); }; From 87dae26e4a8146c7e9b450dfff4d8711deeed933 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 16 Aug 2020 00:59:43 +0200 Subject: [PATCH 12/88] Simplify code to generate only one paragraph at a time. --- autotests/export/docbook/basic.xml | 351 ++++++------ autotests/export/docbook/easy.lyx | 253 +++++++++ autotests/export/docbook/easy.xml | 68 +++ autotests/export/docbook/lists.lyx | 18 +- autotests/export/docbook/lists.xml | 48 +- lib/layouts/stdlayouts.inc | 10 +- lib/layouts/stdlists.inc | 4 +- lib/layouts/stdstarsections.inc | 4 +- lib/layouts/stdstruct.inc | 5 +- src/Paragraph.cpp | 9 +- src/ParagraphList.h | 11 + src/insets/InsetBibtex.cpp | 3 +- src/insets/InsetERT.cpp | 3 +- src/insets/InsetNewline.cpp | 21 +- src/mathed/InsetMathHull.cpp | 3 +- src/output_docbook.cpp | 855 +++++++++++------------------ src/xml.cpp | 45 +- 17 files changed, 928 insertions(+), 783 deletions(-) create mode 100644 autotests/export/docbook/easy.lyx create mode 100644 autotests/export/docbook/easy.xml diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index f208ae61da..6f4a828d4b 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -1,69 +1,62 @@ -
- -I am a title -I am an author +
+ +I am a title + +I am an author + I am a date - -I am an abstract + +I am an abstract I am also an abstract -I am a standard paragraph. -
+
I am the first section I am the first paragraph of the first section. - I am the second paragraph of the first section. - -
I am a quote - - - \,with\,a\,formula +
+I am a quote +\,with\,a\,formula + + - - with - a - formula + withaformula - - . + +.
- - - - Formula! + +Formula! + + Formula! - - - - - \text{I am a formula with a ref.}\label{eq:EQ.} + + +\text{I am a formula with a ref.}\label{eq:EQ.} + + I am a formula with a ref. - - - -See . - -Also, a formula with an user-defined macro that outputs well in LaTeX but cannot in MathML (hence replaced by picture): - - - \testmacro - - . - -
+ + +See . +Also, a formula with an user-defined macro that outputs well in LaTeX but cannot in MathML (hence replaced by picture): +\testmacro +MathML export failed. Please report this as a bug. +. + +
I am the first subsection I am the only paragraph of the first subsection.
@@ -72,174 +65,150 @@ I am the only paragraph of the second subsection.
-
+
I am the second section I am the only paragraph of the second section. Hyperlink. “Text between quotes.” - -See . +See .
I am the third section and I have fun with lists +First item. +
+Second line of the first item, after a line break.
+Second item. +Item has no order (1). +Item has no order (2). + +Word description + + + -First item. -Second line of the first item, after a line break. - - -Second item. - - - - -Item has no order (1). - - -Item has no order (2). - - - -Word - - - description - -Sentence - - - meaning - - +Sentence meaning + +
I am the fourth section and I deal with formatting. The following paragraph should be code. - I am some code. -I am a second line of code. I am no more code. - +I am a second line of code. +I am no more code. This line has inline code. This has typewriter fontI repeat that in a footnote. . - On the other hand, this footnote - has multiple - paragraphs. .
I am the fifth section and I deal with floats Now, three tables: - - - - - - +
I am a table caption below the table.
Table 1
+ + + + - + + - + + - - + +
I am a table caption below the table.
Table 1 Table 2 Table 3
Row 1
Row 1 Col 3, row 1
Row 2
Row 2 Col 3, row 2
- - - - - - - +
I am a table caption above the table.
Table 1
+ + + + - + + - + + - + +
I am a table caption above the table.
Table 1 Table 2 Table 3
Row 1
Row 1 Col 3, row 1
Row 2
Row 2 Col 3, row 2
- - - - -Table that has no caption 1 + + + +Table that has no caption 1 Table that has no caption 2 Table that has no caption 3 -Row 1 + +Row 1 Col 3, row 1 -Row 2 + +Row 2 Col 3, row 2 - + + - Then, one figure: - - -
Caption. - - - +
+Caption. + + + -
I am the sixth section and I really like bibliographies This text has references. First reference: . Second reference: . Both at the same time: , . A book: . - Many things, just testing for completeness: , , , , , .
I am the seventh section and I deal with indices First, a term to index: Term to index. Then a term to add to the second index: Term to add to the second index. - Then several terms for the first index: Termtoindex. - With a see: Termindex. With a see also: Termindex. - Several terms with a see: Termtoindexindex. Several terms with a see also: Termtoindexindex. - -A start of range: Term to index. The corresponding end of range: Term to index. - -Several terms with a start of range: Termtoindex. The corresponding end of range: Termtoindex. - -These terms already appeared before! Start of range: Termtoindex. The corresponding end of range: Termtoindex. +A start of range: Term to index. The corresponding end of range: Term to index. +Several terms with a start of range: Termtoindex. The corresponding end of range: Termtoindex. +These terms already appeared before! Start of range: Termtoindex. The corresponding end of range: Termtoindex.
I am the eight section and I deal with star sections -Star part +Star part Star section (sect1) Star subsection (sect2) Star subsubsection (sect3) Star paragraph (sect4) Star subparagraph (sect5)
- -References - -The title of the work4201-213article + +References + +The title of the work4201-213article 1993 - -The name of the journal + +The name of the journal - - -Peter + + +Peter Adams @@ -247,119 +216,119 @@ I am a second line of code. I am no more code. 2 An optional note - -The title of the work43book - -The name of the publisher + +The title of the work43book + +The name of the publisher
The address
1993 - - -Peter + + +Peter Babington An optional note
- -The title of the workbooklet + +The title of the workbooklet 1993 - - -Peter + + +Peter Caxton - -The title of the work213conference - -The publisher + +The title of the work213conference + +The publisher 1993 - - -Peter + + +Peter Draper - -The title of the work201-213inbook - -The name of the publisher + +The title of the work201-213inbook + +The name of the publisher 1993 - - -Peter + + +Peter Eston - -The title of the work43201-213incollection - -The name of the publisher + +The title of the work43201-213incollection + +The name of the publisher
The address of the publisher
1993 - -The title of the book + +The title of the book - - -Peter + + +Peter Farindon An optional note
- -A small paper-1article + +A small paper-1article 1997 - -The journal of small papers + +The journal of small papers - - -Freely + + +Freely I. P. - - -Ditto + + +Ditto Johannes to appear - -Éléments de géométrie algébriquebook + +Éléments de géométrie algébriquebook 1960 - - -Alexander + + +Alexander Grothendieck - -A big paperMCMXCVIIarticle + +A big paperMCMXCVIIarticle 7991 - -The journal of big papers + +The journal of big papers - - -Hugh + + +Hugh Jass diff --git a/autotests/export/docbook/easy.lyx b/autotests/export/docbook/easy.lyx new file mode 100644 index 0000000000..0ea08e7e65 --- /dev/null +++ b/autotests/export/docbook/easy.lyx @@ -0,0 +1,253 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass article +\begin_preamble +\newcommand{\testmacro}{\ensuremath{\operatorname{testmacro}}} +\end_preamble +\use_default_options true +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding auto-legacy +\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 true +\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 false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine basic +\cite_engine_type default +\biblio_style plain +\use_bibtopic false +\use_indices true +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 1 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\index Other index +\shortcut oth +\color #cc0000 +\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 +I am a title +\end_layout + +\begin_layout Author +I am an author +\end_layout + +\begin_layout Date +I am a date +\end_layout + +\begin_layout Abstract +I am an abstract +\end_layout + +\begin_layout Abstract +I am also an abstract +\end_layout + +\begin_layout Section +I am the first section +\begin_inset CommandInset label +LatexCommand label +name "sec:Sec-1" + +\end_inset + + +\end_layout + +\begin_layout Standard +I am the first paragraph of the first section. + +\end_layout + +\begin_layout Standard +I am the second paragraph of the first section. + +\end_layout + +\begin_layout Quote +I am a quote +\begin_inset Formula $\,with\,a\,formula$ +\end_inset + +. + +\end_layout + +\begin_layout Standard +\begin_inset Formula +\[ +Formula! +\] + +\end_inset + + +\end_layout + +\begin_layout Subsection +I am the first subsection +\end_layout + +\begin_layout Standard +I am the only paragraph of the first subsection. + +\end_layout + +\begin_layout Subsection +I am the second subsection +\end_layout + +\begin_layout Standard +I am the only paragraph of the second subsection. + +\end_layout + +\begin_layout Section +I am the second section +\end_layout + +\begin_layout Standard +I am the only paragraph of the second section. + +\begin_inset CommandInset href +LatexCommand href +name "Hyperlink." +target "http://example.org" +literal "false" + +\end_inset + + +\begin_inset Quotes eld +\end_inset + +Text between quotes. +\begin_inset Quotes erd +\end_inset + + +\end_layout + +\begin_layout Standard +See +\begin_inset CommandInset ref +LatexCommand ref +reference "sec:Sec-1" +plural "false" +caps "false" +noprefix "false" + +\end_inset + +. +\end_layout + +\begin_layout Section +I am the third section and I deal with star sections +\end_layout + +\begin_layout Part* +Star part +\end_layout + +\begin_layout Section* +Star section (sect1) +\end_layout + +\begin_layout Subsection* +Star subsection (sect2) +\end_layout + +\begin_layout Subsubsection* +Star subsubsection (sect3) +\end_layout + +\begin_layout Paragraph* +Star paragraph (sect4) +\end_layout + +\begin_layout Subparagraph* +Star subparagraph (sect5) +\end_layout + +\begin_layout Standard +\begin_inset CommandInset bibtex +LatexCommand bibtex +bibfiles "basic" +options "plain" + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/easy.xml b/autotests/export/docbook/easy.xml new file mode 100644 index 0000000000..883c98226e --- /dev/null +++ b/autotests/export/docbook/easy.xml @@ -0,0 +1,68 @@ + + +
+ +I am a title + +I am an author + +I am a date + +I am an abstract +I am also an abstract + + +
+I am the first section +I am the first paragraph of the first section. +I am the second paragraph of the first section. +
+I am a quote +\,with\,a\,formula + + + + withaformula + + + +. +
+ +Formula! + + + + Formula! + + + +
+I am the first subsection +I am the only paragraph of the first subsection. +
+
+I am the second subsection +I am the only paragraph of the second subsection. +
+
+
+I am the second section +I am the only paragraph of the second section. Hyperlink. “Text between quotes.” +See . +
+
+I am the third section and I deal with star sections +Star part +Star section (sect1) +Star subsection (sect2) +Star subsubsection (sect3) +Star paragraph (sect4) +Star subparagraph (sect5) +
+ +References + + +
\ No newline at end of file diff --git a/autotests/export/docbook/lists.lyx b/autotests/export/docbook/lists.lyx index 4e46d709b2..f903372084 100644 --- a/autotests/export/docbook/lists.lyx +++ b/autotests/export/docbook/lists.lyx @@ -87,7 +87,23 @@ Test document \end_layout \begin_layout Standard -A list: +A simple list: +\end_layout + +\begin_layout Itemize +First item +\end_layout + +\begin_layout Itemize +Second item on two lines +\begin_inset Newline newline +\end_inset + +I'm the second line +\end_layout + +\begin_layout Standard +A complex list: \end_layout \begin_layout Itemize diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml index a00ab4f633..4621e30937 100644 --- a/autotests/export/docbook/lists.xml +++ b/autotests/export/docbook/lists.xml @@ -2,33 +2,61 @@
-Test document -A list: + +Test document + + +A simple list: + First item + + +Second item on two lines + + +I'm the second line + + + + + + + + +A complex list: + +First item + + First first item First second item -Text after first item - + +Text after first item + + Second item - - + + + Second first item - + + Second second item -Text after second item - - + +Text after second item +
\ No newline at end of file diff --git a/lib/layouts/stdlayouts.inc b/lib/layouts/stdlayouts.inc index 3b10ff4143..16706956b7 100644 --- a/lib/layouts/stdlayouts.inc +++ b/lib/layouts/stdlayouts.inc @@ -28,8 +28,9 @@ Style Quotation AlignPossible Block, Left, Right, Center HTMLTag blockquote HTMLItem div - DocBookTag blockquote - DocBookItemTag para + DocBookWrapperTag blockquote + DocBookWrapperMergeWithPrevious true + DocBookTag para End @@ -50,8 +51,9 @@ Style Quote LabelType No_Label HTMLTag blockquote HTMLItem div - DocBookTag blockquote - DocBookItemTag para + DocBookWrapperTag blockquote + DocBookWrapperMergeWithPrevious true + DocBookTag para End diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc index 0eef65c665..16a9e8188f 100644 --- a/lib/layouts/stdlists.inc +++ b/lib/layouts/stdlists.inc @@ -43,7 +43,9 @@ Style Itemize Color latex EndFont EndArgument - DocBookTag itemizedlist + DocBookWrapperTag itemizedlist + DocBookWrapperMergeWithPrevious true + DocBookTag NONE DocBookItemTag listitem DocBookItemInnerTag para End diff --git a/lib/layouts/stdstarsections.inc b/lib/layouts/stdstarsections.inc index 7d6865fe36..60354b1dd3 100644 --- a/lib/layouts/stdstarsections.inc +++ b/lib/layouts/stdstarsections.inc @@ -19,7 +19,7 @@ Style Part* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="part" + DocBookAttr "renderas='other' otherrenderas='part'" DocBookSectionTag NONE DocBookForceAbstractTag NONE End @@ -34,7 +34,7 @@ Style Chapter* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="chapter" + DocBookAttr "renderas='other' otherrenderas='chapter'" DocBookSectionTag NONE DocBookForceAbstractTag NONE End diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc index b02499ff51..c8b7eb4cbd 100644 --- a/lib/layouts/stdstruct.inc +++ b/lib/layouts/stdstruct.inc @@ -51,8 +51,9 @@ Style Abstract EndHTMLStyle DocBookAbstract true DocBookInInfo always - DocBookTag abstract - DocBookItemTag para + DocBookWrapperTag abstract + DocBookWrapperMergeWithPrevious true + DocBookTag para End diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 2465cc4101..24947f80dd 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3383,12 +3383,9 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, if (!runparams.for_toc || inset->isInToc()) { OutputParams np = runparams; np.local_font = &font; - // If the paragraph has size 1, then we are in the "special - // case" where we do not output the containing paragraph info. - // This "special case" is defined in more details in output_docbook.cpp, makeParagraphs. The results - // of that brittle logic is passed to this function through open_par. - if (!inset->getLayout().htmlisblock() && size() != 1) // TODO: htmlisblock here too! - np.docbook_in_par = true; + + // TODO: special case will bite here. + np.docbook_in_par = true; inset->docbook(xs, np); } } else { diff --git a/src/ParagraphList.h b/src/ParagraphList.h index a57deb4eea..7e5cc1a869 100644 --- a/src/ParagraphList.h +++ b/src/ParagraphList.h @@ -29,6 +29,17 @@ public: ParagraphList(InputIterator first, InputIterator last) : RandomAccessList(first, last) {} + + const Paragraph * getParagraphBefore(const_iterator const & par) const + { + // No previous paragraph. + if (par == begin()) + return nullptr; + + auto prevpar = par; + --prevpar; + return &*prevpar; + } }; } // namespace lyx diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 34b22c1583..c03a8e24d3 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1157,10 +1157,11 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const if (vit == ven) { xs << XMLStream::ESCAPE_NONE << ""; + xs << xml::CR(); } for (; vit != ven; ++vit) { - BiblioInfo::const_iterator const biit = bibinfo.find(*vit); + auto const biit = bibinfo.find(*vit); if (biit == bibinfo.end()) continue; diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index a023f7a464..8e69e88260 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -101,7 +101,7 @@ void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const odocstringstream os2; XMLStream xs2(os2); - // Recreate the logic of makeParagraphs in output_docbook.cpp, but much simplified: never open + // Recreate the logic of makeParagraph in output_docbook.cpp, but much simplified: never open // in an ERT, use simple line breaks. while (par != end) { par->simpleDocBookOnePar(buffer(), xs2, runparams, text().outerFont(distance(begin, par))); @@ -116,6 +116,7 @@ void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const xs << XMLStream::ESCAPE_NONE << ""; + xs << xml::CR(); } diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 45d52b23da..00b276ea47 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -176,17 +176,18 @@ void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const { if (runparams.docbook_in_par) { xs.closeFontTags(); - if (!xs.pending_tags_empty()) { - xs << xml::EndTag("para"); - xs << xml::StartTag("para"); - } - else { - xs << xml::CR() << xml::CompTag("br") << xml::CR(); - } - } - else { - xs << xml::CR() << xml::CompTag("br") << xml::CR(); + + // TODO: what if within a list item, and docbookiteminnertag is not para? This would require information + // about the paragraph's layout... Good for now, though, this should not happen in DocBook, only maybe + // extensions. + xs << XMLStream::ESCAPE_NONE << from_utf8(""); + xs << XMLStream::ESCAPE_NONE << from_utf8("\nMathML export failed. Please report this as a bug."; } // Output the complete formula to the DocBook stream. diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 4430041434..b29da56c34 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -43,6 +43,8 @@ #include #include +// #define DOCBOOK_DEBUG_NEWLINES + using namespace std; using namespace lyx::support; @@ -191,6 +193,10 @@ namespace { void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) { +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + Layout const & lay = par->layout(); if (par == prevpar) @@ -212,29 +218,43 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar } // Main logic. - if (openWrapper) + if (openWrapper) { xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); + xs << xml::CR(); + } string tag = lay.docbooktag(); - if (tag == "Plain Layout") - tag = "para"; + if (tag != "NONE") { + auto xmltag = xml::ParTag(tag, lay.docbookattr()); + if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph. TODO: required or not? + xs << xmltag; + } - if (!xs.isTagOpen(xml::ParTag(tag, lay.docbookattr()), 1)) // Don't nest a paragraph directly in a paragraph. - xs << xml::ParTag(tag, lay.docbookattr()); - - if (lay.docbookitemtag() != "NONE") + if (lay.docbookitemtag() != "NONE") { xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); + xs << xml::CR(); + } + + if (lay.docbookiteminnertag() != "NONE") + xs << xml::StartTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr()); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } -void closeTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) +void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) { - Layout const & lay = par->layout(); +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif if (par == nextpar) nextpar = nullptr; // See comment in openParTag. + Layout const & lay = par->layout(); bool closeWrapper = lay.docbookwrappertag() != "NONE"; if (nextpar != nullptr) { Layout const & nextlay = nextpar->layout(); @@ -245,132 +265,133 @@ void closeTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) } // Main logic. - if (lay.docbookitemtag() != "NONE") + if (lay.docbookiteminnertag() != "NONE") { + xs << xml::EndTag(lay.docbookiteminnertag()); + xs << xml::CR(); + } + + if (lay.docbookitemtag() != "NONE") { xs << xml::EndTag(lay.docbookitemtag()); + xs << xml::CR(); + } - string tag = lay.docbooktag(); - if (tag == "Plain Layout") - tag = "para"; + if (lay.docbooktag() != "NONE") { + xs << xml::EndTag(lay.docbooktag()); + xs << xml::CR(); + } - xs << xml::EndTag(tag); - if (closeWrapper) + if (closeWrapper) { xs << xml::EndTag(lay.docbookwrappertag()); + xs << xml::CR(); + } + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif +} + + +void openBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) +{ +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + + // Similar as openParTag, but with a line feed after. + openParTag(xs, par, prevpar); + xs << xml::CR(); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif +} + + +void closeBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) +{ +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + + // Similar as closeParTag, but with a line feed before. + xs << xml::CR(); + closeParTag(xs, par, prevpar); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists. { +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + xs << xml::StartTag(lay.docbookitemlabeltag(), lay.docbookitemlabelattr()); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } void closeLabelTag(XMLStream & xs, Layout const & lay) { +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + xs << xml::EndTag(lay.docbookitemlabeltag()); xs << xml::CR(); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } void openItemTag(XMLStream & xs, Layout const & lay) { +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif + xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); + +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } -// Return true when new elements are output in a paragraph, false otherwise. -bool openInnerItemTag(XMLStream & xs, Layout const & lay) +void closeItemTag(XMLStream & xs, Layout const & lay) { - if (lay.docbookiteminnertag() != "NONE") { - xs << xml::CR(); - xs << xml::ParTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr()); +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif - if (lay.docbookiteminnertag() == "para") { - return true; - } - } - return false; -} - - -void closeInnerItemTag(XMLStream & xs, Layout const & lay) -{ - if (lay.docbookiteminnertag()!= "NONE") { - xs << xml::EndTag(lay.docbookiteminnertag()); - xs << xml::CR(); - } -} - - -inline void closeItemTag(XMLStream & xs, Layout const & lay) -{ xs << xml::EndTag(lay.docbookitemtag()); xs << xml::CR(); -} -// end of convenience functions - -ParagraphList::const_iterator findLast( - ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend, - LatexType type) { - for (++p; p != pend && p->layout().latextype == type; ++p); - - return p; -} - -ParagraphList::const_iterator findLastBibliographyParagraph( - ParagraphList::const_iterator p, - ParagraphList::const_iterator const & pend) { - for (++p; p != pend && p->layout().latextype == LATEX_BIB_ENVIRONMENT; ++p); - - return p; +#ifdef DOCBOOK_DEBUG_NEWLINES + xs << XMLStream::ESCAPE_NONE << ""; +#endif } -ParagraphList::const_iterator findEndOfEnvironment( - ParagraphList::const_iterator const & pstart, - ParagraphList::const_iterator const & pend) -{ - ParagraphList::const_iterator p = pstart; - size_t const depth = p->params().depth(); - - for (++p; p != pend; ++p) { - Layout const &style = p->layout(); - // It shouldn't happen that e.g. a section command occurs inside - // a quotation environment, at a higher depth, but as of 6/2009, - // it can happen. We pretend that it's just at lowest depth. - if (style.latextype == LATEX_COMMAND) - return p; - - // If depth is down, we're done - if (p->params().depth() < depth) - return p; - - // If depth is up, we're not done - if (p->params().depth() > depth) - continue; - - // FIXME I am not sure about the first check. - // Surely we *could* have different layouts that count as - // LATEX_PARAGRAPH, right? - if (style.latextype == LATEX_PARAGRAPH || style != p->layout()) - return p; - } - - return pend; -} - - -ParagraphList::const_iterator makeParagraphBibliography( - Buffer const &buf, - XMLStream &xs, - OutputParams const &runparams, - Text const &text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) +void makeParagraphBibliography( + Buffer const & buf, + XMLStream & xs, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & pbegin) { auto const begin = text.paragraphs().begin(); auto const end = text.paragraphs().end(); + auto pend = pbegin; + ++pend; // Find the paragraph *before* pbegin. ParagraphList::const_iterator pbegin_before = begin; @@ -420,322 +441,203 @@ ParagraphList::const_iterator makeParagraphBibliography( xs << xml::EndTag("bibliography"); xs << xml::CR(); } - - return pend; } -ParagraphList::const_iterator makeParagraphs( - Buffer const &buf, - XMLStream &xs, - OutputParams const &runparams, - Text const &text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) +void makeParagraph( + Buffer const & buf, + XMLStream & xs, + OutputParams const & runparams, + Text const & text, + ParagraphList::const_iterator const & par) { auto const begin = text.paragraphs().begin(); auto const end = text.paragraphs().end(); - ParagraphList::const_iterator par = pbegin; - ParagraphList::const_iterator prevpar = pbegin; + auto prevpar = text.paragraphs().getParagraphBefore(par); - for (; par != pend; prevpar = par, ++par) { - // We want to open the paragraph tag if: - // (i) the current layout permits multiple paragraphs - // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR - // we are, but this is not the first paragraph - // - // But there is also a special case, and we first see whether we are in it. - // We do not want to open the paragraph tag if this paragraph contains - // only one item, and that item is "inline", i.e., not HTMLIsBlock (such - // as a branch). On the other hand, if that single item has a font change - // applied to it, then we still do need to open the paragraph. - // - // Obviously, this is very fragile. The main reason we need to do this is - // because of branches, e.g., a branch that contains an entire new section. - // We do not really want to wrap that whole thing in a
...
. - bool special_case = false; - Inset const *specinset = par->size() == 1 ? par->getInset(0) : nullptr; - if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter? - Layout const &style = par->layout(); - FontInfo const first_font = style.labeltype == LABEL_MANUAL ? - style.labelfont : style.font; - FontInfo const our_font = - par->getFont(buf.masterBuffer()->params(), 0, - text.outerFont(distance(begin, par))).fontInfo(); + // We want to open the paragraph tag if: + // (i) the current layout permits multiple paragraphs + // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR + // we are, but this is not the first paragraph + // + // But there is also a special case, and we first see whether we are in it. + // We do not want to open the paragraph tag if this paragraph contains + // only one item, and that item is "inline", i.e., not HTMLIsBlock (such + // as a branch). On the other hand, if that single item has a font change + // applied to it, then we still do need to open the paragraph. + // + // Obviously, this is very fragile. The main reason we need to do this is + // because of branches, e.g., a branch that contains an entire new section. + // We do not really want to wrap that whole thing in a
...
. + bool special_case = false; + Inset const *specinset = par->size() == 1 ? par->getInset(0) : nullptr; + if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter? + Layout const &style = par->layout(); + FontInfo const first_font = style.labeltype == LABEL_MANUAL ? + style.labelfont : style.font; + FontInfo const our_font = + par->getFont(buf.masterBuffer()->params(), 0, + text.outerFont(std::distance(begin, par))).fontInfo(); - if (first_font == our_font) - special_case = true; - } - - // Plain layouts must be ignored. - if (!special_case && buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars) + if (first_font == our_font) special_case = true; - // TODO: Could get rid of this with a DocBook equivalent to htmlisblock? - if (!special_case && par->size() == 1 && par->getInset(0)) { - Inset const * firstInset = par->getInset(0); - - // Floats cannot be in paragraphs. - special_case = to_utf8(firstInset->layoutName()).substr(0, 6) == "Float:"; - - // Bibliographies cannot be in paragraphs. - if (!special_case && firstInset->asInsetCommand()) - special_case = firstInset->asInsetCommand()->params().getCmdName() == "bibtex"; - - // Equations do not deserve their own paragraph (DocBook allows them outside paragraphs). - if (!special_case && firstInset->asInsetMath()) - special_case = true; - - // ERTs are in comments, not paragraphs. - if (!special_case && firstInset->lyxCode() == lyx::ERT_CODE) - special_case = true; - - // Listings should not get into their own paragraph. - if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE) - special_case = true; - } - - bool const open_par = runparams.docbook_make_pars - && (!runparams.docbook_in_par || par != pbegin) - && !special_case; - - // We want to issue the closing tag if either: - // (i) We opened it, and either docbook_in_par is false, - // or we're not in the last paragraph, anyway. - // (ii) We didn't open it and docbook_in_par is true, - // but we are in the first par, and there is a next par. - auto nextpar = par; - ++nextpar; - bool const close_par = - ((open_par && (!runparams.docbook_in_par || nextpar != pend)) - || (!open_par && runparams.docbook_in_par && par == pbegin && nextpar != pend)); - - // Determine if this paragraph has some real content. Things like new pages are not caught - // by Paragraph::empty(), even though they do not generate anything useful in DocBook. - odocstringstream os2; - XMLStream xs2(os2); - par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0); - - docstring cleaned = os2.str(); - static const lyx::regex reg("[ \\r\\n]*"); - cleaned = from_utf8(lyx::regex_replace(to_utf8(cleaned), reg, string(""))); - - if (!cleaned.empty()) { - if (open_par) - openParTag(xs, &*par, &*prevpar); - - xs << XMLStream::ESCAPE_NONE << os2.str(); - - if (close_par) { - closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); - xs << xml::CR(); - } - } } - return pend; + + // Plain layouts must be ignored. + if (!special_case && buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars) + special_case = true; + // TODO: Could get rid of this with a DocBook equivalent to htmlisblock? + if (!special_case && par->size() == 1 && par->getInset(0)) { + Inset const * firstInset = par->getInset(0); + + // Floats cannot be in paragraphs. + special_case = to_utf8(firstInset->layoutName()).substr(0, 6) == "Float:"; + + // Bibliographies cannot be in paragraphs. + if (!special_case && firstInset->asInsetCommand()) + special_case = firstInset->asInsetCommand()->params().getCmdName() == "bibtex"; + + // Equations do not deserve their own paragraph (DocBook allows them outside paragraphs). + if (!special_case && firstInset->asInsetMath()) + special_case = true; + + // ERTs are in comments, not paragraphs. + if (!special_case && firstInset->lyxCode() == lyx::ERT_CODE) + special_case = true; + + // Listings should not get into their own paragraph. + if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE) + special_case = true; + } + + bool const open_par = runparams.docbook_make_pars + && !runparams.docbook_in_par + && !special_case; + + // We want to issue the closing tag if either: + // (i) We opened it, and either docbook_in_par is false, + // or we're not in the last paragraph, anyway. + // (ii) We didn't open it and docbook_in_par is true, + // but we are in the first par, and there is a next par. + auto nextpar = par; + ++nextpar; + bool const close_par = open_par && (!runparams.docbook_in_par); + + // Determine if this paragraph has some real content. Things like new pages are not caught + // by Paragraph::empty(), even though they do not generate anything useful in DocBook. + odocstringstream os2; + XMLStream xs2(os2); + par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0); + + docstring cleaned = os2.str(); + static const lyx::regex reg("[ \\r\\n]*"); + cleaned = from_utf8(lyx::regex_replace(to_utf8(cleaned), reg, string(""))); + + if (!cleaned.empty()) { + if (open_par) + openParTag(xs, &*par, prevpar); + + xs << XMLStream::ESCAPE_NONE << os2.str(); + + if (close_par) + closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); + } } -bool isNormalEnv(Layout const &lay) -{ - return lay.latextype == LATEX_ENVIRONMENT - || lay.latextype == LATEX_BIB_ENVIRONMENT; -} +void makeAny( + Text const &text, + Buffer const &buf, + XMLStream &xs, + OutputParams const &ourparams, + ParagraphList::const_iterator par); -ParagraphList::const_iterator makeEnvironment( +void makeEnvironment( Buffer const &buf, XMLStream &xs, OutputParams const &runparams, Text const &text, - ParagraphList::const_iterator const & pbegin, - ParagraphList::const_iterator const & pend) + ParagraphList::const_iterator const & par) { - auto const begin = text.paragraphs().begin(); auto const end = text.paragraphs().end(); - ParagraphList::const_iterator par = pbegin; - depth_type const origdepth = pbegin->params().depth(); - // Output the opening tag for this environment. - { - // Find the previous paragraph. - auto prevpar = begin; - if (prevpar != par) { - auto prevpar_next = prevpar; - ++prevpar_next; + // Output the opening tag for this environment, but only if it has not been previously opened (condition + // implemented in openParTag). + auto prevpar = text.paragraphs().getParagraphBefore(par); + openParTag(xs, &*par, prevpar); // TODO: switch in layout for par/block? - while (prevpar_next != par) { - ++prevpar_next; - ++prevpar; - } - } - - // Open tag for this environment. - openParTag(xs, &*par, &*prevpar); - xs << xml::CR(); - } - - // we will on occasion need to remember a layout from before. - Layout const *lastlay = nullptr; - auto prevpar = par; - - while (par != pend) { - Layout const & style = par->layout(); - ParagraphList::const_iterator send; - - auto parnext = par; - ++parnext; - - // Actual content of this paragraph. - prevpar = par; - switch (style.latextype) { - case LATEX_ENVIRONMENT: - case LATEX_LIST_ENVIRONMENT: - case LATEX_ITEM_ENVIRONMENT: { - // There are two possibilities in this case. - // One is that we are still in the environment in which we - // started---which we will be if the depth is the same. - if (par->params().depth() == origdepth) { - LATTEST(par->layout() == style); - if (lastlay != nullptr) { - closeItemTag(xs, *lastlay); - if (lastlay->docbookitemwrappertag() != "NONE") { - xs << xml::EndTag(lastlay->docbookitemwrappertag()); - xs << xml::CR(); - } - lastlay = nullptr; - } - - // this will be positive if we want to skip the - // initial word (if it's been taken for the label). - pos_type sep = 0; - - // Open a wrapper tag if needed. - if (style.docbookitemwrappertag() != "NONE") { - xs << xml::StartTag(style.docbookitemwrappertag(), style.docbookitemwrapperattr()); - xs << xml::CR(); - } - - // label output - if (style.labeltype != LABEL_NO_LABEL && - style.docbookitemlabeltag() != "NONE") { - - if (isNormalEnv(style)) { - // in this case, we print the label only for the first - // paragraph (as in a theorem or an abstract). - if (par == pbegin) { - docstring const lbl = pbegin->params().labelString(); - if (!lbl.empty()) { - openLabelTag(xs, style); - xs << lbl; - closeLabelTag(xs, style); - } else { - // No new line after closeLabelTag. - xs << xml::CR(); - } - } - } else { // some kind of list - if (style.labeltype == LABEL_MANUAL) { - // Only variablelist gets here. - - openLabelTag(xs, style); - sep = par->firstWordDocBook(xs, runparams); - closeLabelTag(xs, style); - } else { - openLabelTag(xs, style); - xs << par->params().labelString(); - closeLabelTag(xs, style); - } - } - } // end label output - - // Start generating the item. - bool wasInParagraph = runparams.docbook_in_par; - openItemTag(xs, style); - bool getsIntoParagraph = openInnerItemTag(xs, style); - OutputParams rp = runparams; - rp.docbook_in_par = wasInParagraph | getsIntoParagraph; - - // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph - // AND if the next paragraph doesn't have the same depth (if there is such a paragraph). - // Common case: there is only the first word on the line, but there is a nested list instead - // of more text. - bool emptyItem = false; - if (sep == par->size()) { - auto next_par = par; - ++next_par; - if (next_par == text.paragraphs().end()) // There is no next paragraph. - emptyItem = true; - else // There is a next paragraph: check depth. - emptyItem = par->params().depth() >= next_par->params().depth(); - } - - if (emptyItem) { - // Avoid having an empty item, this is not valid DocBook. A single character is enough to force - // generation of a full . - xs << ' '; - } else { - // Generate the rest of the paragraph, if need be. - par->simpleDocBookOnePar(buf, xs, rp, text.outerFont(distance(begin, par)), true, true, sep); - } - - ++par; - if (getsIntoParagraph) - closeInnerItemTag(xs, style); - - // We may not want to close the tag yet, in particular: - // If we're not at the end of the item... - if (par != pend - // and are doing items... - && !isNormalEnv(style) - // and if the depth has changed... - && par->params().depth() != origdepth) { - // then we'll save this layout for later, and close it when - // we get another item. - lastlay = &style; - } else { - closeItemTag(xs, style); - - // Eventually, close the item wrapper. - if (style.docbookitemwrappertag() != "NONE") { - xs << xml::EndTag(style.docbookitemwrappertag()); - xs << xml::CR(); - } - } - } - // The other possibility is that the depth has increased. - else { - send = findEndOfEnvironment(par, pend); - par = makeEnvironment(buf, xs, runparams, text, par, send); - } - break; - } - case LATEX_PARAGRAPH: -// send = findLast(par, pend, LATEX_PARAGRAPH); - par = makeParagraphs(buf, xs, runparams, text, par, parnext); - break; - case LATEX_BIB_ENVIRONMENT: -// send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); - makeParagraphBibliography(buf, xs, runparams, text, par, parnext); - break; - case LATEX_COMMAND: - par = parnext; - break; - } - } - - if (lastlay != nullptr) { - closeItemTag(xs, *lastlay); - if (lastlay->docbookitemwrappertag() != "NONE") { - xs << xml::EndTag(lastlay->docbookitemwrappertag()); + // Generate the contents of this environment. There is a special case if this is like some environment. + Layout const & style = par->layout(); + if (style.latextype == LATEX_COMMAND) { + // Nothing to do (otherwise, infinite loops). + } else if (style.latextype == LATEX_ENVIRONMENT || + style.latextype == LATEX_LIST_ENVIRONMENT || + style.latextype == LATEX_ITEM_ENVIRONMENT) { + // Open a wrapper tag if needed. + if (style.docbookitemwrappertag() != "NONE") { + xs << xml::StartTag(style.docbookitemwrappertag(), style.docbookitemwrapperattr()); xs << xml::CR(); } + + // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first + // character after the label. + pos_type sep = 0; + if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") { + // At least one condition must be met: + // - this environment is not a list + // - if this is a list, the label must not be manual (i.e. it must be taken from the layout) + if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) { + // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. + docstring const lbl = par->params().labelString(); + + if (lbl.empty()) { + xs << xml::CR(); + } else { + openLabelTag(xs, style); + xs << lbl; + closeLabelTag(xs, style); + } + } else { + // Only variablelist gets here (or similar items defined as an extension in the layout). + openLabelTag(xs, style); + sep = par->firstWordDocBook(xs, runparams); + closeLabelTag(xs, style); + } + } + + // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph + // AND if the next paragraph doesn't have the same depth (if there is such a paragraph). + // Common case: there is only the first word on the line, but there is a nested list instead + // of more text. + bool emptyItem = false; + if (sep == par->size()) { // If the separator is already at the end of this paragraph... + auto next_par = par; + ++next_par; + if (next_par == text.paragraphs().end()) // There is no next paragraph. + emptyItem = true; + else // There is a next paragraph: check depth. + emptyItem = par->params().depth() >= next_par->params().depth(); + } + + if (emptyItem) { + // Avoid having an empty item, this is not valid DocBook. A single character is enough to force + // generation of a full . + // TODO: this always worked only by magic... + xs << ' '; + } else { + // Generate the rest of the paragraph, if need be. + par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), + true, true, sep); + } + } else { + makeAny(text, buf, xs, runparams, par); } -// auto nextpar = par; -// ++nextpar; - closeTag(xs, &*prevpar, &*par); -// closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); - xs << xml::CR(); - return pend; + + // Close the environment. + auto nextpar = par; + ++nextpar; + closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block? } @@ -744,117 +646,48 @@ void makeCommand( XMLStream & xs, OutputParams const & runparams, Text const & text, - ParagraphList::const_iterator const & pbegin) + ParagraphList::const_iterator const & par) { - // No need for labels, as they are handled by DocBook tags. + // Unlike XHTML, no need for labels, as they are handled by DocBook tags. auto const begin = text.paragraphs().begin(); auto const end = text.paragraphs().end(); - auto nextpar = pbegin; + auto nextpar = par; ++nextpar; - // Find the previous paragraph. - auto prevpar = begin; - if (prevpar != pbegin) { - auto prevpar_next = prevpar; - ++prevpar_next; - - while (prevpar_next != pbegin) { - ++prevpar_next; - ++prevpar; - } - } - // Generate this command. - openParTag(xs, &*pbegin, &*prevpar); + auto prevpar = text.paragraphs().getParagraphBefore(par); + openParTag(xs, &*par, prevpar); - pbegin->simpleDocBookOnePar(buf, xs, runparams, - text.outerFont(distance(begin, pbegin))); + par->simpleDocBookOnePar(buf, xs, runparams, + text.outerFont(distance(begin, par))); - closeTag(xs, &*pbegin, (nextpar != end) ? &*nextpar : nullptr); - xs << xml::CR(); + closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); } -pair makeAny( - Text const &text, - Buffer const &buf, - XMLStream &xs, - OutputParams const &ourparams, - ParagraphList::const_iterator par, - ParagraphList::const_iterator send, - ParagraphList::const_iterator pend) -{ - switch (par->layout().latextype) { - case LATEX_COMMAND: { - // The files with which we are working never have more than - // one paragraph in a command structure. - // FIXME - // if (ourparams.docbook_in_par) - // fix it so we don't get sections inside standard, e.g. - // note that we may then need to make runparams not const, so we - // can communicate that back. - // FIXME Maybe this fix should be in the routines themselves, in case - // they are called from elsewhere. - makeCommand(buf, xs, ourparams, text, par); - ++par; - break; - } - case LATEX_ENVIRONMENT: - case LATEX_LIST_ENVIRONMENT: - case LATEX_ITEM_ENVIRONMENT: - // FIXME Same fix here. - send = findEndOfEnvironment(par, pend); - par = makeEnvironment(buf, xs, ourparams, text, par, send); - break; - case LATEX_PARAGRAPH: - send = findLast(par, pend, LATEX_PARAGRAPH); - par = makeParagraphs(buf, xs, ourparams, text, par, send); - break; - case LATEX_BIB_ENVIRONMENT: - send = findLast(par, pend, LATEX_BIB_ENVIRONMENT); - par = makeParagraphBibliography(buf, xs, ourparams, text, par, send); - break; - } - return make_pair(par, send); -} - -ParagraphList::const_iterator makeAnySimple( +void makeAny( Text const &text, Buffer const &buf, XMLStream &xs, OutputParams const &ourparams, ParagraphList::const_iterator par) { - auto parnext = par; - ++parnext; - switch (par->layout().latextype) { - case LATEX_COMMAND: { - // The files with which we are working never have more than - // one paragraph in a command structure. - // FIXME - // if (ourparams.docbook_in_par) - // fix it so we don't get sections inside standard, e.g. - // note that we may then need to make runparams not const, so we - // can communicate that back. - // FIXME Maybe this fix should be in the routines themselves, in case - // they are called from elsewhere. + case LATEX_COMMAND: makeCommand(buf, xs, ourparams, text, par); - return parnext; - } + break; case LATEX_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: - // FIXME Same fix here. - return makeEnvironment(buf, xs, ourparams, text, par, parnext); + makeEnvironment(buf, xs, ourparams, text, par); + break; case LATEX_PARAGRAPH: - return makeParagraphs(buf, xs, ourparams, text, par, parnext); + makeParagraph(buf, xs, ourparams, text, par); + break; case LATEX_BIB_ENVIRONMENT: - return makeParagraphBibliography(buf, xs, ourparams, text, par, parnext); + makeParagraphBibliography(buf, xs, ourparams, text, par); + break; } - - // This should never happen. Return the next paragraph to avoid an infinite loop. - return parnext; } } // end anonymous namespace @@ -885,9 +718,8 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, Layout const &style = paragraphs[bpit].layout(); documentHasSections |= style.category() == from_utf8("Sectioning"); - if (documentHasSections) { + if (documentHasSections) break; - } bpit += 1; } // Paragraphs before the first section: [ runparams.par_begin ; eppit ) @@ -898,7 +730,10 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, bool hasOnlyNotes(Paragraph const & par) { + // Precondition: the paragraph is not empty. Otherwise, the function will always return true... for (int i = 0; i < par.size(); ++i) + // If you find something that is not an inset (like actual text) or an inset that is not a note, + // return false. if (!par.isInset(i) || !dynamic_cast(par.insetList().get(i))) return false; return true; @@ -994,37 +829,6 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b } -pit_type generateDocBookParagraphWithoutSectioning( - Text const & text, - Buffer const & buf, - XMLStream & xs, - OutputParams const & runparams, - ParagraphList const & paragraphs, - DocBookInfoTag const & info) -{ - auto bpit = info.bpit; - auto par = paragraphs.iterator_at(bpit); - auto lastStartedPar = par; - ParagraphList::const_iterator send; - auto const pend = - (info.epit == (int) paragraphs.size()) ? - paragraphs.end() : paragraphs.iterator_at(info.epit); - - while (bpit < info.epit) { - if (info.abstract.find(bpit) != info.abstract.end()) { - bpit += 1; - continue; - } - - tie(par, send) = makeAny(text, buf, xs, runparams, par, send, pend); - bpit += distance(lastStartedPar, par); - lastStartedPar = par; - } - - return bpit; -} - - void outputDocBookInfo( Text const & text, Buffer const & buf, @@ -1040,6 +844,7 @@ void outputDocBookInfo( bool hasAbstract = !info.abstract.empty(); docstring abstract; if (hasAbstract) { + // Generate the abstract XML into a string before further checks. odocstringstream os2; { XMLStream xs2(os2); @@ -1048,8 +853,7 @@ void outputDocBookInfo( // info.abstract is inclusive, epit is exclusive, hence +1 for looping. while (bpit < epit) { - makeAnySimple(text, buf, xs2, runparams, paragraphs.iterator_at(bpit)); - xs2 << XMLStream::ESCAPE_NONE << from_ascii(""); + makeAny(text, buf, xs2, runparams, paragraphs.iterator_at(bpit)); bpit += 1; } } @@ -1065,7 +869,7 @@ void outputDocBookInfo( hasAbstract = false; } - // The abstract must go in . + // The abstract must go in . Otherwise, decide whether to open based on the layouts. bool needInfo = !info.mustBeInInfo.empty() || hasAbstract; // Start the tag if required. @@ -1076,16 +880,17 @@ void outputDocBookInfo( } // Output the elements that should go in , before and after the abstract. - xs << XMLStream::ESCAPE_NONE << ""; - for (auto pit : info.shouldBeInInfo) // Typically, the title: these elements are so important and ubiquitous - // that mandating a wrapper like would repel users. - makeAnySimple(text, buf, xs, runparams, paragraphs.iterator_at(pit)); - xs << XMLStream::ESCAPE_NONE << ""; - for (auto pit : info.mustBeInInfo) + for (auto pit : info.shouldBeInInfo) { // Typically, the title: these elements are so important and ubiquitous + // that mandating a wrapper like would repel users. Thus, generate them first. + makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); + } + for (auto pit : info.mustBeInInfo) { if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after. - makeAnySimple(text, buf, xs, runparams, paragraphs.iterator_at(pit)); - xs << XMLStream::ESCAPE_NONE << ""; + makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); + } + // Always output the abstract as the last item of the , as it requires special treatment (especially if + // it contains several paragraphs that are empty). if (hasAbstract) { // string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); // if (tag == "NONE") @@ -1093,9 +898,7 @@ void outputDocBookInfo( // // xs << xml::StartTag(tag); // xs << xml::CR(); - xs << XMLStream::ESCAPE_NONE << ""; xs << XMLStream::ESCAPE_NONE << abstract; - xs << XMLStream::ESCAPE_NONE << ""; // xs << xml::EndTag(tag); // xs << xml::CR(); } @@ -1147,7 +950,7 @@ void docbookSimpleAllParagraphs( while (bpit < epit) { auto par = paragraphs.iterator_at(bpit); if (!hasOnlyNotes(*par)) - makeAnySimple(text, buf, xs, runparams, par); + makeAny(text, buf, xs, runparams, par); bpit += 1; } } @@ -1170,9 +973,6 @@ void docbookParagraphs(Text const &text, return; }); - ParagraphList::const_iterator const pend = - (epit == (int) paragraphs.size()) ? - paragraphs.end() : paragraphs.iterator_at(epit); std::stack> headerLevels; // Used to determine when to open/close sections: store the depth // of the section and the tag that was used to open it. @@ -1203,8 +1003,7 @@ void docbookParagraphs(Text const &text, ParagraphList::const_iterator send; if (hasOnlyNotes(*par)) { - ++par; - bpit += distance(lastStartedPar, par); + bpit += 1; continue; } @@ -1283,8 +1082,8 @@ void docbookParagraphs(Text const &text, } // Generate this paragraph. - tie(par, send) = makeAny(text, buf, xs, ourparams, par, send, pend); - bpit += distance(lastStartedPar, par); + makeAny(text, buf, xs, ourparams, par); + bpit += 1; } // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning diff --git a/src/xml.cpp b/src/xml.cpp index e16a7840b6..147eaddbb9 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -200,7 +200,7 @@ bool XMLStream::closeFontTags() tag_stack_.pop_back(); // this shouldn't happen, since then the font tags // weren't in any other tag. -// LASSERT(!tag_stack_.empty(), return true); + LASSERT(!tag_stack_.empty(), return true); if (tag_stack_.empty()) return true; curtag = &tag_stack_.back(); @@ -583,62 +583,57 @@ docstring xml::uniqueID(docstring const & label) docstring xml::cleanID(docstring const & orig) { - // The standard xml:id only allows letters, - // digits, '-' and '.' in a name. - // This routine replaces illegal characters by '-' or '.' - // and adds a number for uniqueness if need be. - docstring const allowed = from_ascii(".-_"); + // The standard xml:id only allows letters, digits, '-' and '.' in a name. + // This routine replaces illegal characters by '-' or '.' and adds a number for uniqueness if need be. // Use a cache of already mangled names: the alterations may merge several IDs as one. This ensures that the IDs // are not mixed up in the document. + // This code could be improved: it uses Qt outside the GUI part. Any TLS implementation could do the trick. typedef map MangledMap; static QThreadStorage tMangledNames; static QThreadStorage tMangleID; - MangledMap & mangledNames = tMangledNames.localData(); - // If the name is already known, just return it. - MangledMap::const_iterator const known = mangledNames.find(orig); + MangledMap & mangledNames = tMangledNames.localData(); + auto const known = mangledNames.find(orig); if (known != mangledNames.end()) return known->second; // Start creating the mangled name by iterating over the characters. docstring content; - docstring::const_iterator it = orig.begin(); - docstring::const_iterator end = orig.end(); + auto it = orig.cbegin(); + auto end = orig.cend(); // Make sure it starts with a letter. - if (!isAlphaASCII(*it) && allowed.find(*it) >= allowed.size()) + if (!isAlphaASCII(*it)) content += "x"; - // Do the mangling. + // Parse the ID character by character and change what needs to. bool mangle = false; // Indicates whether the ID had to be changed, i.e. if ID no more ensured to be unique. for (; it != end; ++it) { char_type c = *it; - if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.' - || allowed.find(c) < allowed.size()) + if (isAlphaASCII(c) || isDigitASCII(c) || c == '-' || c == '.' || c == '_') { content += c; - else if (c == '_' || c == ' ') { - mangle = true; - content += "-"; - } - else if (c == ':' || c == ',' || c == ';' || c == '!') { + } else if (c == ':' || c == ',' || c == ';' || c == '!') { mangle = true; content += "."; - } - else { + } else { // Other invalid characters, such as ' '. mangle = true; content += "-"; } } - if (mangle) { + // If there had to be a change, check if ID unicity is still guaranteed. + // This avoids having a clash if satisfying XML requirements for ID makes two IDs identical, like "a:b" and "a!b", + // as both of them would be transformed as "a.b". With this procedure, one will become "a.b" and the other "a.b-1". + if (mangle && mangledNames.find(content) != mangledNames.end()) { int & mangleID = tMangleID.localData(); - content += "-" + convert(mangleID++); + content += "-" + convert(mangleID); + mangleID += 1; } + // Save the new ID to avoid recomputing it afterwards and to ensure stability over the document. mangledNames[orig] = content; - return content; } From 6998e76495d4dedbc5dc11db8e0cf39b590fd674 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 17 Aug 2020 23:06:26 +0200 Subject: [PATCH 13/88] DocBook: define new arguments in layouts to configure new-line behaviour. --- lib/scripts/layout2layout.py | 7 +- src/Floating.cpp | 35 ++++++--- src/Floating.h | 13 +++- src/Layout.cpp | 147 ++++++++++++++++++++++++++++++----- src/Layout.h | 26 ++++++- src/TextClass.cpp | 13 +++- 6 files changed, 200 insertions(+), 41 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 2bb62e37c9..7cf2332300 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -11,7 +11,7 @@ # This script will update a .layout file to current format # The latest layout format is also defined in src/TextClass.cpp -currentFormat = 83 +currentFormat = 84 # Incremented to format 4, 6 April 2007, lasgouttes @@ -284,6 +284,11 @@ currentFormat = 83 # Incremented to format 83, 2 August 2020 by dourouc05 # New tags DocBookWrapperMergeWithPrevious and DocBookAbstract +# Incremented to format 84, 17 August 2020 by tcuvelier +# New tags DocBookTagType, DocBookWrapperTagTagType, +# DocBookItemWrapperTagTagType, DocBookItemTagTagType, +# DocBookLabelTag + # Do not forget to document format change in Customization # Manual (section "Declaring a new text class"). diff --git a/src/Floating.cpp b/src/Floating.cpp index ebd1e41c09..d44afc3a73 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -31,8 +31,8 @@ Floating::Floating(string const & type, string const & placement, string const & refPrefix, std::string const & allowedplacement, string const & htmlTag, string const & htmlAttrib, docstring const & htmlStyle, string const & docbookTag, - string const & docbookAttr, string const & required, - bool usesfloat, bool ispredefined, + string const & docbookAttr, string const & docbookTagType, + string const & required, bool usesfloat, bool ispredefined, bool allowswide, bool allowssideways) : floattype_(type), placement_(placement), ext_(ext), within_(within), style_(style), name_(name), listname_(listName), listcommand_(listCmd), @@ -40,7 +40,8 @@ Floating::Floating(string const & type, string const & placement, usesfloatpkg_(usesfloat), ispredefined_(ispredefined), allowswide_(allowswide), allowssideways_(allowssideways), html_tag_(htmlTag), html_attrib_(htmlAttrib), html_style_(htmlStyle), - docbook_tag_(docbookTag), docbook_attr_(docbookAttr) + docbook_tag_(docbookTag), docbook_attr_(docbookAttr), + docbook_tag_type_(docbookTagType) {} @@ -90,20 +91,30 @@ string const & Floating::docbookAttr() const string const & Floating::docbookTag(bool hasTitle) const { - docbook_tag_ = ""; - if (floattype_ == "figure") { - docbook_tag_ = hasTitle ? "figure" : "informalfigure"; - } else if (floattype_ == "table") { - docbook_tag_ = hasTitle ? "table" : "informaltable"; - } else if (floattype_ == "algorithm") { - // TODO: no good translation for now! Figures are the closest match, as they can contain text. - // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. - docbook_tag_ = "figure"; + if (docbook_tag_.empty()) { + docbook_tag_ = ""; + if (floattype_ == "figure") { + docbook_tag_ = hasTitle ? "figure" : "informalfigure"; + } else if (floattype_ == "table") { + docbook_tag_ = hasTitle ? "table" : "informaltable"; + } else if (floattype_ == "algorithm") { + // TODO: no good translation for now! Figures are the closest match, as they can contain text. + // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. + docbook_tag_ = "figure"; + } } return docbook_tag_; } +string const & Floating::docbookTagType() const +{ + if (docbook_tag_type_ != "block" && docbook_tag_type_ != "paragraph" && docbook_tag_type_ != "inline") + docbook_tag_type_ = "block"; + return docbook_tag_type_; +} + + string const & Floating::docbookCaption() const { docbook_caption_ = ""; diff --git a/src/Floating.h b/src/Floating.h index d10694f92b..5cfea080e6 100644 --- a/src/Floating.h +++ b/src/Floating.h @@ -38,8 +38,9 @@ public: std::string const & refPrefix, std::string const & allowedplacement, std::string const & htmlType, std::string const & htmlClass, docstring const & htmlStyle, std::string const & docbookTag, - std::string const & docbookAttr, std::string const & required, - bool usesfloat, bool isprefined, bool allowswide, bool allowssideways); + std::string const & docbookAttr, std::string const & docbookTagType, + std::string const & required, bool usesfloat, bool isprefined, + bool allowswide, bool allowssideways); /// std::string const & floattype() const { return floattype_; } /// @@ -84,6 +85,8 @@ public: /// std::string const & docbookAttr() const; /// + std::string const & docbookTagType() const; + /// std::string const & docbookCaption() const; private: /// @@ -115,9 +118,9 @@ private: /// bool ispredefined_; /// - bool allowswide_; + bool allowswide_; /// - bool allowssideways_; + bool allowssideways_; /// mutable std::string html_tag_; /// @@ -132,6 +135,8 @@ private: mutable std::string docbook_caption_; /// caption tag (mostly, either caption or title) std::string docbook_attr_; + /// DocBook tag type (block, paragraph, inline) + mutable std::string docbook_tag_type_; }; diff --git a/src/Layout.cpp b/src/Layout.cpp index 50475061ed..102410d534 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -106,20 +106,26 @@ enum LayoutTags { LT_HTMLFORCECSS, LT_DOCBOOKTAG, LT_DOCBOOKATTR, + LT_DOCBOOKTAGTYPE, LT_DOCBOOKININFO, LT_DOCBOOKABSTRACT, LT_DOCBOOKWRAPPERTAG, LT_DOCBOOKWRAPPERATTR, + LT_DOCBOOKWRAPPERTAGTYPE, LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS, LT_DOCBOOKSECTIONTAG, LT_DOCBOOKITEMWRAPPERTAG, LT_DOCBOOKITEMWRAPPERATTR, + LT_DOCBOOKITEMWRAPPERTAGTYPE, LT_DOCBOOKITEMTAG, LT_DOCBOOKITEMATTR, + LT_DOCBOOKITEMTAGTYPE, LT_DOCBOOKITEMLABELTAG, LT_DOCBOOKITEMLABELATTR, + LT_DOCBOOKITEMLABELTAGTYPE, LT_DOCBOOKITEMINNERTAG, LT_DOCBOOKITEMINNERATTR, + LT_DOCBOOKITEMINNERTAGTYPE, LT_DOCBOOKFORCEABSTRACTTAG, LT_INPREAMBLE, LT_HTMLTITLE, @@ -223,23 +229,29 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) { "commanddepth", LT_COMMANDDEPTH }, { "copystyle", LT_COPYSTYLE }, { "dependson", LT_DEPENDSON }, - { "docbookabstract", LT_DOCBOOKABSTRACT }, - { "docbookattr", LT_DOCBOOKATTR }, - { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG }, - { "docbookininfo", LT_DOCBOOKININFO }, - { "docbookitemattr", LT_DOCBOOKITEMATTR }, - { "docbookiteminnerattr", LT_DOCBOOKITEMINNERATTR }, - { "docbookiteminnertag", LT_DOCBOOKITEMINNERTAG }, - { "docbookitemlabelattr", LT_DOCBOOKITEMLABELATTR }, - { "docbookitemlabeltag", LT_DOCBOOKITEMLABELTAG }, - { "docbookitemtag", LT_DOCBOOKITEMTAG }, - { "docbookitemwrapperattr", LT_DOCBOOKITEMWRAPPERATTR }, - { "docbookitemwrappertag", LT_DOCBOOKITEMWRAPPERTAG }, - { "docbooksectiontag", LT_DOCBOOKSECTIONTAG }, - { "docbooktag", LT_DOCBOOKTAG }, - { "docbookwrapperattr", LT_DOCBOOKWRAPPERATTR }, + { "docbookabstract", LT_DOCBOOKABSTRACT }, + { "docbookattr", LT_DOCBOOKATTR }, + { "docbookforceabstracttag", LT_DOCBOOKFORCEABSTRACTTAG }, + { "docbookininfo", LT_DOCBOOKININFO }, + { "docbookitemattr", LT_DOCBOOKITEMATTR }, + { "docbookiteminnerattr", LT_DOCBOOKITEMINNERATTR }, + { "docbookiteminnertag", LT_DOCBOOKITEMINNERTAG }, + { "docbookiteminnertagtype", LT_DOCBOOKITEMINNERTAGTYPE }, + { "docbookitemlabelattr", LT_DOCBOOKITEMLABELATTR }, + { "docbookitemlabeltag", LT_DOCBOOKITEMLABELTAG }, + { "docbookitemlabeltagtype", LT_DOCBOOKITEMLABELTAGTYPE }, + { "docbookitemtag", LT_DOCBOOKITEMTAG }, + { "docbookitemtagtype", LT_DOCBOOKITEMTAGTYPE }, + { "docbookitemwrapperattr", LT_DOCBOOKITEMWRAPPERATTR }, + { "docbookitemwrappertag", LT_DOCBOOKITEMWRAPPERTAG }, + { "docbookitemwrappertagtype", LT_DOCBOOKITEMWRAPPERTAGTYPE }, + { "docbooksectiontag", LT_DOCBOOKSECTIONTAG }, + { "docbooktag", LT_DOCBOOKTAG }, + { "docbooktagtype", LT_DOCBOOKTAGTYPE }, + { "docbookwrapperattr", LT_DOCBOOKWRAPPERATTR }, { "docbookwrappermergewithprevious", LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS }, - { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG }, + { "docbookwrappertag", LT_DOCBOOKWRAPPERTAG }, + { "docbookwrappertagtype", LT_DOCBOOKWRAPPERTAGTYPE }, { "end", LT_END }, { "endlabelstring", LT_ENDLABELSTRING }, { "endlabeltype", LT_ENDLABELTYPE }, @@ -733,6 +745,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookattr_; break; + case LT_DOCBOOKTAGTYPE: + lex >> docbooktagtype_; + break; + case LT_DOCBOOKFORCEABSTRACTTAG: lex >> docbookforceabstracttag_; break; @@ -753,6 +769,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookwrapperattr_; break; + case LT_DOCBOOKWRAPPERTAGTYPE: + lex >> docbookwrappertagtype_; + break; + case LT_DOCBOOKWRAPPERMERGEWITHPREVIOUS: lex >> docbookwrappermergewithprevious_; break; @@ -769,6 +789,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookitemwrapperattr_; break; + case LT_DOCBOOKITEMWRAPPERTAGTYPE: + lex >> docbookitemwrappertagtype_; + break; + case LT_DOCBOOKITEMTAG: lex >> docbookitemtag_; break; @@ -777,6 +801,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookitemattr_; break; + case LT_DOCBOOKITEMTAGTYPE: + lex >> docbookitemtagtype_; + break; + case LT_DOCBOOKITEMLABELTAG: lex >> docbookitemlabeltag_; break; @@ -785,6 +813,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookitemlabelattr_; break; + case LT_DOCBOOKITEMLABELTAGTYPE: + lex >> docbookitemlabeltagtype_; + break; + case LT_DOCBOOKITEMINNERTAG: lex >> docbookiteminnertag_; break; @@ -793,6 +825,10 @@ bool Layout::readIgnoreForcelocal(Lexer & lex, TextClass const & tclass) lex >> docbookiteminnerattr_; break; + case LT_DOCBOOKITEMINNERTAGTYPE: + lex >> docbookiteminnertagtype_; + break; + case LT_SPELLCHECK: lex >> spellcheck; break; @@ -1608,6 +1644,8 @@ void Layout::write(ostream & os) const os << "\tDocBookTag " << docbooktag_ << '\n'; if(!docbookattr_.empty()) os << "\tDocBookAttr " << docbookattr_ << '\n'; + if(!docbooktagtype_.empty()) + os << "\tDocBookTagType " << docbooktagtype_ << '\n'; if(!docbookininfo_.empty()) os << "\tDocBookInInfo " << docbookininfo_ << '\n'; os << "\tDocBookAbstract " << docbookabstract_ << '\n'; @@ -1615,25 +1653,35 @@ void Layout::write(ostream & os) const os << "\tDocBookWrapperTag " << docbookwrappertag_ << '\n'; if(!docbookwrapperattr_.empty()) os << "\tDocBookWrapperAttr " << docbookwrapperattr_ << '\n'; + if(!docbookwrappertagtype_.empty()) + os << "\tDocBookWrapperTagType " << docbookwrappertagtype_ << '\n'; if(!docbooksectiontag_.empty()) os << "\tDocBookSectionTag " << docbooksectiontag_ << '\n'; if(!docbookitemtag_.empty()) os << "\tDocBookItemTag " << docbookitemtag_ << '\n'; if(!docbookitemattr_.empty()) os << "\tDocBookItemAttr " << docbookitemattr_ << '\n'; + if(!docbookitemtagtype_.empty()) + os << "\tDocBookItemTagType " << docbookitemtagtype_ << '\n'; if(!docbookitemwrappertag_.empty()) os << "\tDocBookItemWrapperTag " << docbookitemwrappertag_ << '\n'; if(!docbookitemwrapperattr_.empty()) os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n'; + if(!docbookitemwrappertagtype_.empty()) + os << "\tDocBookItemWrapperTagType " << docbookitemwrappertagtype_ << '\n'; os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n'; if(!docbookitemlabeltag_.empty()) os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n'; if(!docbookitemlabelattr_.empty()) os << "\tDocBookItemLabelAttr " << docbookitemlabelattr_ << '\n'; + if(!docbookitemlabeltagtype_.empty()) + os << "\tDocBookItemLabelTagType " << docbookitemlabeltagtype_ << '\n'; if(!docbookiteminnertag_.empty()) os << "\tDocBookItemInnerTag " << docbookiteminnertag_ << '\n'; if(!docbookiteminnerattr_.empty()) os << "\tDocBookItemInnerAttr " << docbookiteminnerattr_ << '\n'; + if(!docbookiteminnertagtype_.empty()) + os << "\tDocBookItemInnerTagType " << docbookiteminnertagtype_ << '\n'; if(!docbookforceabstracttag_.empty()) os << "\tDocBookForceAbstractTag " << docbookforceabstracttag_ << '\n'; os << "\tSpellcheck " << spellcheck << "\n" @@ -1786,9 +1834,12 @@ string Layout::defaultCSSClass() const string const & Layout::docbooktag() const { - // No sensible default value, unhappily... - if (docbooktag_.empty()) - docbooktag_ = to_utf8(name_); + if (docbooktag_.empty()) { + if (to_ascii(name_) == "Plain Layout") + docbooktag_ = "para"; + else // No sensible default value, unhappily... + docbooktag_ = to_utf8(name_); + } return docbooktag_; } @@ -1800,6 +1851,20 @@ string const & Layout::docbookattr() const } +bool isValidTagType(std::string type) +{ + return !(type.empty() || (type != "block" && type != "paragraph" && type != "inline")); +} + + +string const & Layout::docbooktagtype() const +{ + if (!isValidTagType(docbooktagtype_)) + docbooktagtype_ = "block"; + return docbooktagtype_; +} + + string const & Layout::docbookininfo() const { // Indeed, a trilean. Only titles should be "maybe": otherwise, metadata is "always", content is "never". @@ -1823,6 +1888,14 @@ string const & Layout::docbookwrapperattr() const } +string const & Layout::docbookwrappertagtype() const +{ + if (!isValidTagType(docbookwrappertagtype_)) + docbookwrappertagtype_ = "block"; + return docbookwrappertagtype_; +} + + string const & Layout::docbooksectiontag() const { if (docbooksectiontag_.empty()) @@ -1845,9 +1918,19 @@ string const & Layout::docbookitemwrapperattr() const } +string const & Layout::docbookitemwrappertagtype() const +{ + if (!isValidTagType(docbookitemwrappertagtype_)) + docbookitemwrappertagtype_ = "block"; + return docbookitemwrappertagtype_; +} + + string const & Layout::docbookitemtag() const { - return docbookitemtag_; + if (docbookitemtag_.empty()) + docbookitemtag_ = "NONE"; + return docbookitemtag_; } @@ -1857,6 +1940,14 @@ string const & Layout::docbookitemattr() const } +string const & Layout::docbookitemtagtype() const +{ + if (!isValidTagType(docbookitemtagtype_)) + docbookitemtagtype_ = "block"; + return docbookitemtagtype_; +} + + string const & Layout::docbookitemlabeltag() const { if (docbookitemlabeltag_.empty()) @@ -1871,6 +1962,14 @@ string const & Layout::docbookitemlabelattr() const } +string const & Layout::docbookitemlabeltagtype() const +{ + if (!isValidTagType(docbookitemlabeltagtype_)) + docbookitemlabeltagtype_ = "block"; + return docbookitemlabeltagtype_; +} + + string const & Layout::docbookiteminnertag() const { if (docbookiteminnertag_.empty()) @@ -1885,6 +1984,14 @@ string const & Layout::docbookiteminnerattr() const } +string const & Layout::docbookiteminnertagtype() const +{ + if (!isValidTagType(docbookiteminnertagtype_)) + docbookiteminnertagtype_ = "block"; + return docbookiteminnertagtype_; +} + + std::string const & Layout::docbookforceabstracttag() const { if (docbookforceabstracttag_.empty()) diff --git a/src/Layout.h b/src/Layout.h index a894142a97..14784a27d2 100644 --- a/src/Layout.h +++ b/src/Layout.h @@ -197,6 +197,8 @@ public: /// std::string const & docbookattr() const; /// + std::string const & docbooktagtype() const; + /// std::string const & docbookininfo() const; /// bool docbookabstract() const { return docbookabstract_; } @@ -205,6 +207,8 @@ public: /// std::string const & docbookwrapperattr() const; /// + std::string const & docbookwrappertagtype() const; + /// bool docbookwrappermergewithprevious() const { return docbookwrappermergewithprevious_; } /// std::string const & docbooksectiontag() const; @@ -213,18 +217,26 @@ public: /// std::string const & docbookitemwrapperattr() const; /// + std::string const & docbookitemwrappertagtype() const; + /// std::string const & docbookitemlabeltag() const; /// std::string const & docbookitemlabelattr() const; /// + std::string const & docbookitemlabeltagtype() const; + /// std::string const & docbookiteminnertag() const; /// std::string const & docbookiteminnerattr() const; /// + std::string const & docbookiteminnertagtype() const; + /// std::string const & docbookitemtag() const; /// std::string const & docbookitemattr() const; /// + std::string const & docbookitemtagtype() const; + /// std::string const & docbookforceabstracttag() const; /// bool isParagraph() const { return latextype == LATEX_PARAGRAPH; } @@ -495,27 +507,39 @@ private: mutable std::string docbooktag_; /// Roles to add to docbooktag_, if any (default: none). mutable std::string docbookattr_; + /// DocBook tag type corresponding to this layout (block, paragraph, or inline; default: block). + mutable std::string docbooktagtype_; /// DocBook tag corresponding to this item (mainly for lists). mutable std::string docbookitemtag_; /// Roles to add to docbookitemtag_, if any (default: none). mutable std::string docbookitemattr_; + /// DocBook tag type corresponding to this item (block, paragraph, or inline; default: block). + mutable std::string docbookitemtagtype_; /// DocBook tag corresponding to the wrapper around an item (mainly for lists). mutable std::string docbookitemwrappertag_; /// Roles to add to docbookitemwrappertag_, if any (default: none). mutable std::string docbookitemwrapperattr_; - /// DocBook tag corresponding to this label (only for description lists; + /// DocBook tag type corresponding to the wrapper around an item (block, paragraph, or inline; default: block). + mutable std::string docbookitemwrappertagtype_; + /// DocBook tag corresponding to this label (mostly for description lists; /// labels in the common sense do not exist with DocBook). mutable std::string docbookitemlabeltag_; /// Roles to add to docbooklabeltag_, if any (default: none). mutable std::string docbookitemlabelattr_; + /// DocBook tag corresponding to this label (block, paragraph, or inline; default: block). + mutable std::string docbookitemlabeltagtype_; /// DocBook tag to add within the item, around its direct content (mainly for lists). mutable std::string docbookiteminnertag_; /// Roles to add to docbookiteminnertag_, if any (default: none). mutable std::string docbookiteminnerattr_; + /// DocBook tag to add within the item, around its direct content (block, paragraph, or inline; default: block). + mutable std::string docbookiteminnertagtype_; /// DocBook tag corresponding to this wrapper around the main tag. mutable std::string docbookwrappertag_; /// Roles to add to docbookwrappertag_, if any (default: none). mutable std::string docbookwrapperattr_; + /// DocBook tag corresponding to this wrapper around the main tag (block, paragraph, or inline; default: block). + mutable std::string docbookwrappertagtype_; /// Whether this wrapper tag may be merged with the previously opened wrapper tag. bool docbookwrappermergewithprevious_; /// Outer tag for this section, only if this layout represent a sectionning item, including chapters diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 469cfafff4..900d6b2634 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -62,7 +62,7 @@ namespace lyx { // You should also run the development/tools/updatelayouts.py script, // to update the format of all of our layout files. // -int const LAYOUT_FORMAT = 83; // tcuvelier: DocBookWrapperMergeWithPrevious. +int const LAYOUT_FORMAT = 84; // tcuvelier: DocBook*TagType. // Layout format for the current lyx file format. Controls which format is @@ -1378,6 +1378,7 @@ bool TextClass::readFloat(Lexer & lexrc) FT_HTMLTAG, FT_DOCBOOKATTR, FT_DOCBOOKTAG, + FT_DOCBOOKTAGTYPE, FT_LISTCOMMAND, FT_REFPREFIX, FT_ALLOWED_PLACEMENT, @@ -1393,6 +1394,7 @@ bool TextClass::readFloat(Lexer & lexrc) { "allowswide", FT_ALLOWS_WIDE }, { "docbookattr", FT_DOCBOOKATTR }, { "docbooktag", FT_DOCBOOKTAG }, + { "docbooktagtype", FT_DOCBOOKTAGTYPE }, { "end", FT_END }, { "extension", FT_EXT }, { "guiname", FT_NAME }, @@ -1419,6 +1421,7 @@ bool TextClass::readFloat(Lexer & lexrc) string htmltag; string docbookattr; string docbooktag; + string docbooktagtype; string listname; string listcommand; string name; @@ -1540,6 +1543,10 @@ bool TextClass::readFloat(Lexer & lexrc) lexrc.next(); docbooktag = lexrc.getString(); break; + case FT_DOCBOOKTAGTYPE: + lexrc.next(); + docbooktagtype = lexrc.getString(); + break; case FT_END: getout = true; break; @@ -1568,8 +1575,8 @@ bool TextClass::readFloat(Lexer & lexrc) Floating fl(type, placement, ext, within, style, name, listname, listcommand, refprefix, allowed_placement, htmltag, htmlattr, htmlstyle, docbooktag, docbookattr, - required, usesfloat, ispredefined, allowswide, - allowssideways); + docbooktagtype, required, usesfloat, ispredefined, + allowswide, allowssideways); floatlist_.newFloat(fl); // each float has its own counter counters_.newCounter(from_ascii(type), from_ascii(within), From 360139a0911415a9ce31137aedef760714f6e189 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 17 Aug 2020 23:35:40 +0200 Subject: [PATCH 14/88] DocBook: documentation for the new tags. --- lib/doc/Customization.lyx | 649 +++++++++++++++++++++++++++++++++- lib/generate_contributions.py | 2 +- 2 files changed, 645 insertions(+), 6 deletions(-) diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index 541e562ce0..d6f5f1744b 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -27208,13 +27208,24 @@ Labels are rarely output, as they are redundant in DocBook: this information \begin_layout Subsection -\change_inserted -970929547 1496610966 +\change_inserted 1075283030 1597699417 +\begin_inset CommandInset label +LatexCommand label +name "subsec:Paragraph-Style-DocBook" + +\end_inset + + +\change_deleted 1075283030 1597699417 + \begin_inset CommandInset label LatexCommand label name "subsec:Paragraph-Style-XHTML-1" \end_inset + +\change_inserted -970929547 1496610966 Paragraph styles \end_layout @@ -27454,6 +27465,252 @@ tag in the example above. The default is the name of the float and always needs to be changed, as DocBook provides no generic tag. +\change_inserted 1075283030 1597698868 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699399 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597698872 +DocBookTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597700585 +block, paragraph, inline +\change_unchanged + +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + +\change_unchanged + +\end_layout + +\begin_layout Subsection + +\change_inserted 1075283030 1597699385 +New-line policy +\begin_inset CommandInset label +LatexCommand label +name "subsec:DocBook-New-line-policy" + +\end_inset + + +\end_layout + +\begin_layout Standard + +\change_inserted 1075283030 1597698993 +For all tags, there are three possible policies for outputting new lines + (given in the +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597698987 +DocBook*TagType +\end_layout + +\end_inset + + attribute): +\end_layout + +\begin_layout Itemize + +\change_inserted 1075283030 1597699279 +\begin_inset Quotes eld +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699012 +block +\end_layout + +\end_inset + + +\begin_inset Quotes erd +\end_inset + +: the opening and closing tags are on their own lines (i.e. + a line feed after and before the opening and the closing tags). + Typical elements are floats. + For instance: +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699194 +Content before +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699194 + +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699098 + Contents of the block. +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699196 + +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699198 +Content after +\end_layout + +\begin_layout Itemize + +\change_inserted 1075283030 1597699289 +\begin_inset Quotes eld +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699113 +paragraph +\end_layout + +\end_inset + + +\begin_inset Quotes erd +\end_inset + +: the opening and closing tags are on the same, new line; a line feed is + output before the opening tag and after the closing tag. + Typical elements are paragraphs and list items. + For instance: +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699186 +Content before +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699357 +Contents of the paragraph. +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699231 +Content after +\end_layout + +\begin_layout Itemize + +\change_inserted 1075283030 1597699343 +\begin_inset Quotes eld +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699307 +inline +\end_layout + +\end_inset + + +\begin_inset Quotes erd +\end_inset + +: the opening and closing tags are on the same line as the rest of the content. + No line feeds are output. + Typical elements are fonts. + For instance: +\end_layout + +\begin_layout LyX-Code + +\change_inserted 1075283030 1597699585 +Content beforeContents of the paragraph.Content after +\end_layout + +\begin_layout Standard + +\change_inserted 1075283030 1597699585 +The default value is always +\begin_inset Quotes eld +\end_inset + + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699585 +block +\end_layout + +\end_inset + + +\begin_inset Quotes erd +\end_inset + +. \change_unchanged \end_layout @@ -28158,6 +28415,52 @@ NONE This parameter only makes sense when itemising layouts are used, such as lists. +\change_inserted 1075283030 1597699848 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699866 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699853 +DocBookItemInnerTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699866 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + \change_unchanged \end_layout @@ -28277,6 +28580,52 @@ itemlabeltag This parameter only makes sense when itemising layouts are used with a notion of labels, such as definition lists. +\change_inserted 1075283030 1597699874 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699874 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699880 +DocBookItemLabelTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699874 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + \change_unchanged \end_layout @@ -28352,6 +28701,54 @@ NONE This parameter only makes sense when itemising layouts are used, such as lists. +\change_inserted 1075283030 1597699890 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699890 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699890 +DocBookItemTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699890 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + +\change_unchanged + \end_layout \begin_layout Description @@ -28487,6 +28884,52 @@ NONE This parameter only makes sense when itemising layouts are used, such as lists. +\change_inserted 1075283030 1597699897 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699897 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699900 +DocBookItemWrapperTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699897 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + \change_unchanged \end_layout @@ -28618,6 +29061,54 @@ NONE , indicating that there is no inner tag: content is directly output without it. +\change_inserted 1075283030 1597699904 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699904 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699904 +DocBookInnerTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699904 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + +\change_unchanged + \end_layout \begin_layout Description @@ -28668,7 +29159,11 @@ section \end_inset , and is only overridden when DocBook uses something else for sectioning - (parts and chapters of a book). + ( +\change_inserted 1075283030 1597699921 +typically, +\change_inserted -970929547 1515110753 +parts and chapters of a book). \change_unchanged @@ -28729,6 +29224,54 @@ tag in the example above. The default is the name of the float and always needs to be changed, as DocBook provides no generic inset tag. +\change_inserted 1075283030 1597699924 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699924 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699924 +DocBookTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699924 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + +\change_unchanged + \end_layout \begin_layout Description @@ -28858,7 +29401,53 @@ NONE , indicating that there is no wrapper tag: tag and content are directly output without it. -\change_deleted -970929547 1515111523 +\change_inserted 1075283030 1597699929 + +\end_layout + +\begin_layout Description + +\change_inserted 1075283030 1597699929 +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699932 +DocBookWrapperTagType +\end_layout + +\end_inset + + [ +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597699929 +block, paragraph, inline +\end_layout + +\end_inset + +] The new-line policy for this tag, see Section +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:DocBook-New-line-policy" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for the details. + +\change_unchanged \end_layout @@ -29024,9 +29613,59 @@ Bibliography formatting \begin_layout Standard +\change_deleted 1075283030 1597699984 +The +\change_inserted 1075283030 1597699985 +Included \change_inserted -970929547 1515110187 -The bibliography cannot be formatted: all fields are always output in the - database-like DocBook format (equivalent to a BibTeX file). +bibliograph +\change_deleted 1075283030 1597699987 +y +\change_inserted 1075283030 1597699987 +ies +\change_inserted -970929547 1515110187 + cannot be formatted: all fields are always output in the database-like + DocBook format (equivalent to a BibTeX file) +\change_inserted 1075283030 1597700117 +, using the +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597700120 +biblioentry +\end_layout + +\end_inset + + tag +\change_inserted -970929547 1515110187 +. +\change_inserted 1075283030 1597700092 + +\end_layout + +\begin_layout Standard + +\change_inserted 1075283030 1597700112 +When the bibliographic entries are manually inserted into the LyX document + as Bibliography Items, the user deals with formatting themself: there is + no attempt of parsing what the user wrote, the string is directly used + (with the +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1597700076 +bibliomixed +\end_layout + +\end_inset + + tag). + \change_unchanged \end_layout diff --git a/lib/generate_contributions.py b/lib/generate_contributions.py index 4e3e1911a0..e864ebd062 100755 --- a/lib/generate_contributions.py +++ b/lib/generate_contributions.py @@ -650,7 +650,7 @@ contributors = [ "Re: Patches to improve compatibility with modern C++ standard", "m=158862338815864", "4 May 2020", - u"Windows compatibility patches, Docbook backend"), + u"Windows compatibility patches, DocBook backend"), contributor(u"Matthias Kalle Dalheimer", "kalle () kdab ! net", From 27a44f8e4854807448e827fc473995477ac037e6 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 17 Aug 2020 23:44:02 +0200 Subject: [PATCH 15/88] XML: memorise if the last thing that is getting output is a line feed. --- src/xml.cpp | 13 +++++++++++++ src/xml.h | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/xml.cpp b/src/xml.cpp index 147eaddbb9..b4004af4cb 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -290,6 +290,7 @@ void XMLStream::clearTagDeque() XMLStream &XMLStream::operator<<(docstring const &d) { + is_last_tag_cr_ = false; clearTagDeque(); os_ << xml::escapeString(d, escape_); escape_ = ESCAPE_ALL; @@ -299,6 +300,7 @@ XMLStream &XMLStream::operator<<(docstring const &d) XMLStream &XMLStream::operator<<(const char *s) { + is_last_tag_cr_ = false; clearTagDeque(); docstring const d = from_ascii(s); os_ << xml::escapeString(d, escape_); @@ -309,6 +311,7 @@ XMLStream &XMLStream::operator<<(const char *s) XMLStream &XMLStream::operator<<(char_type c) { + is_last_tag_cr_ = false; clearTagDeque(); os_ << xml::escapeChar(c, escape_); escape_ = ESCAPE_ALL; @@ -318,6 +321,7 @@ XMLStream &XMLStream::operator<<(char_type c) XMLStream &XMLStream::operator<<(char c) { + is_last_tag_cr_ = false; clearTagDeque(); os_ << xml::escapeChar(c, escape_); escape_ = ESCAPE_ALL; @@ -327,6 +331,7 @@ XMLStream &XMLStream::operator<<(char c) XMLStream &XMLStream::operator<<(int i) { + is_last_tag_cr_ = false; clearTagDeque(); os_ << i; escape_ = ESCAPE_ALL; @@ -336,6 +341,7 @@ XMLStream &XMLStream::operator<<(int i) XMLStream &XMLStream::operator<<(EscapeSettings e) { + // Don't update is_last_tag_cr_ here, as this does not output anything. escape_ = e; return *this; } @@ -343,6 +349,7 @@ XMLStream &XMLStream::operator<<(EscapeSettings e) XMLStream &XMLStream::operator<<(xml::StartTag const &tag) { + is_last_tag_cr_ = false; if (tag.tag_.empty()) return *this; pending_tags_.push_back(makeTagPtr(tag)); @@ -354,6 +361,7 @@ XMLStream &XMLStream::operator<<(xml::StartTag const &tag) XMLStream &XMLStream::operator<<(xml::ParTag const &tag) { + is_last_tag_cr_ = false; if (tag.tag_.empty()) return *this; pending_tags_.push_back(makeTagPtr(tag)); @@ -363,6 +371,7 @@ XMLStream &XMLStream::operator<<(xml::ParTag const &tag) XMLStream &XMLStream::operator<<(xml::CompTag const &tag) { + is_last_tag_cr_ = false; if (tag.tag_.empty()) return *this; clearTagDeque(); @@ -373,6 +382,7 @@ XMLStream &XMLStream::operator<<(xml::CompTag const &tag) XMLStream &XMLStream::operator<<(xml::FontTag const &tag) { + is_last_tag_cr_ = false; if (tag.tag_.empty()) return *this; pending_tags_.push_back(makeTagPtr(tag)); @@ -382,6 +392,7 @@ XMLStream &XMLStream::operator<<(xml::FontTag const &tag) XMLStream &XMLStream::operator<<(xml::CR const &) { + is_last_tag_cr_ = true; clearTagDeque(); os_ << from_ascii("\n"); return *this; @@ -434,6 +445,8 @@ bool XMLStream::isTagPending(xml::StartTag const &stag, int maxdepth) const // best to make things work. XMLStream &XMLStream::operator<<(xml::EndTag const &etag) { + is_last_tag_cr_ = false; + if (etag.tag_.empty()) return *this; diff --git a/src/xml.h b/src/xml.h index b585a48a9d..581cca57a8 100644 --- a/src/xml.h +++ b/src/xml.h @@ -39,7 +39,7 @@ struct CR; class XMLStream { public: /// - explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL) {} + explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(false) {} /// odocstream & os() { return os_; } /// @@ -98,6 +98,8 @@ public: bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const; /// bool isTagPending(xml::StartTag const &, int maxdepth = -1) const; + /// + bool isLastTagCR() const { return is_last_tag_cr_; }; private: /// void clearTagDeque(); @@ -126,6 +128,8 @@ private: TagDeque pending_tags_; /// TagDeque tag_stack_; + /// + bool is_last_tag_cr_; public: bool pending_tags_empty() { return pending_tags_.empty();}; }; From 9393ca74ba93b70c2aa610e6c3c2b6aff651eb42 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 00:37:34 +0200 Subject: [PATCH 16/88] DocBook: new logic to handle the new lines, only used in output_docbook for now. --- lib/layouts/stdlayouts.inc | 2 +- lib/layouts/stdlists.inc | 2 +- lib/layouts/stdstruct.inc | 2 +- lib/layouts/stdtitle.inc | 6 +- src/insets/InsetNewline.cpp | 2 +- src/output_docbook.cpp | 231 +++++++++++++++++------------------- src/xml.h | 6 +- 7 files changed, 121 insertions(+), 130 deletions(-) diff --git a/lib/layouts/stdlayouts.inc b/lib/layouts/stdlayouts.inc index 16706956b7..e550518a60 100644 --- a/lib/layouts/stdlayouts.inc +++ b/lib/layouts/stdlayouts.inc @@ -7,7 +7,7 @@ # quotations and such. -Format 82 +Format 84 Style Quotation Category MainText diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc index 16a9e8188f..c0b346dbd1 100644 --- a/lib/layouts/stdlists.inc +++ b/lib/layouts/stdlists.inc @@ -6,7 +6,7 @@ # This include files contains various standard environments for lists. -Format 82 +Format 84 Input stdlyxlist.inc diff --git a/lib/layouts/stdstruct.inc b/lib/layouts/stdstruct.inc index c8b7eb4cbd..2a81117354 100644 --- a/lib/layouts/stdstruct.inc +++ b/lib/layouts/stdstruct.inc @@ -8,7 +8,7 @@ # a document, like abstract, bibliography and such. -Format 82 +Format 84 Style Abstract Margin Static diff --git a/lib/layouts/stdtitle.inc b/lib/layouts/stdtitle.inc index ad989a6767..44b1b8e067 100644 --- a/lib/layouts/stdtitle.inc +++ b/lib/layouts/stdtitle.inc @@ -8,7 +8,7 @@ # a document, like title, author and such. -Format 82 +Format 84 Style Title Margin Static @@ -29,6 +29,7 @@ Style Title HTMLTag h1 HTMLTitle true DocBookTag title + DocBookTagType paragraph DocBookInInfo maybe End @@ -50,7 +51,9 @@ Style Author Size Large EndFont DocBookTag personname + DocBookTagType paragraph DocBookWrapperTag author + DocBookWrapperTagType inline DocBookInInfo always End @@ -72,5 +75,6 @@ Style Date Size Large EndFont DocBookTag date + DocBookTagType paragraph DocBookInInfo always End diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 00b276ea47..7cba0f756a 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -181,7 +181,7 @@ void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const // about the paragraph's layout... Good for now, though, this should not happen in DocBook, only maybe // extensions. xs << XMLStream::ESCAPE_NONE << from_utf8(""); - xs << XMLStream::ESCAPE_NONE << from_utf8("\n\n"); // TODO: that's a hack... // xs << xml::EndTag("para"); // xs << xml::CR(); diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index b29da56c34..b7b59413ad 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -43,8 +43,6 @@ #include #include -// #define DOCBOOK_DEBUG_NEWLINES - using namespace std; using namespace lyx::support; @@ -189,14 +187,100 @@ xml::EndFontTag docbookEndFontTag(xml::FontTypes type) namespace { -// convenience functions +// Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour. +// Block style: +// Content before +// +// Contents of the block. +// +// Content after +// Paragraph style: +// Content before +// Contents of the paragraph. +// Content after +// Inline style: +// Content beforeContents of the paragraph.Content after + +void openInlineTag(XMLStream & xs, const std::string & tag, const std::string & attr) +{ + xs << xml::StartTag(tag, attr); +} + + +void closeInlineTag(XMLStream & xs, const std::string & tag) +{ + xs << xml::EndTag(tag); +} + + +void openParTag(XMLStream & xs, const std::string & tag, const std::string & attr) +{ + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::StartTag(tag, attr); +} + + +void closeParTag(XMLStream & xs, const std::string & tag) +{ + xs << xml::EndTag(tag); + xs << xml::CR(); +} + + +void openBlockTag(XMLStream & xs, const std::string & tag, const std::string & attr) +{ + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::StartTag(tag, attr); + xs << xml::CR(); +} + + +void closeBlockTag(XMLStream & xs, const std::string & tag) +{ + xs << xml::CR(); + xs << xml::EndTag(tag); + xs << xml::CR(); +} + + +void openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype) +{ + if (tag.empty() || tag == "NONE") + return; + + if (tag == "para" || tagtype == "paragraph") // Special case for : always considered as a paragraph. + openParTag(xs, tag, attr); + else if (tagtype == "block") + openBlockTag(xs, tag, attr); + else if (tagtype == "inline") + openInlineTag(xs, tag, attr); + else + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + " " + attr + "'"); +} + + +void closeTag(XMLStream & xs, const std::string & tag, const std::string & tagtype) +{ + if (tag.empty() || tag == "NONE") + return; + + if (tag == "para" || tagtype == "paragraph") // Special case for : always considered as a paragraph. + closeParTag(xs, tag); + else if (tagtype == "block") + closeBlockTag(xs, tag); + else if (tagtype == "inline") + closeInlineTag(xs, tag); + else + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + "'"); +} + + +// Higher-level convenience functions. void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - Layout const & lay = par->layout(); if (par == prevpar) @@ -218,38 +302,25 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar } // Main logic. - if (openWrapper) { - xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); - xs << xml::CR(); - } + if (openWrapper) + openTag(xs, lay.docbookwrappertag(), lay.docbookwrapperattr(), lay.docbookwrappertagtype()); - string tag = lay.docbooktag(); + const string & tag = lay.docbooktag(); if (tag != "NONE") { auto xmltag = xml::ParTag(tag, lay.docbookattr()); - if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph. TODO: required or not? - xs << xmltag; + if (!xs.isTagOpen(xmltag, 1)) // Don't nest a paragraph directly in a paragraph. + // TODO: required or not? + // TODO: avoid creating a ParTag object just for this query... + openTag(xs, lay.docbooktag(), lay.docbookattr(), lay.docbooktagtype()); } - if (lay.docbookitemtag() != "NONE") { - xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); - xs << xml::CR(); - } - - if (lay.docbookiteminnertag() != "NONE") - xs << xml::StartTag(lay.docbookiteminnertag(), lay.docbookiteminnerattr()); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype()); + openTag(xs, lay.docbookiteminnertag(), lay.docbookiteminnerattr(), lay.docbookiteminnertagtype()); } void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - if (par == nextpar) nextpar = nullptr; @@ -265,119 +336,35 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa } // Main logic. - if (lay.docbookiteminnertag() != "NONE") { - xs << xml::EndTag(lay.docbookiteminnertag()); - xs << xml::CR(); - } - - if (lay.docbookitemtag() != "NONE") { - xs << xml::EndTag(lay.docbookitemtag()); - xs << xml::CR(); - } - - if (lay.docbooktag() != "NONE") { - xs << xml::EndTag(lay.docbooktag()); - xs << xml::CR(); - } - - if (closeWrapper) { - xs << xml::EndTag(lay.docbookwrappertag()); - xs << xml::CR(); - } - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif -} - - -void openBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) -{ -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - // Similar as openParTag, but with a line feed after. - openParTag(xs, par, prevpar); - xs << xml::CR(); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif -} - - -void closeBlockTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) -{ -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - // Similar as closeParTag, but with a line feed before. - xs << xml::CR(); - closeParTag(xs, par, prevpar); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + closeTag(xs, lay.docbookiteminnertag(), lay.docbookiteminnertagtype()); + closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype()); + closeTag(xs, lay.docbooktag(), lay.docbooktagtype()); + if (closeWrapper) + closeTag(xs, lay.docbookwrappertag(), lay.docbookwrappertagtype()); } void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists. { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - xs << xml::StartTag(lay.docbookitemlabeltag(), lay.docbookitemlabelattr()); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + openTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabelattr(), lay.docbookitemlabeltagtype()); } void closeLabelTag(XMLStream & xs, Layout const & lay) { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - xs << xml::EndTag(lay.docbookitemlabeltag()); - xs << xml::CR(); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + closeTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabeltagtype()); } void openItemTag(XMLStream & xs, Layout const & lay) { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - xs << xml::StartTag(lay.docbookitemtag(), lay.docbookitemattr()); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype()); } void closeItemTag(XMLStream & xs, Layout const & lay) { -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif - - xs << xml::EndTag(lay.docbookitemtag()); - xs << xml::CR(); - -#ifdef DOCBOOK_DEBUG_NEWLINES - xs << XMLStream::ESCAPE_NONE << ""; -#endif + closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype()); } diff --git a/src/xml.h b/src/xml.h index 581cca57a8..0948143c57 100644 --- a/src/xml.h +++ b/src/xml.h @@ -100,13 +100,13 @@ public: bool isTagPending(xml::StartTag const &, int maxdepth = -1) const; /// bool isLastTagCR() const { return is_last_tag_cr_; }; -private: - /// - void clearTagDeque(); /// void writeError(std::string const &) const; /// void writeError(docstring const &) const; +private: + /// + void clearTagDeque(); /// odocstream & os_; /// From bdea21a87e7b54747ced9f913659e0e2fe6590c6 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 04:56:25 +0200 Subject: [PATCH 17/88] DocBook: improve comments. --- src/xml.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xml.h b/src/xml.h index 0948143c57..69d582d0fd 100644 --- a/src/xml.h +++ b/src/xml.h @@ -39,7 +39,7 @@ struct CR; class XMLStream { public: /// - explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(false) {} + explicit XMLStream(odocstream & os): os_(os), escape_(ESCAPE_ALL), is_last_tag_cr_(true) {} /// odocstream & os() { return os_; } /// @@ -82,7 +82,7 @@ public: enum EscapeSettings { ESCAPE_NONE, ESCAPE_AND, // meaning & - ESCAPE_ALL, // meaning <, >, &, at present + ESCAPE_ALL, // meaning <, >, &, at present, except things that are forbidden in comments ESCAPE_COMMENTS // Anything that is forbidden within comments }; /// Sets what we are going to escape on the NEXT write. @@ -98,7 +98,9 @@ public: bool isTagOpen(xml::EndTag const &, int maxdepth = -1) const; /// bool isTagPending(xml::StartTag const &, int maxdepth = -1) const; - /// + /// Is the last tag that was added to the stream a new line (CR)? This is mostly to known + /// whether a new line must be added. Therefore, consider that an empty stream just had a CR, + /// that simplifies the logic using this code. bool isLastTagCR() const { return is_last_tag_cr_; }; /// void writeError(std::string const &) const; From 25f72d392c60e93f5adb2412d5885a758fa2511a Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 05:37:46 +0200 Subject: [PATCH 18/88] DocBook: fine tuning of new lines. --- src/Buffer.cpp | 11 +++++------ src/output_docbook.cpp | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 82fd0899c4..2ef5768771 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2140,8 +2140,6 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, bool const output_body = output == FullSource || output == OnlyBody; - XMLStream xs(os); - if (output_preamble) { // XML preamble, no doctype needed. // Not using XMLStream for this, as the root tag would be in the tag stack and make troubles with the error @@ -2164,16 +2162,17 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, } if (output_body) { - params().documentClass().counters().reset(); - // Start to output the document. + XMLStream xs(os); docbookParagraphs(text(), *this, xs, runparams); } if (output_preamble) { - // Close the root element. - os << "\n"; + // Close the root element. No need for a line break, as free text is never allowed + // in a root element, it must always be wrapped in some container. + os << ""; } + return ExportSuccess; } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index b7b59413ad..ad683c713e 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -239,7 +239,8 @@ void openBlockTag(XMLStream & xs, const std::string & tag, const std::string & a void closeBlockTag(XMLStream & xs, const std::string & tag) { - xs << xml::CR(); + if (!xs.isLastTagCR()) + xs << xml::CR(); xs << xml::EndTag(tag); xs << xml::CR(); } From d8651cc60b0e95b262baa189196817f4de26d360 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 05:39:46 +0200 Subject: [PATCH 19/88] More functions in anonymous namespace. --- src/output_docbook.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ad683c713e..12601c5f5e 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -170,8 +170,6 @@ string fontToAttribute(xml::FontTypes type) { } } -} // end anonymous namespace - xml::FontTag docbookStartFontTag(xml::FontTypes type) { @@ -185,8 +183,6 @@ xml::EndFontTag docbookEndFontTag(xml::FontTypes type) } -namespace { - // Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour. // Block style: // Content before From 6a4d3dbef779c0be9a7e69f1801b2bfb4dcb86c8 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 05:40:34 +0200 Subject: [PATCH 20/88] DocBook: remove useless includes. --- src/output_docbook.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 12601c5f5e..04818907c2 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -16,8 +16,6 @@ #include "BufferParams.h" #include "Font.h" #include "InsetList.h" -#include "Layout.h" -#include "OutputParams.h" #include "Paragraph.h" #include "ParagraphList.h" #include "ParagraphParameters.h" @@ -30,11 +28,7 @@ #include "insets/InsetLabel.h" #include "insets/InsetNote.h" -#include "support/convert.h" -#include "support/debug.h" #include "support/lassert.h" -#include "support/lstrings.h" -#include "support/textutils.h" #include "support/regex.h" @@ -159,6 +153,7 @@ string fontToRole(xml::FontTypes type) } } + string fontToAttribute(xml::FontTypes type) { // If there is a role (i.e. nonstandard use of a tag), output the attribute. Otherwise, the sheer tag is sufficient // for the font. From ac46456b288c35a05f716a9e3bbf022f60b2cd9f Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 18 Aug 2020 05:46:40 +0200 Subject: [PATCH 21/88] DocBook: simplify precooked bibliography code. --- src/output_docbook.cpp | 88 ++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 50 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 04818907c2..3f6a69287b 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -360,63 +360,59 @@ void closeItemTag(XMLStream & xs, Layout const & lay) } +void makeAny( + Text const &, + Buffer const &, + XMLStream &, + OutputParams const &, + ParagraphList::const_iterator); + + void makeParagraphBibliography( Buffer const & buf, XMLStream & xs, OutputParams const & runparams, Text const & text, - ParagraphList::const_iterator const & pbegin) + ParagraphList::const_iterator const & par) { - auto const begin = text.paragraphs().begin(); - auto const end = text.paragraphs().end(); - auto pend = pbegin; - ++pend; - - // Find the paragraph *before* pbegin. - ParagraphList::const_iterator pbegin_before = begin; - if (pbegin != begin) { - ParagraphList::const_iterator pbegin_before_next = begin; - ++pbegin_before_next; - - while (pbegin_before_next != pbegin) { - ++pbegin_before; - ++pbegin_before_next; - } - } - - ParagraphList::const_iterator par = pbegin; - // If this is the first paragraph in a bibliography, open the bibliography tag. - if (pbegin != begin && pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT) { + auto pbegin_before = text.paragraphs().getParagraphBefore(par); + if (pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT) { xs << xml::StartTag("bibliography"); xs << xml::CR(); } - // Generate the required paragraphs, but only if they are . - for (; par != pend; ++par) { - // Start the precooked bibliography entry. This is very much like opening a paragraph tag. - // Don't forget the citation ID! - docstring attr; - for (auto i = 0; i < par->size(); ++i) { - Inset const *ip = par->getInset(0); - if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) { - const auto * bibitem = dynamic_cast(par->getInset(i)); - attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'"); - break; - } + // Start the precooked bibliography entry. This is very much like opening a paragraph tag. + // Don't forget the citation ID! + docstring attr; + for (auto i = 0; i < par->size(); ++i) { + Inset const *ip = par->getInset(0); + if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) { + const auto * bibitem = dynamic_cast(par->getInset(i)); + attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'"); + break; } - xs << xml::StartTag(from_utf8("bibliomixed"), attr); - - // Generate the entry. - par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(distance(begin, par)), true, true, 0); - - // End the precooked bibliography entry. - xs << xml::EndTag("bibliomixed"); - xs << xml::CR(); } + xs << xml::StartTag(from_utf8("bibliomixed"), attr); + + // Generate the entry. + auto const begin = text.paragraphs().begin(); + par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(begin, par)), true, true, 0); + + // End the precooked bibliography entry. + xs << xml::EndTag("bibliomixed"); + xs << xml::CR(); // If this is the last paragraph in a bibliography, close the bibliography tag. - if (par == end || par->layout().latextype != LATEX_BIB_ENVIRONMENT) { + auto const end = text.paragraphs().end(); + bool endBibliography = par == end; + if (!endBibliography) { + auto nextpar = par; + ++nextpar; + endBibliography = par->layout().latextype != LATEX_BIB_ENVIRONMENT; + } + + if (endBibliography) { xs << xml::EndTag("bibliography"); xs << xml::CR(); } @@ -524,14 +520,6 @@ void makeParagraph( } -void makeAny( - Text const &text, - Buffer const &buf, - XMLStream &xs, - OutputParams const &ourparams, - ParagraphList::const_iterator par); - - void makeEnvironment( Buffer const &buf, XMLStream &xs, From 3d348818e083ceb531d916be01ef2db99392f9c3 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 25 Aug 2020 02:11:08 +0200 Subject: [PATCH 22/88] DocBook: Coverity potential problem for precooked bibliographies. --- src/output_docbook.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 3f6a69287b..4e6c30e545 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -386,9 +386,10 @@ void makeParagraphBibliography( // Don't forget the citation ID! docstring attr; for (auto i = 0; i < par->size(); ++i) { - Inset const *ip = par->getInset(0); - if (ip != nullptr && ip->lyxCode() == BIBITEM_CODE) { - const auto * bibitem = dynamic_cast(par->getInset(i)); + Inset const *ip = par->getInset(i); + if (!ip) + continue; + if (const auto * bibitem = dynamic_cast(ip)) { attr = from_utf8("xml:id='") + bibitem->getParam("key") + from_utf8("'"); break; } From faaf780bed0e48eff34390c7c0bdb98e0f41b244 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Tue, 25 Aug 2020 02:41:07 +0200 Subject: [PATCH 23/88] DocBook: fix compilation issues. --- src/output_docbook.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 4e6c30e545..ce3f6991b5 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -30,8 +30,6 @@ #include "support/lassert.h" -#include "support/regex.h" - #include #include #include @@ -166,18 +164,6 @@ string fontToAttribute(xml::FontTypes type) { } -xml::FontTag docbookStartFontTag(xml::FontTypes type) -{ - return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type); -} - - -xml::EndFontTag docbookEndFontTag(xml::FontTypes type) -{ - return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type); -} - - // Convenience functions to open and close tags. First, very low-level ones to ensure a consistent new-line behaviour. // Block style: // Content before @@ -501,13 +487,13 @@ void makeParagraph( // Determine if this paragraph has some real content. Things like new pages are not caught // by Paragraph::empty(), even though they do not generate anything useful in DocBook. + // Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness. odocstringstream os2; XMLStream xs2(os2); par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0); docstring cleaned = os2.str(); - static const lyx::regex reg("[ \\r\\n]*"); - cleaned = from_utf8(lyx::regex_replace(to_utf8(cleaned), reg, string(""))); + cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end()); if (!cleaned.empty()) { if (open_par) @@ -658,8 +644,6 @@ void makeAny( } } -} // end anonymous namespace - using DocBookDocumentSectioning = tuple; @@ -796,6 +780,20 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit); } +} // end anonymous namespace + + +xml::FontTag docbookStartFontTag(xml::FontTypes type) +{ + return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type); +} + + +xml::EndFontTag docbookEndFontTag(xml::FontTypes type) +{ + return xml::EndFontTag(from_utf8(fontToDocBookTag(type)), type); +} + void outputDocBookInfo( Text const & text, @@ -829,11 +827,11 @@ void outputDocBookInfo( // Actually output the abstract if there is something to do. Don't count line feeds or spaces in this, // even though they must be properly output if there is some abstract. abstract = os2.str(); - static const lyx::regex reg("[ \\r\\n]*"); - docstring abstractContent = from_utf8(lyx::regex_replace(to_utf8(abstract), reg, string(""))); + docstring cleaned = abstract; + cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end()); // Nothing? Then there is no abstract! - if (abstractContent.empty()) + if (cleaned.empty()) hasAbstract = false; } From 52b2d3f683250f7405f0efe14c4f1ff9c064bcf5 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 26 Aug 2020 21:19:38 +0200 Subject: [PATCH 24/88] DocBook: make Paragraph::simpleDocBookOnePar return a list of paragraphs. Before, it directly wrote to the XMLStream, but it made implementation of new lines tricky. Now, it returns the XML for each sub-paragraph (delimited by new lines) as a string, so that the caller can adopt a more precise behaviour (such as in lists). --- autotests/export/docbook/lists.lyx | 13 +++++- autotests/export/docbook/lists.xml | 54 ++-------------------- lib/doc/Customization.lyx | 72 +++++++++++++++++++++++++++++- src/Paragraph.cpp | 53 +++++++++++++--------- src/Paragraph.h | 14 +++--- src/insets/InsetERT.cpp | 24 +++++++--- src/insets/InsetNewline.cpp | 15 +------ src/output_docbook.cpp | 57 +++++++++++++---------- src/xml.h | 2 - 9 files changed, 175 insertions(+), 129 deletions(-) diff --git a/autotests/export/docbook/lists.lyx b/autotests/export/docbook/lists.lyx index f903372084..f4a58c2e10 100644 --- a/autotests/export/docbook/lists.lyx +++ b/autotests/export/docbook/lists.lyx @@ -103,6 +103,10 @@ I'm the second line \end_layout \begin_layout Standard +\begin_inset Note Note +status collapsed + +\begin_layout Plain Layout A complex list: \end_layout @@ -119,7 +123,7 @@ First first item First second item \end_layout -\begin_layout Standard +\begin_layout Plain Layout Text after first item \end_layout @@ -137,10 +141,15 @@ Second first item Second second item \end_layout -\begin_layout Standard +\begin_layout Plain Layout Text after second item \end_layout \end_deeper +\end_inset + + +\end_layout + \end_body \end_document diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml index 4621e30937..d7b24f6da7 100644 --- a/autotests/export/docbook/lists.xml +++ b/autotests/export/docbook/lists.xml @@ -2,61 +2,15 @@
- -Test document - - -A simple list: - +Test document +A simple list: First item -Second item on two lines - - -I'm the second line - - - - - +Second item on two lines +I'm the second line - -A complex list: - - - -First item - - -First first item - - -First second item - - - -Text after first item - - - -Second item - - - -Second first item - - - -Second second item - - - -Text after second item - -
\ No newline at end of file diff --git a/lib/doc/Customization.lyx b/lib/doc/Customization.lyx index d6f5f1744b..357845a342 100644 --- a/lib/doc/Customization.lyx +++ b/lib/doc/Customization.lyx @@ -27479,6 +27479,8 @@ status collapsed \change_inserted 1075283030 1597698872 DocBookTagType +\change_unchanged + \end_layout \end_inset @@ -27542,6 +27544,8 @@ status collapsed \change_inserted 1075283030 1597698987 DocBook*TagType +\change_unchanged + \end_layout \end_inset @@ -27563,6 +27567,8 @@ status collapsed \change_inserted 1075283030 1597699012 block +\change_unchanged + \end_layout \end_inset @@ -27621,6 +27627,8 @@ status collapsed \change_inserted 1075283030 1597699113 paragraph +\change_unchanged + \end_layout \end_inset @@ -27667,6 +27675,8 @@ status collapsed \change_inserted 1075283030 1597699307 inline +\change_unchanged + \end_layout \end_inset @@ -27702,6 +27712,8 @@ status collapsed \change_inserted 1075283030 1597699585 block +\change_unchanged + \end_layout \end_inset @@ -28415,8 +28427,34 @@ NONE This parameter only makes sense when itemising layouts are used, such as lists. -\change_inserted 1075283030 1597699848 +\change_inserted 1075283030 1598469472 +The most likely value is +\begin_inset Quotes eld +\end_inset + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\change_inserted 1075283030 1598469476 +para +\end_layout + +\end_inset + + +\begin_inset Quotes erd +\end_inset + +. +\begin_inset Newline newline +\end_inset + +When a list item is split using a new line, the item inner tag will be repeated + for each part of the paragraph, parts being separated by new lines. + \end_layout \begin_layout Description @@ -28429,6 +28467,8 @@ status collapsed \change_inserted 1075283030 1597699853 DocBookItemInnerTagType +\change_unchanged + \end_layout \end_inset @@ -28441,6 +28481,8 @@ status collapsed \change_inserted 1075283030 1597699866 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -28594,6 +28636,8 @@ status collapsed \change_inserted 1075283030 1597699880 DocBookItemLabelTagType +\change_unchanged + \end_layout \end_inset @@ -28606,6 +28650,8 @@ status collapsed \change_inserted 1075283030 1597699874 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -28715,6 +28761,8 @@ status collapsed \change_inserted 1075283030 1597699890 DocBookItemTagType +\change_unchanged + \end_layout \end_inset @@ -28727,6 +28775,8 @@ status collapsed \change_inserted 1075283030 1597699890 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -28898,6 +28948,8 @@ status collapsed \change_inserted 1075283030 1597699900 DocBookItemWrapperTagType +\change_unchanged + \end_layout \end_inset @@ -28910,6 +28962,8 @@ status collapsed \change_inserted 1075283030 1597699897 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -29075,6 +29129,8 @@ status collapsed \change_inserted 1075283030 1597699904 DocBookInnerTagType +\change_unchanged + \end_layout \end_inset @@ -29087,6 +29143,8 @@ status collapsed \change_inserted 1075283030 1597699904 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -29238,6 +29296,8 @@ status collapsed \change_inserted 1075283030 1597699924 DocBookTagType +\change_unchanged + \end_layout \end_inset @@ -29250,6 +29310,8 @@ status collapsed \change_inserted 1075283030 1597699924 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -29415,6 +29477,8 @@ status collapsed \change_inserted 1075283030 1597699932 DocBookWrapperTagType +\change_unchanged + \end_layout \end_inset @@ -29427,6 +29491,8 @@ status collapsed \change_inserted 1075283030 1597699929 block, paragraph, inline +\change_unchanged + \end_layout \end_inset @@ -29635,6 +29701,8 @@ status collapsed \change_inserted 1075283030 1597700120 biblioentry +\change_unchanged + \end_layout \end_inset @@ -29660,6 +29728,8 @@ status collapsed \change_inserted 1075283030 1597700076 bibliomixed +\change_unchanged + \end_layout \end_inset diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 24947f80dd..e87ef88176 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3329,19 +3329,14 @@ std::tuple, vector> computeDocBookFontSwit } // anonymous namespace -void Paragraph::simpleDocBookOnePar(Buffer const & buf, - XMLStream & xs, - OutputParams const & runparams, - Font const & outerfont, - bool start_paragraph, bool close_paragraph, - pos_type initial) const +std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, + OutputParams const & runparams, + Font const & outerfont, + pos_type initial) const { - // track whether we have opened these tags + // Track whether we have opened these tags DocBookFontState fs; - if (start_paragraph) - xs.startDivision(allowEmpty()); - Layout const & style = *d->layout_; FontInfo font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font; @@ -3352,15 +3347,27 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, vector tagsToOpen; vector tagsToClose; - // parsing main loop + std::vector generatedParagraphs; + odocstringstream os; + auto * xs = new XMLStream(os); + + // Parsing main loop. for (pos_type i = initial; i < size(); ++i) { - // let's not show deleted material in the output + // Don't show deleted material in the output. if (isDeleted(i)) continue; - Font const font = getFont(buf.masterBuffer()->params(), i, outerfont); + // If this is an InsetNewline, generate a new paragraph. + if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) { + generatedParagraphs.push_back(os.str()); + os = odocstringstream(); + // XMLStream has no copy constructor. + delete xs; + xs = new XMLStream(os); + } // Determine which tags should be opened or closed. + Font const font = getFont(buf.masterBuffer()->params(), i, outerfont); tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs); // FIXME XHTML @@ -3369,12 +3376,12 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, vector::const_iterator cit = tagsToClose.begin(); vector::const_iterator cen = tagsToClose.end(); for (; cit != cen; ++cit) - xs << *cit; + *xs << *cit; vector::const_iterator sit = tagsToOpen.begin(); vector::const_iterator sen = tagsToOpen.end(); for (; sit != sen; ++sit) - xs << *sit; + *xs << *sit; tagsToClose.clear(); tagsToOpen.clear(); @@ -3386,11 +3393,11 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, // TODO: special case will bite here. np.docbook_in_par = true; - inset->docbook(xs, np); + inset->docbook(*xs, np); } } else { char_type c = getUChar(buf.masterBuffer()->params(), runparams, i); - xs << c; + *xs << c; } font_old = font.fontInfo(); } @@ -3398,11 +3405,15 @@ void Paragraph::simpleDocBookOnePar(Buffer const & buf, // FIXME, this code is just imported from XHTML // I'm worried about what happens if a branch, say, is itself // wrapped in some font stuff. I think that will not work. - xs.closeFontTags(); + xs->closeFontTags(); if (runparams.docbook_in_listing) - xs << xml::CR(); - if (close_paragraph) - xs.endDivision(); + *xs << xml::CR(); + + // Finalise the last (and most likely only) paragraph. + generatedParagraphs.push_back(os.str()); + delete xs; + + return generatedParagraphs; } diff --git a/src/Paragraph.h b/src/Paragraph.h index 58b2762263..ee314031ba 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -24,6 +24,7 @@ #include "support/types.h" #include +#include namespace lyx { @@ -208,14 +209,11 @@ public: /// Output the first word of a paragraph, return the position where it left. pos_type firstWordLyXHTML(XMLStream & xs, OutputParams const & runparams) const; - /// Writes to stream the DocBook representation - void simpleDocBookOnePar(Buffer const & buf, - XMLStream &, - OutputParams const & runparams, - Font const & outerfont, - bool start_paragraph = true, - bool close_paragraph = true, - pos_type initial = 0) const; + /// Outputs to stream the DocBook representation, one element per paragraph. + std::vector simpleDocBookOnePar(Buffer const & buf, + OutputParams const & runparams, + Font const & outerfont, + pos_type initial = 0) const; /// \return any material that has had to be deferred until after the /// paragraph has closed. diff --git a/src/insets/InsetERT.cpp b/src/insets/InsetERT.cpp index 8e69e88260..1af67e1e31 100644 --- a/src/insets/InsetERT.cpp +++ b/src/insets/InsetERT.cpp @@ -98,23 +98,33 @@ void InsetERT::docbook(XMLStream & xs, OutputParams const & runparams) const auto par = begin; auto const end = paragraphs().end(); - odocstringstream os2; - XMLStream xs2(os2); + odocstringstream os; // No need for XML handling here. // Recreate the logic of makeParagraph in output_docbook.cpp, but much simplified: never open // in an ERT, use simple line breaks. - while (par != end) { - par->simpleDocBookOnePar(buffer(), xs2, runparams, text().outerFont(distance(begin, par))); + // New line after each paragraph of the ERT, save the last one. + while (true) { // For each paragraph in the ERT... + auto pars = par->simpleDocBookOnePar(buffer(), runparams, text().outerFont(distance(begin, par))); + auto p = pars.begin(); + while (true) { // For each line of this ERT paragraph... + os << *p; + ++p; + if (p != pars.end()) + os << "\n"; + else + break; + } - // New line after each paragraph of the ERT, save the last one. ++par; if (par != end) - xs << "\n"; + os << "\n"; + else + break; } // Output the ERT as a comment with the appropriate escaping. xs << XMLStream::ESCAPE_NONE << ""; xs << xml::CR(); } diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index 7cba0f756a..b33cf00768 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -174,20 +174,7 @@ int InsetNewline::plaintext(odocstringstream & os, void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const { - if (runparams.docbook_in_par) { - xs.closeFontTags(); - - // TODO: what if within a list item, and docbookiteminnertag is not para? This would require information - // about the paragraph's layout... Good for now, though, this should not happen in DocBook, only maybe - // extensions. - xs << XMLStream::ESCAPE_NONE << from_utf8(""); - xs << XMLStream::ESCAPE_NONE << from_utf8("\n"); - // TODO: that's a hack... -// xs << xml::EndTag("para"); -// xs << xml::CR(); -// xs << xml::StartTag("para"); - } - // Outside a paragraph, no need to handle new lines. + // New lines are handled by Paragraph::simpleDocBookOnePar. } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ce3f6991b5..0dc52578d3 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -382,9 +382,11 @@ void makeParagraphBibliography( } xs << xml::StartTag(from_utf8("bibliomixed"), attr); - // Generate the entry. + // Generate the entry. Concatenate the different parts of the paragraph if any. auto const begin = text.paragraphs().begin(); - par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(begin, par)), true, true, 0); + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(begin, par)), 0); + for (auto & parXML : pars) + xs << XMLStream::ESCAPE_NONE << parXML; // End the precooked bibliography entry. xs << xml::EndTag("bibliomixed"); @@ -488,21 +490,19 @@ void makeParagraph( // Determine if this paragraph has some real content. Things like new pages are not caught // by Paragraph::empty(), even though they do not generate anything useful in DocBook. // Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness. - odocstringstream os2; - XMLStream xs2(os2); - par->simpleDocBookOnePar(buf, xs2, runparams, text.outerFont(distance(begin, par)), open_par, close_par, 0); + // std::all_of allows doing this check without having to copy the string. + // Open and close tags around each contained paragraph. + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0); + for (auto & parXML : pars) { + if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) { + if (open_par) + openParTag(xs, &*par, prevpar); - docstring cleaned = os2.str(); - cleaned.erase(std::remove_if(cleaned.begin(), cleaned.end(), ::isspace), cleaned.end()); + xs << XMLStream::ESCAPE_NONE << parXML; - if (!cleaned.empty()) { - if (open_par) - openParTag(xs, &*par, prevpar); - - xs << XMLStream::ESCAPE_NONE << os2.str(); - - if (close_par) - closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); + if (close_par) + closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); + } } } @@ -529,10 +529,8 @@ void makeEnvironment( style.latextype == LATEX_LIST_ENVIRONMENT || style.latextype == LATEX_ITEM_ENVIRONMENT) { // Open a wrapper tag if needed. - if (style.docbookitemwrappertag() != "NONE") { - xs << xml::StartTag(style.docbookitemwrappertag(), style.docbookitemwrapperattr()); - xs << xml::CR(); - } + if (style.docbookitemwrappertag() != "NONE") + openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype()); // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first // character after the label. @@ -580,9 +578,18 @@ void makeEnvironment( // TODO: this always worked only by magic... xs << ' '; } else { - // Generate the rest of the paragraph, if need be. - par->simpleDocBookOnePar(buf, xs, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), - true, true, sep); + // Generate the rest of the paragraph, if need be. Open as many inner tags as necessary. + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep); + auto p = pars.begin(); + while (true) { + xs << XMLStream::ESCAPE_NONE << *p; + ++p; + if (p != pars.end()) { + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); + } else + break; + } } } else { makeAny(text, buf, xs, runparams, par); @@ -612,8 +619,10 @@ void makeCommand( auto prevpar = text.paragraphs().getParagraphBefore(par); openParTag(xs, &*par, prevpar); - par->simpleDocBookOnePar(buf, xs, runparams, - text.outerFont(distance(begin, par))); + auto pars = par->simpleDocBookOnePar(buf, runparams,text.outerFont(distance(begin, par))); + for (auto & parXML : pars) + // TODO: decide what to do with openParTag/closeParTag in new lines. + xs << XMLStream::ESCAPE_NONE << parXML; closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); } diff --git a/src/xml.h b/src/xml.h index 69d582d0fd..9a7cf17f28 100644 --- a/src/xml.h +++ b/src/xml.h @@ -132,8 +132,6 @@ private: TagDeque tag_stack_; /// bool is_last_tag_cr_; -public: - bool pending_tags_empty() { return pending_tags_.empty();}; }; namespace xml { From bfc67c59b44415f2dea7ad068a8ac86e2b19f488 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 29 Aug 2020 02:43:30 +0200 Subject: [PATCH 25/88] XML: use the new mechanisms for CR detection with errors. This helps tracking down line problems even in the presence of errors. --- src/xml.cpp | 12 ++++++++---- src/xml.h | 8 ++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/xml.cpp b/src/xml.cpp index b4004af4cb..2f496679c9 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -167,17 +167,21 @@ bool FontTag::operator==(StartTag const & tag) const } // namespace xml -void XMLStream::writeError(std::string const &s) const +void XMLStream::writeError(std::string const &s) { LYXERR0(s); - os_ << from_utf8("\n"); + *this << ESCAPE_NONE << from_utf8(""); + *this << xml::CR(); } -void XMLStream::writeError(docstring const &s) const +void XMLStream::writeError(docstring const &s) { LYXERR0(s); - os_ << from_utf8("\n"); + *this << ESCAPE_NONE << from_utf8(""); + *this << xml::CR(); } diff --git a/src/xml.h b/src/xml.h index 9a7cf17f28..45c62aba32 100644 --- a/src/xml.h +++ b/src/xml.h @@ -103,9 +103,13 @@ public: /// that simplifies the logic using this code. bool isLastTagCR() const { return is_last_tag_cr_; }; /// - void writeError(std::string const &) const; + void writeError(std::string const &); /// - void writeError(docstring const &) const; + void writeError(docstring const &); + /// + typedef std::shared_ptr TagPtr; + /// Returns the last element on the tag stack. XMLStream keeps ownership of the item. + TagPtr getLastStackTag(); private: /// void clearTagDeque(); From fc0999a4220afb1646a5ae75ea8192b6d304ec56 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 29 Aug 2020 02:55:47 +0200 Subject: [PATCH 26/88] DocBook: partially remove use of bpit/epit in docbookParagraphs and docbookSimpleAllParagraphs. This will help with the next refactoring to be much cleaner (only work with iterators, don't maintain twice the same information). --- src/output_docbook.cpp | 193 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 172 insertions(+), 21 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 0dc52578d3..ff47aa6814 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -308,8 +308,32 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa if (nextpar != nullptr) { Layout const & nextlay = nextpar->layout(); if (nextlay.docbookwrappertag() != "NONE") { - closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() - && !nextlay.docbookwrappermergewithprevious(); + if (nextpar->getDepth() == par->getDepth()) { + // Same depth: the basic condition applies. + closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() + && !nextlay.docbookwrappermergewithprevious(); + } else if (nextpar->getDepth() > par->getDepth()) { + // The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag). + closeWrapper = 0; + } else { + // This paragraph is deeper than the next one: close the wrapper, + // disregarding docbookwrappermergewithprevious. + // Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found? + closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth() + } + } else { + if (nextpar->getDepth() == par->getDepth()) { + // This is not wrapped: this must be the rest of the item, still within the wrapper. + closeWrapper = 1; + } else if (nextpar->getDepth() > par->getDepth()) { + // The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag). + closeWrapper = 0; + } else { + // This paragraph is deeper than the next one: close the wrapper, + // disregarding docbookwrappermergewithprevious. + // Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found? + closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth() + } } } @@ -507,12 +531,140 @@ void makeParagraph( } -void makeEnvironment( - Buffer const &buf, - XMLStream &xs, - OutputParams const &runparams, - Text const &text, - ParagraphList::const_iterator const & par) +void makeEnvironment(Buffer const &buf, + XMLStream &xs, + OutputParams const &runparams, + Text const &text, + ParagraphList::const_iterator const & par) +{ + // TODO: simplify me! + auto const end = text.paragraphs().end(); + + // Output the opening tag for this environment, but only if it has not been previously opened (condition + // implemented in openParTag). + auto prevpar = text.paragraphs().getParagraphBefore(par); + openParTag(xs, &*par, prevpar); // TODO: switch in layout for par/block? + + // Generate the contents of this environment. There is a special case if this is like some environment. + Layout const & style = par->layout(); + if (style.latextype == LATEX_COMMAND) { + // Nothing to do (otherwise, infinite loops). + } else if (style.latextype == LATEX_ENVIRONMENT) { + // Open a wrapper tag if needed. + if (style.docbookitemwrappertag() != "NONE") + openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype()); + + // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first + // character after the label. + pos_type sep = 0; + if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") { + // At least one condition must be met: + // - this environment is not a list + // - if this is a list, the label must not be manual (i.e. it must be taken from the layout) + if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) { + // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. + docstring const lbl = par->params().labelString(); + + if (lbl.empty()) { + xs << xml::CR(); + } else { + openLabelTag(xs, style); + xs << lbl; + closeLabelTag(xs, style); + } + } else { + // Only variablelist gets here (or similar items defined as an extension in the layout). + openLabelTag(xs, style); + sep = par->firstWordDocBook(xs, runparams); + closeLabelTag(xs, style); + } + } + + // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph + // AND if the next paragraph doesn't have the same depth (if there is such a paragraph). + // Common case: there is only the first word on the line, but there is a nested list instead + // of more text. + bool emptyItem = false; + if (sep == par->size()) { // If the separator is already at the end of this paragraph... + auto next_par = par; + ++next_par; + if (next_par == text.paragraphs().end()) // There is no next paragraph. + emptyItem = true; + else // There is a next paragraph: check depth. + emptyItem = par->params().depth() >= next_par->params().depth(); + } + + if (emptyItem) { + // Avoid having an empty item, this is not valid DocBook. A single character is enough to force + // generation of a full . + // TODO: this always worked only by magic... + xs << ' '; + } else { + // Generate the rest of the paragraph, if need be. Open as many inner tags as necessary. + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep); + auto p = pars.begin(); + while (true) { + xs << XMLStream::ESCAPE_NONE << *p; + ++p; + if (p != pars.end()) { + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); + } else + break; + } + } + } else { + makeAny(text, buf, xs, runparams, par); + } + + // Close the environment. + auto nextpar = par; + ++nextpar; + closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block? +} + + +ParagraphList::const_iterator findEndOfEnvironment( + ParagraphList::const_iterator const & pstart, + ParagraphList::const_iterator const & pend) +{ + // Copy-paste from XHTML. Should be factored out at some point... + + ParagraphList::const_iterator p = pstart; + Layout const & bstyle = p->layout(); + size_t const depth = p->params().depth(); + for (++p; p != pend; ++p) { + Layout const & style = p->layout(); + // It shouldn't happen that e.g. a section command occurs inside + // a quotation environment, at a higher depth, but as of 6/2009, + // it can happen. We pretend that it's just at lowest depth. + if (style.latextype == LATEX_COMMAND) + return p; + + // If depth is down, we're done + if (p->params().depth() < depth) + return p; + + // If depth is up, we're not done + if (p->params().depth() > depth) + continue; + + // FIXME I am not sure about the first check. + // Surely we *could* have different layouts that count as + // LATEX_PARAGRAPH, right? + if (style.latextype == LATEX_PARAGRAPH || style != bstyle) + return p; + } + return pend; +} + + +ParagraphList::const_iterator makeListEnvironment(Buffer const &buf, + XMLStream &xs, + OutputParams const &runparams, + Text const &text, + ParagraphList::const_iterator const & par) +>>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs. { auto const end = text.paragraphs().end(); @@ -921,12 +1073,13 @@ void docbookSimpleAllParagraphs( outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); // Then, the content. It starts where the ends. - bpit = info.epit; - while (bpit < epit) { - auto par = paragraphs.iterator_at(bpit); + auto par = text.paragraphs().iterator_at(info.epit); + auto end = text.paragraphs().iterator_at(epit); + while (par != end) { if (!hasOnlyNotes(*par)) - makeAny(text, buf, xs, runparams, par); - bpit += 1; + par = makeAny(text, buf, xs, runparams, par); + else + ++par; } } @@ -967,21 +1120,20 @@ void docbookParagraphs(Text const &text, bool currentlyInAppendix = false; - while (bpit < epit) { + auto par = text.paragraphs().iterator_at(bpit); + auto end = text.paragraphs().iterator_at(epit); + while (par != end) { OutputParams ourparams = runparams; - auto par = paragraphs.iterator_at(bpit); if (par->params().startOfAppendix()) currentlyInAppendix = true; - Layout const &style = par->layout(); - ParagraphList::const_iterator const lastStartedPar = par; - ParagraphList::const_iterator send; - if (hasOnlyNotes(*par)) { - bpit += 1; + ++par; continue; } + Layout const &style = par->layout(); + // Think about adding
and/or
s. const bool isLayoutSectioning = style.category() == from_utf8("Sectioning"); if (isLayoutSectioning) { @@ -1058,7 +1210,6 @@ void docbookParagraphs(Text const &text, // Generate this paragraph. makeAny(text, buf, xs, ourparams, par); - bpit += 1; } // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning From 1bd49f9c39b103b2d8bbe079bc603cfa47509ae5 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 29 Aug 2020 03:46:30 +0200 Subject: [PATCH 27/88] DocBook: make all make* functions have the same argument order. --- src/output_docbook.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ff47aa6814..12c00899ea 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -378,11 +378,11 @@ void makeAny( ParagraphList::const_iterator); -void makeParagraphBibliography( +void makeBibliography( + Text const & text, Buffer const & buf, XMLStream & xs, OutputParams const & runparams, - Text const & text, ParagraphList::const_iterator const & par) { // If this is the first paragraph in a bibliography, open the bibliography tag. @@ -433,10 +433,10 @@ void makeParagraphBibliography( void makeParagraph( + Text const & text, Buffer const & buf, XMLStream & xs, OutputParams const & runparams, - Text const & text, ParagraphList::const_iterator const & par) { auto const begin = text.paragraphs().begin(); @@ -531,10 +531,10 @@ void makeParagraph( } -void makeEnvironment(Buffer const &buf, +void makeEnvironment(Text const &text, + Buffer const &buf, XMLStream &xs, OutputParams const &runparams, - Text const &text, ParagraphList::const_iterator const & par) { // TODO: simplify me! @@ -659,10 +659,10 @@ ParagraphList::const_iterator findEndOfEnvironment( } -ParagraphList::const_iterator makeListEnvironment(Buffer const &buf, +ParagraphList::const_iterator makeListEnvironment(Text const &text, + Buffer const &buf, XMLStream &xs, OutputParams const &runparams, - Text const &text, ParagraphList::const_iterator const & par) >>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs. { @@ -755,10 +755,10 @@ ParagraphList::const_iterator makeListEnvironment(Buffer const &buf, void makeCommand( + Text const & text, Buffer const & buf, XMLStream & xs, OutputParams const & runparams, - Text const & text, ParagraphList::const_iterator const & par) { // Unlike XHTML, no need for labels, as they are handled by DocBook tags. @@ -780,16 +780,15 @@ void makeCommand( } -void makeAny( - Text const &text, - Buffer const &buf, - XMLStream &xs, - OutputParams const &ourparams, - ParagraphList::const_iterator par) +ParagraphList::const_iterator makeAny(Text const &text, + Buffer const &buf, + XMLStream &xs, + OutputParams const &runparams, + ParagraphList::const_iterator par) { switch (par->layout().latextype) { case LATEX_COMMAND: - makeCommand(buf, xs, ourparams, text, par); + makeCommand(text, buf, xs, runparams, par); break; case LATEX_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT: @@ -797,10 +796,10 @@ void makeAny( makeEnvironment(buf, xs, ourparams, text, par); break; case LATEX_PARAGRAPH: - makeParagraph(buf, xs, ourparams, text, par); + makeParagraph(text, buf, xs, runparams, par); break; case LATEX_BIB_ENVIRONMENT: - makeParagraphBibliography(buf, xs, ourparams, text, par); + makeBibliography(text, buf, xs, runparams, par); break; } } From 8656fbd520030a2879f60a55edf0dfc706a2a60b Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 29 Aug 2020 03:03:16 +0200 Subject: [PATCH 28/88] DocBook: start splitting environment handling in two, to have proper things for lists. --- src/output_docbook.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 12c00899ea..356de072b9 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -370,12 +370,11 @@ void closeItemTag(XMLStream & xs, Layout const & lay) } -void makeAny( - Text const &, - Buffer const &, - XMLStream &, - OutputParams const &, - ParagraphList::const_iterator); +ParagraphList::const_iterator makeAny(Text const &, + Buffer const &, + XMLStream &, + OutputParams const &, + ParagraphList::const_iterator); void makeBibliography( @@ -664,7 +663,6 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text, XMLStream &xs, OutputParams const &runparams, ParagraphList::const_iterator const & par) ->>>>>>> be6480e59c... DocBook: same refactoring for docbookSimpleAllParagraphs. { auto const end = text.paragraphs().end(); @@ -751,6 +749,8 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text, auto nextpar = par; ++nextpar; closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block? + + return nextpar; } @@ -791,10 +791,12 @@ ParagraphList::const_iterator makeAny(Text const &text, makeCommand(text, buf, xs, runparams, par); break; case LATEX_ENVIRONMENT: + makeEnvironment(text, buf, xs, runparams, par); + break; case LATEX_LIST_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT: - makeEnvironment(buf, xs, ourparams, text, par); - break; + // Only case when makeAny() might consume more than one paragraph. + return makeListEnvironment(text, buf, xs, runparams, par); case LATEX_PARAGRAPH: makeParagraph(text, buf, xs, runparams, par); break; @@ -802,6 +804,8 @@ ParagraphList::const_iterator makeAny(Text const &text, makeBibliography(text, buf, xs, runparams, par); break; } + ++par; + return par; } @@ -1208,7 +1212,7 @@ void docbookParagraphs(Text const &text, } // Generate this paragraph. - makeAny(text, buf, xs, ourparams, par); + par = makeAny(text, buf, xs, ourparams, par); } // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning From fc2c36289b5c0cd15f453c4905bb56a2b20aef25 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 27 Aug 2020 00:52:06 +0200 Subject: [PATCH 29/88] DocBook: rewrite makeListEnvironment. --- autotests/export/docbook/lists.lyx | 135 +++++++++++++++++++++++-- autotests/export/docbook/lists.xml | 136 +++++++++++++++++++++++++ lib/layouts/stdlists.inc | 5 +- src/output_docbook.cpp | 154 +++++++++++------------------ src/xml.cpp | 6 ++ src/xml.h | 1 - 6 files changed, 328 insertions(+), 109 deletions(-) diff --git a/autotests/export/docbook/lists.lyx b/autotests/export/docbook/lists.lyx index f4a58c2e10..1c1e88bcb0 100644 --- a/autotests/export/docbook/lists.lyx +++ b/autotests/export/docbook/lists.lyx @@ -102,11 +102,71 @@ Second item on two lines I'm the second line \end_layout -\begin_layout Standard -\begin_inset Note Note -status collapsed +\begin_layout Itemize +Third item +\end_layout -\begin_layout Plain Layout +\begin_layout Standard +A simple enumerated list: +\end_layout + +\begin_layout Enumerate +First item +\end_layout + +\begin_layout Enumerate +Second item on two lines +\begin_inset Newline newline +\end_inset + +I'm the second line +\end_layout + +\begin_layout Standard +A simple description list: +\end_layout + +\begin_layout Description +Word description +\end_layout + +\begin_layout Description +Sentence meaning +\end_layout + +\begin_layout Standard +Nested lists: +\end_layout + +\begin_layout Itemize +First item +\end_layout + +\begin_deeper +\begin_layout Itemize +First first item +\end_layout + +\begin_layout Itemize +First second item +\end_layout + +\end_deeper +\begin_layout Itemize +Second item +\end_layout + +\begin_deeper +\begin_layout Itemize +Second first item +\end_layout + +\begin_layout Itemize +Second second item +\end_layout + +\end_deeper +\begin_layout Standard A complex list: \end_layout @@ -123,7 +183,47 @@ First first item First second item \end_layout -\begin_layout Plain Layout +\begin_layout Standard +Text after first item +\end_layout + +\end_deeper +\begin_layout Itemize +Second item +\end_layout + +\begin_deeper +\begin_layout Itemize +Second first item +\end_layout + +\begin_layout Itemize +Second second item +\end_layout + +\begin_layout Standard +Text after second item +\end_layout + +\end_deeper +\begin_layout Standard +A very complex list: +\end_layout + +\begin_layout Itemize +First item +\end_layout + +\begin_deeper +\begin_layout Itemize +First first item +\end_layout + +\begin_layout Itemize +First second item +\end_layout + +\begin_layout Standard Text after first item \end_layout @@ -141,15 +241,32 @@ Second first item Second second item \end_layout -\begin_layout Plain Layout +\begin_layout Standard Text after second item \end_layout \end_deeper -\end_inset - - +\begin_layout Standard +Nested description lists: \end_layout +\begin_layout Description +LyX: +\end_layout + +\begin_deeper +\begin_layout Description +lyx16 LyX 1.6 file format (lyx2lyx) +\end_layout + +\begin_layout Description +lyx21 LyX 2.1 file format (lyx2lyx) +\end_layout + +\begin_layout Description +xhtml LyXHTML (native LyX HTML export) +\end_layout + +\end_deeper \end_body \end_document diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml index d7b24f6da7..6812230064 100644 --- a/autotests/export/docbook/lists.xml +++ b/autotests/export/docbook/lists.xml @@ -12,5 +12,141 @@ Second item on two lines I'm the second line + +Third item + +A simple enumerated list: + + +First item + + +Second item on two lines +I'm the second line + + +A simple description list: + + +Word + +description + + + +Sentence + +meaning + + + +Nested lists: + + +First item + + +First first item + + +First second item + + + + +Second item + + +Second first item + + +Second second item + + + + +A complex list: + + +First item + + +First first item + + +First second item + + +Text after first item + + +Second item + + +Second first item + + +Second second item + + +Text after second item + + +A very complex list: + + +First item + + +First first item + + +First second item + + +Text after first item + + +Second item + + +Second first item + + +Second second item + + +Text after second item + + +Nested description lists: + + +LyX: + + + + +lyx16 + +LyX 1.6 file format (lyx2lyx) + + + +lyx21 + +LyX 2.1 file format (lyx2lyx) + + + +xhtml + +LyXHTML (native LyX HTML export) + + + + + +
\ No newline at end of file diff --git a/lib/layouts/stdlists.inc b/lib/layouts/stdlists.inc index c0b346dbd1..d05e896e39 100644 --- a/lib/layouts/stdlists.inc +++ b/lib/layouts/stdlists.inc @@ -43,9 +43,7 @@ Style Itemize Color latex EndFont EndArgument - DocBookWrapperTag itemizedlist - DocBookWrapperMergeWithPrevious true - DocBookTag NONE + DocBookTag itemizedlist DocBookItemTag listitem DocBookItemInnerTag para End @@ -134,6 +132,7 @@ Style Description DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 356de072b9..9d518539e7 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -225,7 +225,7 @@ void closeBlockTag(XMLStream & xs, const std::string & tag) void openTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype) { - if (tag.empty() || tag == "NONE") + if (tag.empty() || tag == "NONE") // Common check to be performed elsewhere, if it was not here. return; if (tag == "para" || tagtype == "paragraph") // Special case for : always considered as a paragraph. @@ -275,7 +275,7 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar Layout const & prevlay = prevpar->layout(); if (prevlay.docbookwrappertag() != "NONE") { openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag() - && !lay.docbookwrappermergewithprevious(); + && !lay.docbookwrappermergewithprevious(); } } @@ -308,32 +308,8 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa if (nextpar != nullptr) { Layout const & nextlay = nextpar->layout(); if (nextlay.docbookwrappertag() != "NONE") { - if (nextpar->getDepth() == par->getDepth()) { - // Same depth: the basic condition applies. - closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() - && !nextlay.docbookwrappermergewithprevious(); - } else if (nextpar->getDepth() > par->getDepth()) { - // The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag). - closeWrapper = 0; - } else { - // This paragraph is deeper than the next one: close the wrapper, - // disregarding docbookwrappermergewithprevious. - // Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found? - closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth() - } - } else { - if (nextpar->getDepth() == par->getDepth()) { - // This is not wrapped: this must be the rest of the item, still within the wrapper. - closeWrapper = 1; - } else if (nextpar->getDepth() > par->getDepth()) { - // The next paragraph is deeper: no need to close the wrapper, only to open it (cf. openParTag). - closeWrapper = 0; - } else { - // This paragraph is deeper than the next one: close the wrapper, - // disregarding docbookwrappermergewithprevious. - // Hypothesis: nextlay.docbookwrappertag() == lay.docbookwrappertag(). TODO: THIS IS WRONG! Loop back until a layout with the right depth is found? - closeWrapper = 1L + (long long) par->getDepth() - (long long) nextpar->getDepth(); // > 0, as nextpar->getDepth() < par->getDepth() - } + closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() + && !nextlay.docbookwrappermergewithprevious(); } } @@ -564,9 +540,7 @@ void makeEnvironment(Text const &text, // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. docstring const lbl = par->params().labelString(); - if (lbl.empty()) { - xs << xml::CR(); - } else { + if (!lbl.empty()) { openLabelTag(xs, style); xs << lbl; closeLabelTag(xs, style); @@ -628,7 +602,6 @@ ParagraphList::const_iterator findEndOfEnvironment( ParagraphList::const_iterator const & pend) { // Copy-paste from XHTML. Should be factored out at some point... - ParagraphList::const_iterator p = pstart; Layout const & bstyle = p->layout(); size_t const depth = p->params().depth(); @@ -662,95 +635,84 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text, Buffer const &buf, XMLStream &xs, OutputParams const &runparams, - ParagraphList::const_iterator const & par) + ParagraphList::const_iterator const & begin) { + auto par = begin; auto const end = text.paragraphs().end(); + auto const envend = findEndOfEnvironment(par, end); - // Output the opening tag for this environment, but only if it has not been previously opened (condition - // implemented in openParTag). - auto prevpar = text.paragraphs().getParagraphBefore(par); - openParTag(xs, &*par, prevpar); // TODO: switch in layout for par/block? + // Output the opening tag for this environment. + Layout const & envstyle = par->layout(); + openTag(xs, envstyle.docbookwrappertag(), envstyle.docbookwrapperattr(), envstyle.docbookwrappertagtype()); + openTag(xs, envstyle.docbooktag(), envstyle.docbookattr(), envstyle.docbooktagtype()); - // Generate the contents of this environment. There is a special case if this is like some environment. - Layout const & style = par->layout(); - if (style.latextype == LATEX_COMMAND) { - // Nothing to do (otherwise, infinite loops). - } else if (style.latextype == LATEX_ENVIRONMENT || - style.latextype == LATEX_LIST_ENVIRONMENT || - style.latextype == LATEX_ITEM_ENVIRONMENT) { - // Open a wrapper tag if needed. - if (style.docbookitemwrappertag() != "NONE") - openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype()); + // Handle the content of the list environment, item by item. + while (par != envend) { + Layout const & style = par->layout(); + + // Open the item wrapper. + openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype()); // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first // character after the label. pos_type sep = 0; if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") { - // At least one condition must be met: - // - this environment is not a list - // - if this is a list, the label must not be manual (i.e. it must be taken from the layout) - if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) { + if (style.labeltype == LABEL_MANUAL) { + // Only variablelist gets here (or similar items defined as an extension in the layout). + openLabelTag(xs, style); + sep = 1 + par->firstWordDocBook(xs, runparams); + closeLabelTag(xs, style); + } else { // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. docstring const lbl = par->params().labelString(); - if (lbl.empty()) { - xs << xml::CR(); - } else { + if (!lbl.empty()) { openLabelTag(xs, style); xs << lbl; closeLabelTag(xs, style); } - } else { - // Only variablelist gets here (or similar items defined as an extension in the layout). - openLabelTag(xs, style); - sep = par->firstWordDocBook(xs, runparams); - closeLabelTag(xs, style); } } - // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph - // AND if the next paragraph doesn't have the same depth (if there is such a paragraph). - // Common case: there is only the first word on the line, but there is a nested list instead - // of more text. - bool emptyItem = false; - if (sep == par->size()) { // If the separator is already at the end of this paragraph... - auto next_par = par; - ++next_par; - if (next_par == text.paragraphs().end()) // There is no next paragraph. - emptyItem = true; - else // There is a next paragraph: check depth. - emptyItem = par->params().depth() >= next_par->params().depth(); - } + // Open the item (after the wrapper and the label). + openTag(xs, style.docbookitemtag(), style.docbookitemattr(), style.docbookitemtagtype()); - if (emptyItem) { - // Avoid having an empty item, this is not valid DocBook. A single character is enough to force - // generation of a full . - // TODO: this always worked only by magic... - xs << ' '; + // Generate the content of the item. + if (sep < par->size()) { + auto pars = par->simpleDocBookOnePar(buf, runparams, + text.outerFont(std::distance(text.paragraphs().begin(), par)), sep); + for (auto &p : pars) { + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), + par->layout().docbookiteminnertagtype()); + xs << XMLStream::ESCAPE_NONE << p; + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); + } } else { - // Generate the rest of the paragraph, if need be. Open as many inner tags as necessary. - auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep); - auto p = pars.begin(); - while (true) { - xs << XMLStream::ESCAPE_NONE << *p; - ++p; - if (p != pars.end()) { - closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); - openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); - } else - break; - } + // DocBook doesn't like emptiness. + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), + par->layout().docbookiteminnertagtype()); + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); } - } else { - makeAny(text, buf, xs, runparams, par); + + // If the next item is deeper, it must go entirely within this item (do it recursively). + // By construction, with findEndOfEnvironment, depth can only stay constant or increase, never decrease. + depth_type currentDepth = par->getDepth(); + ++par; + while (par != envend && par->getDepth() != currentDepth) + par = makeAny(text, buf, xs, runparams, par); + // Usually, this loop only makes one iteration, except in complex scenarios, like an item with a paragraph, + // a list, and another paragraph; or an item with two types of list (itemise then enumerate, for instance). + + // Close the item. + closeTag(xs, style.docbookitemtag(), style.docbookitemtagtype()); + closeTag(xs, style.docbookitemwrappertag(), style.docbookitemwrappertagtype()); } - // Close the environment. - auto nextpar = par; - ++nextpar; - closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block? + // Close this environment in exactly the same way as it was opened. + closeTag(xs, envstyle.docbooktag(), envstyle.docbooktagtype()); + closeTag(xs, envstyle.docbookwrappertag(), envstyle.docbookwrappertagtype()); - return nextpar; + return envend; } diff --git a/src/xml.cpp b/src/xml.cpp index 2f496679c9..0daa9d84e2 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -185,6 +185,12 @@ void XMLStream::writeError(docstring const &s) } +XMLStream::TagPtr XMLStream::getLastStackTag() +{ + return tag_stack_.back(); +} + + bool XMLStream::closeFontTags() { if (isTagPending(xml::parsep_tag)) diff --git a/src/xml.h b/src/xml.h index 45c62aba32..56e5d81114 100644 --- a/src/xml.h +++ b/src/xml.h @@ -125,7 +125,6 @@ private: // own these pointers and how they will be deleted, so we use shared // pointers. /// - typedef std::shared_ptr TagPtr; typedef std::deque TagDeque; /// template From 97cfabb8831ea5ab58b46f470dcecd317b26df04 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 29 Aug 2020 18:40:31 +0200 Subject: [PATCH 30/88] DocBook: fix indentation for section titles (including stars). --- autotests/export/docbook/basic.lyx | 31 ++++++++++++--- autotests/export/docbook/basic.xml | 62 +++++++++++++++++++----------- lib/layouts/stdsections.inc | 5 ++- 3 files changed, 69 insertions(+), 29 deletions(-) diff --git a/autotests/export/docbook/basic.lyx b/autotests/export/docbook/basic.lyx index 0bd87cecbb..1735dc4266 100644 --- a/autotests/export/docbook/basic.lyx +++ b/autotests/export/docbook/basic.lyx @@ -1,5 +1,5 @@ -#LyX 2.4 created this file. For more info see http://www.lyx.org/ -\lyxformat 544 +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 \begin_document \begin_header \save_transient_properties true @@ -9,11 +9,11 @@ \newcommand{\testmacro}{\ensuremath{\operatorname{testmacro}}} \end_preamble \use_default_options true -\maintain_unincluded_children false +\maintain_unincluded_children no \language english \language_package default -\inputencoding auto -\fontencoding global +\inputencoding auto-legacy +\fontencoding auto \font_roman "default" "default" \font_sans "default" "default" \font_typewriter "default" "default" @@ -21,7 +21,9 @@ \font_default_family default \use_non_tex_fonts false \font_sc false -\font_osf 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 @@ -56,6 +58,7 @@ \justification true \use_refstyle 1 \use_minted 0 +\use_lineno 0 \index Index \shortcut idx \color #008000 @@ -75,11 +78,15 @@ \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 @@ -139,6 +146,10 @@ I am a quote \end_layout +\begin_layout Standard +Now, we're outside quotes. +\end_layout + \begin_layout Standard \begin_inset Formula \[ @@ -386,6 +397,8 @@ Now, three tables: \begin_layout Standard \begin_inset Float table +placement document +alignment document wide false sideways false status open @@ -511,6 +524,8 @@ I am a table caption below the table. \begin_layout Standard \begin_inset Float table +placement document +alignment document wide false sideways false status open @@ -636,6 +651,8 @@ Col 3, row 2 \begin_layout Standard \begin_inset Float table +placement document +alignment document wide false sideways false status open @@ -753,6 +770,8 @@ Then, one figure: \begin_layout Standard \begin_inset Float figure +placement document +alignment document wide false sideways false status open diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index 6f4a828d4b..79802893f6 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -29,6 +29,7 @@ . +Now, we're outside quotes. Formula! @@ -72,22 +73,37 @@
I am the third section and I have fun with lists -First item. -
-Second line of the first item, after a line break.
-Second item. -Item has no order (1). -Item has no order (2). - - -Word description - - - - -Sentence meaning - - + + +First item. +Second line of the first item, after a line break. + + +Second item. + + + + +Item has no order (1). + + +Item has no order (2). + + + + +Word + +description + + + +Sentence + +meaning + + +
I am the fourth section and I deal with formatting. @@ -95,9 +111,11 @@ Sentence meaning - - -Book title -Book author - -Book abstract in info. + + +Book title + +Book author + + +Book abstract in info. @@ -15,9 +17,7 @@ First part - -Part intro. - +Part intro. First chapter of first part Paragraph. @@ -29,9 +29,7 @@ Second part - -Part 2 intro. - +Part 2 intro. First chapter of second part Paragraph. @@ -41,5 +39,4 @@ Paragraph. - \ No newline at end of file diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index e609f39282..38bcf05d38 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -773,21 +773,28 @@ ParagraphList::const_iterator makeAny(Text const &text, } +bool isLayoutSectioning(Layout const & lay) +{ + return lay.category() == from_utf8("Sectioning"); +} + + using DocBookDocumentSectioning = tuple; struct DocBookInfoTag { const set shouldBeInInfo; - const set mustBeInInfo; + const set mustBeInInfo; // With the notable exception of the abstract! const set abstract; + const bool abstractLayout; pit_type bpit; pit_type epit; DocBookInfoTag(const set & shouldBeInInfo, const set & mustBeInInfo, - const set & abstract, pit_type bpit, pit_type epit) : + const set & abstract, bool abstractLayout, pit_type bpit, pit_type epit) : shouldBeInInfo(shouldBeInInfo), mustBeInInfo(mustBeInInfo), abstract(abstract), - bpit(bpit), epit(epit) {} + abstractLayout(abstractLayout), bpit(bpit), epit(epit) {} }; @@ -796,7 +803,7 @@ DocBookDocumentSectioning hasDocumentSectioning(ParagraphList const ¶graphs, while (bpit < epit) { Layout const &style = paragraphs[bpit].layout(); - documentHasSections |= style.category() == from_utf8("Sectioning"); + documentHasSections |= isLayoutSectioning(style); if (documentHasSections) break; @@ -820,10 +827,14 @@ bool hasOnlyNotes(Paragraph const & par) } -DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type bpit, pit_type const epit) { +DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, + pit_type bpit, pit_type const epit, + // Typically, bpit is the beginning of the document and epit the end *or* the first section. + bool documentHasSections) { set shouldBeInInfo; set mustBeInInfo; - set abstract; + set abstractWithLayout; + set abstractNoLayout; // Find the first non empty paragraph by mutating bpit. while (bpit < epit) { @@ -834,78 +845,48 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, pit_type b break; } - // Find the last info-like paragraph. - pit_type cpit = bpit; + // Traverse everything that might belong to . bool hasAbstractLayout = false; - while (cpit < epit) { - // Skip paragraphs only containing one note. + pit_type cpit = bpit; + for (; cpit < epit; ++cpit) { + // Skip paragraphs that don't generate anything in DocBook. Paragraph const & par = paragraphs[cpit]; - if (hasOnlyNotes(par)) { - cpit += 1; + if (par.empty() || par.emptyTag() || hasOnlyNotes(par)) + continue; + + // There should never be any section here. (Just a sanity check: if this fails, this function could end up + // processing the whole document.) + if (isLayoutSectioning(par.layout())) { + LYXERR0("Assertion failed: section found in potential paragraphs."); + break; + } + + // If this is marked as an abstract by the layout, put it in the right set. + if (par.layout().docbookabstract()) { + hasAbstractLayout = true; + abstractWithLayout.emplace(cpit); continue; } - if (par.layout().docbookabstract()) - hasAbstractLayout = true; - - // Based on layout information, store this paragraph in one set: should be in , must be. + // Based on layout information, store this paragraph in one set: should be in , must be, + // or abstract (). Layout const &style = par.layout(); - if (style.docbookininfo() == "always") { + if (style.docbookininfo() == "always") mustBeInInfo.emplace(cpit); - } else if (style.docbookininfo() == "maybe") { + else if (style.docbookininfo() == "maybe") shouldBeInInfo.emplace(cpit); - } else { - // Hypothesis: the parts should be grouped together near the beginning bpit. - // There may be notes in between, but nothing else. + else if (!hasAbstractLayout) + abstractNoLayout.emplace(cpit); + else // This should definitely not be in . break; - } - cpit += 1; } - // Now, cpit points to the last paragraph that has things that could go in . + // Now, cpit points to the first paragraph that no more has things that could go in . // bpit is the beginning of the part. - // Go once again through the list of paragraphs to find the abstract. If there is an abstract - // layout, only consider it. Otherwise, an abstract is just a sequence of paragraphs with text. - if (hasAbstractLayout) { - pit_type pit = bpit; - while (pit < cpit) { // Don't overshoot the part. - if (paragraphs[pit].layout().docbookabstract()) - abstract.emplace(pit); - pit++; - } - } else { - pit_type lastAbstract = epit + 1; // A nonsensical value. - docstring lastAbstractLayout; - - pit_type pit = bpit; - while (pit < cpit) { // Don't overshoot the part. - const Paragraph & par = paragraphs.at(pit); - if (!par.insetList().empty()) { - for (const auto &i : par.insetList()) { - if (i.inset->getText(0) != nullptr) { - if (lastAbstract == epit + 1) { - // First paragraph that matches the heuristic definition of abstract. - lastAbstract = pit; - lastAbstractLayout = par.layout().name(); - } else if (pit > lastAbstract + 1 || par.layout().name() != lastAbstractLayout) { - // This is either too far from the last abstract paragraph or doesn't - // have the right layout name, BUT there has already been an abstract - // in this document: done with detecting the abstract. - goto done; // Easier to get out of two nested loops. - } - - abstract.emplace(pit); - break; - } - } - } - pit++; - } - } - - done: - return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, abstract, bpit, cpit); + return DocBookInfoTag(shouldBeInInfo, mustBeInInfo, + hasAbstractLayout ? abstractWithLayout : abstractNoLayout, + hasAbstractLayout, bpit, cpit); } } // end anonymous namespace @@ -940,17 +921,9 @@ void outputDocBookInfo( if (hasAbstract) { // Generate the abstract XML into a string before further checks. odocstringstream os2; - { - XMLStream xs2(os2); - auto bpit = *std::min_element(info.abstract.begin(), info.abstract.end()); - auto epit = 1 + *std::max_element(info.abstract.begin(), info.abstract.end()); - // info.abstract is inclusive, epit is exclusive, hence +1 for looping. - - while (bpit < epit) { - makeAny(text, buf, xs2, runparams, paragraphs.iterator_at(bpit)); - bpit += 1; - } - } + XMLStream xs2(os2); + for (auto const & p : info.abstract) + makeAny(text, buf, xs2, runparams, paragraphs.iterator_at(p)); // Actually output the abstract if there is something to do. Don't count line feeds or spaces in this, // even though they must be properly output if there is some abstract. @@ -974,27 +947,33 @@ void outputDocBookInfo( } // Output the elements that should go in , before and after the abstract. - for (auto pit : info.shouldBeInInfo) { // Typically, the title: these elements are so important and ubiquitous + for (auto pit : info.shouldBeInInfo) // Typically, the title: these elements are so important and ubiquitous // that mandating a wrapper like would repel users. Thus, generate them first. makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); - } - for (auto pit : info.mustBeInInfo) { + for (auto pit : info.mustBeInInfo) if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after. makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); - } // Always output the abstract as the last item of the , as it requires special treatment (especially if // it contains several paragraphs that are empty). if (hasAbstract) { -// string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); -// if (tag == "NONE") -// tag = "abstract"; -// -// xs << xml::StartTag(tag); -// xs << xml::CR(); - xs << XMLStream::ESCAPE_NONE << abstract; -// xs << xml::EndTag(tag); -// xs << xml::CR(); + if (info.abstractLayout) { + xs << XMLStream::ESCAPE_NONE << abstract; + xs << xml::CR(); + } else { + string tag = paragraphs[*info.abstract.begin()].layout().docbookforceabstracttag(); + if (tag == "NONE") + tag = "abstract"; + + if (!xs.isLastTagCR()) + xs << xml::CR(); + + xs << xml::StartTag(tag); + xs << xml::CR(); + xs << XMLStream::ESCAPE_NONE << abstract; + xs << xml::EndTag(tag); + xs << xml::CR(); + } } // End the tag if it was started. @@ -1006,23 +985,6 @@ void outputDocBookInfo( } -void docbookFirstParagraphs( - Text const &text, - Buffer const &buf, - XMLStream &xs, - OutputParams const &runparams, - pit_type epit) -{ - // Handle the beginning of the document, supposing it has sections. - // Major role: output the first tag. - - ParagraphList const ¶graphs = text.paragraphs(); - pit_type bpit = runparams.par_begin; - DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit); - outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); -} - - void docbookSimpleAllParagraphs( Text const & text, Buffer const & buf, @@ -1036,7 +998,7 @@ void docbookSimpleAllParagraphs( ParagraphList const ¶graphs = text.paragraphs(); pit_type bpit = runparams.par_begin; pit_type const epit = runparams.par_end; - DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit); + DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit, false); outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); // Then, the content. It starts where the ends. @@ -1071,20 +1033,24 @@ void docbookParagraphs(Text const &text, std::stack> headerLevels; // Used to determine when to open/close sections: store the depth // of the section and the tag that was used to open it. - // Detect whether the document contains sections. If there are no sections, there can be no automatically - // discovered abstract. + // Detect whether the document contains sections. If there are no sections, treatment is largely simplified. + // In particular, there can't be an abstract, unless it is manually marked. bool documentHasSections; pit_type eppit; tie(documentHasSections, eppit) = hasDocumentSectioning(paragraphs, bpit, epit); - if (documentHasSections) { - docbookFirstParagraphs(text, buf, xs, runparams, eppit); - bpit = eppit; - } else { + // Deal with "simple" documents, i.e. those without sections. + if (!documentHasSections){ docbookSimpleAllParagraphs(text, buf, xs, runparams); return; } + // Output the first tag (or just the title). + DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, eppit, true); + outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); + bpit = eppit; + + // Then, iterate through the paragraphs of this document. bool currentlyInAppendix = false; auto par = text.paragraphs().iterator_at(bpit); @@ -1102,8 +1068,7 @@ void docbookParagraphs(Text const &text, Layout const &style = par->layout(); // Think about adding
and/or
s. - const bool isLayoutSectioning = style.category() == from_utf8("Sectioning"); - if (isLayoutSectioning) { + if (isLayoutSectioning(style)) { int level = style.toclevel; // Need to close a previous section if it has the same level or a higher one (close
if opening a

From 17b06f5336241236191d7ec9eb7643669ccfbab9 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 00:58:50 +0200 Subject: [PATCH 35/88] DocBook: streamline code to handle sections. --- src/output_docbook.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 38bcf05d38..3e37f90912 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -1071,18 +1071,18 @@ void docbookParagraphs(Text const &text, if (isLayoutSectioning(style)) { int level = style.toclevel; - // Need to close a previous section if it has the same level or a higher one (close
if opening a

- // after a

,

,

,

or
). More examples: + // Need to close a previous section if it has the same level or a higher one (close
if opening a + //

after a

,

,

,

or
). More examples: // - current: h2; back: h1; do not close any
// - current: h1; back: h2; close two
(first the

, then the

, so a new

can come) while (!headerLevels.empty() && level <= headerLevels.top().first) { - int stackLevel = headerLevels.top().first; - docstring stackTag = from_utf8(""); - headerLevels.pop(); - // Output the tag only if it corresponds to a legit section. - if (stackLevel != Layout::NOT_IN_TOC) - xs << XMLStream::ESCAPE_NONE << stackTag << xml::CR(); + int stackLevel = headerLevels.top().first; + if (stackLevel != Layout::NOT_IN_TOC) { + xs << xml::EndTag(headerLevels.top().second); + xs << xml::CR(); + } + headerLevels.pop(); } // Open the new section: first push it onto the stack, then output it in DocBook. @@ -1111,11 +1111,10 @@ void docbookParagraphs(Text const &text, } // Write the open tag for this section. - docstring tag = from_utf8("<" + sectionTag); + docstring attrs; if (!id.empty()) - tag += from_utf8(" ") + id; - tag += from_utf8(">"); - xs << XMLStream::ESCAPE_NONE << tag; + attrs = id; + xs << xml::StartTag(sectionTag, attrs); xs << xml::CR(); } } From 642b18aad0b2add87ef746f78f77f3eb8467f693 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 01:14:44 +0200 Subject: [PATCH 36/88] DocBook: generate when required. --- autotests/export/docbook/basic.xml | 2 ++ autotests/export/docbook/basic_book.xml | 4 +++ src/output_docbook.cpp | 45 +++++++++++++++++++------ 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/autotests/export/docbook/basic.xml b/autotests/export/docbook/basic.xml index ea91d3d5e1..49ec1f4b97 100644 --- a/autotests/export/docbook/basic.xml +++ b/autotests/export/docbook/basic.xml @@ -12,7 +12,9 @@ I am an abstract I am also an abstract + +I am a standard paragraph.
I am the first section I am the first paragraph of the first section. diff --git a/autotests/export/docbook/basic_book.xml b/autotests/export/docbook/basic_book.xml index 18496b9521..c6e907810c 100644 --- a/autotests/export/docbook/basic_book.xml +++ b/autotests/export/docbook/basic_book.xml @@ -17,7 +17,9 @@ First part + Part intro. + First chapter of first part Paragraph. @@ -29,7 +31,9 @@ Second part + Part 2 intro. + First chapter of second part Paragraph. diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 3e37f90912..a0ac96aa75 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -821,7 +821,7 @@ bool hasOnlyNotes(Paragraph const & par) for (int i = 0; i < par.size(); ++i) // If you find something that is not an inset (like actual text) or an inset that is not a note, // return false. - if (!par.isInset(i) || !dynamic_cast(par.insetList().get(i))) + if (!par.isInset(i) || par.getInset(i)->lyxCode() != NOTE_CODE) return false; return true; } @@ -851,7 +851,7 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, for (; cpit < epit; ++cpit) { // Skip paragraphs that don't generate anything in DocBook. Paragraph const & par = paragraphs[cpit]; - if (par.empty() || par.emptyTag() || hasOnlyNotes(par)) + if (hasOnlyNotes(par)) continue; // There should never be any section here. (Just a sanity check: if this fails, this function could end up @@ -869,14 +869,14 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, } // Based on layout information, store this paragraph in one set: should be in , must be, - // or abstract (). + // or abstract (either because of layout or of position). Layout const &style = par.layout(); if (style.docbookininfo() == "always") mustBeInInfo.emplace(cpit); else if (style.docbookininfo() == "maybe") shouldBeInInfo.emplace(cpit); - else if (!hasAbstractLayout) + else if (documentHasSections && !hasAbstractLayout) abstractNoLayout.emplace(cpit); else // This should definitely not be in . break; @@ -993,17 +993,17 @@ void docbookSimpleAllParagraphs( { // Handle the given text, supposing it has no sections (i.e. a "simple" text). The input may vary in length // between a single paragraph to a whole document. + pit_type const bpit = runparams.par_begin; + pit_type const epit = runparams.par_end; + ParagraphList const ¶graphs = text.paragraphs(); // First, the tag. - ParagraphList const ¶graphs = text.paragraphs(); - pit_type bpit = runparams.par_begin; - pit_type const epit = runparams.par_end; DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, epit, false); outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); // Then, the content. It starts where the ends. - auto par = text.paragraphs().iterator_at(info.epit); - auto end = text.paragraphs().iterator_at(epit); + auto par = paragraphs.iterator_at(info.epit); + auto end = paragraphs.iterator_at(epit); while (par != end) { if (!hasOnlyNotes(*par)) par = makeAny(text, buf, xs, runparams, par); @@ -1040,7 +1040,7 @@ void docbookParagraphs(Text const &text, tie(documentHasSections, eppit) = hasDocumentSectioning(paragraphs, bpit, epit); // Deal with "simple" documents, i.e. those without sections. - if (!documentHasSections){ + if (!documentHasSections) { docbookSimpleAllParagraphs(text, buf, xs, runparams); return; } @@ -1048,7 +1048,7 @@ void docbookParagraphs(Text const &text, // Output the first tag (or just the title). DocBookInfoTag info = getParagraphsWithInfo(paragraphs, bpit, eppit, true); outputDocBookInfo(text, buf, xs, runparams, paragraphs, info); - bpit = eppit; + bpit = info.epit; // Then, iterate through the paragraphs of this document. bool currentlyInAppendix = false; @@ -1141,6 +1141,29 @@ void docbookParagraphs(Text const &text, // Generate this paragraph. par = makeAny(text, buf, xs, ourparams, par); + + // Some special sections may require abstracts (mostly parts, in books). + // TODO: docbookforceabstracttag is a bit contrived here, but it does the job. Having another field just for this would be cleaner, but that's just for and , so it's probably not worth the effort. + if (isLayoutSectioning(style) && style.docbookforceabstracttag() != "NONE") { + // This abstract may be found between the next paragraph and the next title. + pit_type cpit = std::distance(text.paragraphs().begin(), par); + pit_type ppit = std::get<1>(hasDocumentSectioning(paragraphs, cpit, epit)); + + // Generate this abstract (this code corresponds to parts of outputDocBookInfo). + DocBookInfoTag secInfo = getParagraphsWithInfo(paragraphs, cpit, ppit, true); + + if (!secInfo.abstract.empty()) { + xs << xml::StartTag(style.docbookforceabstracttag()); + xs << xml::CR(); + for (auto const &p : secInfo.abstract) + makeAny(text, buf, xs, runparams, paragraphs.iterator_at(p)); + xs << xml::EndTag(style.docbookforceabstracttag()); + xs << xml::CR(); + } + + // Skip all the text that just has been generated. + par = paragraphs.iterator_at(ppit); + } } // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning From ec0f4885a7fd9afb007c3a4604a4e75c10ac0452 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 02:30:04 +0200 Subject: [PATCH 37/88] DocBook: fix bibliographies (end of and sections). --- autotests/export/docbook/bibliography_precooked.xml | 3 +-- src/output_docbook.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked.xml b/autotests/export/docbook/bibliography_precooked.xml index 1f103bcf8a..901abd450f 100644 --- a/autotests/export/docbook/bibliography_precooked.xml +++ b/autotests/export/docbook/bibliography_precooked.xml @@ -5,11 +5,10 @@ William Shakespeare
Publications +
First Folio. Second Folio. Third Folio. -
-

\ No newline at end of file diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index a0ac96aa75..19bd1d841f 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -393,12 +393,9 @@ void makeBibliography( // If this is the last paragraph in a bibliography, close the bibliography tag. auto const end = text.paragraphs().end(); - bool endBibliography = par == end; - if (!endBibliography) { - auto nextpar = par; - ++nextpar; - endBibliography = par->layout().latextype != LATEX_BIB_ENVIRONMENT; - } + auto nextpar = par; + ++nextpar; + bool endBibliography = nextpar == end || nextpar->layout().latextype != LATEX_BIB_ENVIRONMENT; if (endBibliography) { xs << xml::EndTag("bibliography"); @@ -1124,7 +1121,7 @@ void docbookParagraphs(Text const &text, auto insetsLength = distance(par->insetList().begin(), par->insetList().end()); if (insetsLength > 0) { Inset const *firstInset = par->getInset(0); - if (firstInset && dynamic_cast(firstInset)) { + if (firstInset && (firstInset->lyxCode() == BIBITEM_CODE || firstInset->lyxCode() == BIBTEX_CODE)) { while (!headerLevels.empty()) { int level = headerLevels.top().first; docstring tag = from_utf8(""); From 1f2c51d56b4a136fd5832041c070b80d9adcc8a2 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 02:30:24 +0200 Subject: [PATCH 38/88] DocBook: adapt SimpleCV for tag types (new-line behaviour). --- lib/layouts/simplecv.layout | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/layouts/simplecv.layout b/lib/layouts/simplecv.layout index 0a69f1efaa..1cf6c30980 100644 --- a/lib/layouts/simplecv.layout +++ b/lib/layouts/simplecv.layout @@ -54,6 +54,7 @@ Style Section IsTocCaption 1 EndArgument DocBookTag title + DocBookTagType paragraph DocBookSectionTag section End @@ -176,6 +177,7 @@ Style Title EndFont HTMLTitle true DocBookTag title + DocBookTagType paragraph DocBookInInfo maybe End From fb8c07a2c76e082593152086d495b5a3f278fd31 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 02:34:49 +0200 Subject: [PATCH 39/88] DocBook: adapt AASTeX for tag types (new-line behaviour). --- .../docbook/bibliography_precooked_aastex.xml | 366 +++++++++++------- lib/layouts/aastex.layout | 3 + 2 files changed, 222 insertions(+), 147 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index fe77b72494..71fe700e56 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -3,25 +3,53 @@ See http://www.lyx.org/ for more information -->
-Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples -S. Djorgovski and Ivan R. King -Astronomy Department, University of California, Berkeley, CA 94720 -Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. -Society of Fellows, Harvard University. -present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 -C. D. Biemesderfer -National Optical Astronomy Observatories, Tucson, AZ 85719 -Visiting Programmer, Space Telescope Science Institute -Patron, Alonso's Bar and Grill -aastex-help@aas.org -R. J. Hanisch -Space Telescope Science Institute, Baltimore, MD 21218 -Patron, Alonso's Bar and Grill -clusters: globular, peanut—bosons: bozos - +Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples + +S. Djorgovski and Ivan R. King + +Astronomy Department, University of California, Berkeley, CA 94720 + + +Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation. + + +Society of Fellows, Harvard University. + + +present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138 + + + +C. D. Biemesderfer + +National Optical Astronomy Observatories, Tucson, AZ 85719 + + +Visiting Programmer, Space Telescope Science Institute + + +Patron, Alonso's Bar and Grill + +aastex-help@aas.org + + +R. J. Hanisch + +Space Telescope Science Institute, Baltimore, MD 21218 + + +Patron, Alonso's Bar and Grill + + +clusters: globular, peanut—bosons: bozos + + + This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. - - + + + +
Introduction A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades , , , but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 , seemed a unique anomaly. Then suggested a central peak in NGC 6397, and a limited photographic survey of ours found three more cases, including NGC 6624, whose sharp center had often been remarked on . @@ -107,7 +135,8 @@
Helicity Amplitudes -It has been realized that helicity amplitudes provide a convenient means for Feynman diagramFootnotes can be inserted like this. +It has been realized that helicity amplitudes provide a convenient means for Feynman diagram +Footnotes can be inserted like this. evaluations. These amplitude-level techniques are particularly convenient for calculations involving many Feynman diagrams, where the usual trace techniques for the amplitude squared becomes unwieldy. Our calculations use the helicity techniques developed by other authors ; we briefly summarize below.
Formalism @@ -133,7 +162,8 @@ - collisions can be expressed in terms of fermion strings of the form + collisions can be expressed in terms of fermion strings of the form + \bar{v}(p_{2},\sigma_{2})P_{-\tau}\hat{a}_{1}\hat{a}_{2}\cdots\hat{a}_{n}u(p_{1},\sigma_{1}), @@ -352,7 +382,9 @@ may be formed from particle four-momenta, gauge-boson polarization vectors or fermion strings with an uncontracted Lorentz index associated with final-state fermions. -Figures 1 and 2 should appear side-by-side in print + +Figures 1 and 2 should appear side-by-side in print + In the chiral representation the \gamma @@ -376,7 +408,8 @@ σ - and the unit matrix 1 as + and the unit matrix 1 as + \gamma^{\mu} & = & \left(\begin{array}{cc} 0 & \sigma_{+}^{\mu}\\ \sigma_{-}^{\mu} & 0 @@ -486,7 +519,8 @@ - giving + giving + \hat{a}=\left(\begin{array}{cc} 0 & (\hat{a})_{+}\\ (\hat{a})_{-} & 0 @@ -564,11 +598,13 @@ - The spinors are expressed in terms of two-component Weyl spinors as + The spinors are expressed in terms of two-component Weyl spinors as + u=\left(\begin{array}{c} (u)_{-}\\ (u)_{+} -\end{array}\right),v={\textbf{(}}\vdag_{+}{\textbf{,}}\vdag_{-}{\textbf{)}}.MathML export failed. Please report this as a bug. +\end{array}\right),v={\textbf{(}}\vdag_{+}{\textbf{,}}\vdag_{-}{\textbf{)}}. +MathML export failed. Please report this as a bug. The Weyl spinors are given in terms of helicity eigenstates \chi_{\lambda}(p) @@ -694,7 +730,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
Floating material and so forth -Consider a task that computes profile parameters for a modified Lorentzian of the form +Consider a task that computes profile parameters for a modified Lorentzian of the form + I=\frac{1}{1+d_{1}^{P(1+d_{2})}} @@ -732,7 +769,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - where + where + d_{1}=\sqrt{\left(\begin{array}{c} \frac{x_{1}}{R_{maj}}\end{array}\right)^{2}+\left(\begin{array}{c} \frac{y_{1}}{R_{min}}\end{array}\right)^{2}} @@ -817,11 +855,14 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - + + d_{2}=\sqrt{\left(\begin{array}{c} \frac{x_{1}}{PR_{maj}}\end{array}\right)^{2}+\left(\begin{array}{c} -\case{y_{1}}{PR_{min}}\end{array}\right)^{2}}MathML export failed. Please report this as a bug. - +\case{y_{1}}{PR_{min}}\end{array}\right)^{2}} +MathML export failed. Please report this as a bug. + + x_{1}=(x-x_{0})\cos\Theta+(y-y_{0})\sin\Theta @@ -858,7 +899,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - + + y_{1}=-(x-x_{0})\sin\Theta+(y-y_{0})\cos\Theta @@ -951,7 +993,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi -, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of . Roughly +, but the assumption is that the alternate results should be less than 90° out of phase with previous values. We have no observations of +. Roughly \nicefrac{4}{5} @@ -965,33 +1008,49 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi of the electronically submitted abstracts for AAS meetings are error-free. -We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. -IRAF, AIPS, Astropy, ... + +We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. + +IRAF, AIPS, Astropy, ... + + +
-Aurière, M. 1982, , 109, 301 -Canizares, C. R., Grindlay, J. E., Hiltner, W. A., Liller, W., and McClintock, J. E. 1978, , 224, 39 -Djorgovski, S., and King, I. R. 1984, , 277, L49 +Aurière, M. 1982, +, 109, 301 +Canizares, C. R., Grindlay, J. E., Hiltner, W. A., Liller, W., and McClintock, J. E. 1978, +, 224, 39 +Djorgovski, S., and King, I. R. 1984, +, 277, L49 Hagiwara, K., and Zeppenfeld, D. 1986, Nucl.Phys., 274, 1 -Harris, W. E., and van den Bergh, S. 1984, , 89, 1816 +Harris, W. E., and van den Bergh, S. 1984, +, 89, 1816 Hénon, M. 1961, Ann.d'Ap., 24, 369 -King, I. R. 1966, , 71, 276 +King, I. R. 1966, +, 71, 276 King, I. R. 1975, Dynamics of Stellar Systems, A. Hayli, Dordrecht: Reidel, 1975, 99 -King, I. R., Hedemann, E., Hodge, S. M., and White, R. E. 1968, , 73, 456 -Kron, G. E., Hewitt, A. V., and Wasserman, L. H. 1984, , 96, 198 -Lynden-Bell, D., and Wood, R. 1968, , 138, 495 -Newell, E. B., and O'Neil, E. J. 1978, , 37, 27 -Ortolani, S., Rosino, L., and Sandage, A. 1985, , 90, 473 -Peterson, C. J. 1976, , 81, 617 +King, I. R., Hedemann, E., Hodge, S. M., and White, R. E. 1968, +, 73, 456 +Kron, G. E., Hewitt, A. V., and Wasserman, L. H. 1984, +, 96, 198 +Lynden-Bell, D., and Wood, R. 1968, +, 138, 495 +Newell, E. B., and O'Neil, E. J. 1978, +, 37, 27 +Ortolani, S., Rosino, L., and Sandage, A. 1985, +, 90, 473 +Peterson, C. J. 1976, +, 81, 617 Spitzer, L. 1985, Dynamics of Star Clusters, J. Goodman and P. Hut, Dordrecht: Reidel, 109 - - + + - - - + + - - - - - - - + - - - +b + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + -
Terribly relevant tabular information.Terribly relevant tabular information.
Star Height +Star Height d_{x} @@ -1005,7 +1064,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + d_{y} @@ -1019,7 +1078,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + n @@ -1027,7 +1086,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + \chi^{2} @@ -1041,7 +1100,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + R_{maj} @@ -1057,7 +1116,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + R_{min} @@ -1073,15 +1132,15 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + P P -a +a PR_{maj} @@ -1099,7 +1158,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + PR_{min} @@ -1117,113 +1176,126 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi + \Theta Θ -bRef.Ref.
1 33472.5 -0.1 0.4 53 27.4 2.065 1.940 3.900 68.3 116.2 -27.6391,2 +1 33472.5 -0.1 0.4 53 27.4 2.065 1.940 3.900 68.3 116.2 -27.6391,2
2 27802.4 -0.3 -0.2 60 3.7 1.628 1.510 2.156 6.8 7.5 -26.7643 2 27802.4 -0.3 -0.2 60 3.7 1.628 1.510 2.156 6.8 7.5 -26.7643
3 29210.6 0.9 0.3 60 3.4 1.622 1.551 2.159 6.7 7.3 -40.2724 3 29210.6 0.9 0.3 60 3.4 1.622 1.551 2.159 6.7 7.3 -40.2724
4 32733.8 -1.2c-0.5 41 54.8 2.282 2.156 4.313 117.4 78.2 -35.8475,6 4 32733.8 -1.2c-0.5 41 54.8 2.282 2.156 4.313 117.4 78.2 -35.8475,6
5 9607.4 -0.4 -0.4 60 1.4 1.669c1.574 2.343 8.0 8.9 -33.4177 5 9607.4 -0.4 -0.4 60 1.4 1.669c1.574 2.343 8.0 8.9 -33.4177
6 31638.6 1.6 0.1 39 315.2 3.433 3.075 7.488 92.1 25.3 -12.052 8 6 31638.6 1.6 0.1 39 315.2 3.433 3.075 7.488 92.1 25.3 -12.052 8
aSample footnote for table  that was generated with the LaTeX table environment
-bYet another sample footnote for table 
-cAnother sample footnote for table 
-We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not. -(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983. - -
+ +a +Sample footnote for table  that was generated with the LaTeX table environment +
+ +b +Yet another sample footnote for table  +
+ +c +Another sample footnote for table  +
+ +We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not. + + +(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983. + +
\ No newline at end of file diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 74d2ab6ade..d79cd02d07 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -179,6 +179,7 @@ Style Affiliation DocBookWrapperTag author DocBookWrapperMergeWithPrevious true DocBookItemTag orgname + DocBookItemTagType paragraph DocBookInInfo always End @@ -207,6 +208,7 @@ Style Altaffilation DocBookWrapperTag author DocBookWrapperMergeWithPrevious true DocBookItemTag orgname + DocBookItemTagType paragraph DocBookInInfo always End @@ -228,6 +230,7 @@ Style Email Shape Italic EndFont DocBookTag email + DocBookTagType paragraph DocBookWrapperTag author DocBookWrapperMergeWithPrevious true DocBookInInfo always From 7ec0307b13b002e5914882ece6c76f864ef61746 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 03:08:55 +0200 Subject: [PATCH 40/88] DocBook: bug fixing in AASTeX layout. That's mostly generating DocBook tags at an inappropriate place with some metadata, rather than outputting whatever you have at your disposal. Far from satisfying, but good enough for a generic tool (see details in the new TODO). Doesn't trigger assertions. Is valid XML. --- .../docbook/bibliography_precooked_aastex.xml | 45 +++++++------------ development/DocBookToDo | 20 +++++++++ lib/layouts/aastex.layout | 24 +++++++++- lib/layouts/aastex6.layout | 7 ++- lib/layouts/aastex62.layout | 7 ++- 5 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 development/DocBookToDo diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index 71fe700e56..70b19af60c 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -382,9 +382,7 @@ clusters: globular, peanut—bosons: bozos may be formed from particle four-momenta, gauge-boson polarization vectors or fermion strings with an uncontracted Lorentz index associated with final-state fermions. - -Figures 1 and 2 should appear side-by-side in print - +Figures 1 and 2 should appear side-by-side in print In the chiral representation the \gamma @@ -634,7 +632,6 @@ Figures 1 and 2 should appear side-by-side in print by - u(p,\lambda)_{\pm} & = & (E\pm\lambda|{\textbf{p}}|)^{1/2}\chi_{\lambda}(p),\\ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi_{-\lambda}(p) @@ -724,9 +721,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi - - -
+
Floating material and so forth @@ -1008,7 +1003,7 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi of the electronically submitted abstracts for AAS meetings are error-free. - + We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. IRAF, AIPS, Astropy, ... @@ -1139,7 +1134,7 @@ IRAF, AIPS, Astropy, ... P -a +a PR_{maj} @@ -1183,7 +1178,7 @@ IRAF, AIPS, Astropy, ... Θ -b +b Ref. @@ -1235,7 +1230,7 @@ IRAF, AIPS, Astropy, ... 4 32733.8 --1.2c +-1.2c -0.5 41 54.8 @@ -1254,7 +1249,7 @@ IRAF, AIPS, Astropy, ... -0.4 60 1.4 -1.669c +1.669c 1.574 2.343 8.0 @@ -1279,23 +1274,13 @@ IRAF, AIPS, Astropy, ... - -a -Sample footnote for table  that was generated with the LaTeX table environment -
- -b -Yet another sample footnote for table  -
- -c -Another sample footnote for table  -
- -We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not. - - -(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983. - +a +Sample footnote for table  that was generated with the LaTeX table environment +b +Yet another sample footnote for table  +c +Another sample footnote for table  +We can also attach a long-ish paragraph of explanatory material to a table. Use \tablerefs to append a list of references. The following references were from a different table: I've patched them in here to show how they look, but don't take them too seriously—I certainly have not. +(1) Barbuy, Spite, & Spite 1985; (2) Bond 1980; (3) Carbon et al. 1987; (4) Hobbs & Duncan 1987; (5) Gilroy et al. 1988: (6) Gratton & Ortolani 1986; (7) Gratton & Sneden 1987; (8) Gratton & Sneden (1988); (9) Gratton & Sneden 1991; (10) Kraft et al. 1982; (11) LCL, or Laird, 1990; (12) Leep & Wallerstein 1981; (13) Luck & Bond 1981; (14) Luck & Bond 1985; (15) Magain 1987; (16) Magain 1989; (17) Peterson 1981; (18) Peterson, Kurucz, & Carney 1990; (19) RMB; (20) Schuster & Nissen 1988; (21) Schuster & Nissen 1989b; (22) Spite et al. 1984; (23) Spite & Spite 1986; (24) Hobbs & Thorburn 1991; (25) Hobbs et al. 1991; (26) Olsen 1983.
\ No newline at end of file diff --git a/development/DocBookToDo b/development/DocBookToDo new file mode 100644 index 0000000000..39ca534ecb --- /dev/null +++ b/development/DocBookToDo @@ -0,0 +1,20 @@ +Things specific to layouts +========================== + +AASTeX +------ + +No support for table notes. They could be implemented through , but it becomes a nightmare to ensure xml:id uniqueness (the only ID available here is in the inset; mix it with the table ID?). Anyway, it would require a lot of specific code to make it work, probably not worth the effort right now. + + Related parts of the layout: + Style "Table note" + InsetLayout "Flex:tablenotemark" + Alreayd used in the following test: + bibliography_precooked_aastex.lyx + +Notion of MathLetters: a group of equations. No good mapping in DocBook, maybe an informalgroup? To discuss with DocBook TC. +TableRefs, TableComments: no mapping in DocBook, not really a way to add these things. To discuss with DocBook TC. + +Clearly, with this kind of template, we're reaching the limits of such a system! Having a really good converter for all these cases would require a lot of very specific code. + +More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. \ No newline at end of file diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index d79cd02d07..78089a45c9 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -285,6 +285,11 @@ Style Abstract Series Bold Size Normal EndFont + DocBookAbstract true + DocBookInInfo always + DocBookWrapperTag abstract + DocBookWrapperMergeWithPrevious true + DocBookTag para End @@ -335,6 +340,7 @@ Style Keywords Size Normal EndFont DocBookTag keyword + DocBookTagType paragraph DocBookWrapperTag keywordset DocBookInInfo always End @@ -359,7 +365,7 @@ Style Acknowledgements Shape Italic EndFont DocBookTag para - DocBookWrapperTag acknowledgement + DocBookWrapperTag acknowledgements End @@ -432,6 +438,7 @@ Style MathLetters Font Size Normal EndFont + DocBookTag NONE End @@ -495,6 +502,9 @@ Style NoteToEditor Size Normal Shape Italic EndFont + DocBookTag remark + DocBookTagType paragraph + DocBookAttr role='to-editor' End @@ -515,6 +525,9 @@ Style TableRefs Family Roman Size Normal EndFont + DocBookTag remark + DocBookTagType paragraph + DocBookAttr role='tablerefs' End @@ -535,6 +548,9 @@ Style TableComments Family Roman Size Normal EndFont + DocBookTag remark + DocBookTagType paragraph + DocBookAttr role='tablecomments' End @@ -550,6 +566,9 @@ Style "Table note" LabelFont Color magenta EndFont + DocBookTag remark + DocBookTagType paragraph + DocBookAttr role='tablenote' End @@ -572,6 +591,9 @@ InsetLayout "Flex:tablenotemark" Color magenta Size Small EndFont + DocBookTag remark + DocBookTagType paragraph + DocBookAttr role='tablenotemark' End diff --git a/lib/layouts/aastex6.layout b/lib/layouts/aastex6.layout index 03d585ef8a..693536530a 100644 --- a/lib/layouts/aastex6.layout +++ b/lib/layouts/aastex6.layout @@ -67,8 +67,11 @@ Style Software LabelFont Shape Italic EndFont - DocBookWrapperTag para - DocBookTag application + DocBookTag remark + DocBookAttr role='software' + # Override what's taken from Keywords, but not really wanted. + DocBookWrapperTag NONE + DocBookInInfo never End # other new commands are mainly for the user preamble diff --git a/lib/layouts/aastex62.layout b/lib/layouts/aastex62.layout index 3eb7dcc44c..1ef86366c0 100644 --- a/lib/layouts/aastex62.layout +++ b/lib/layouts/aastex62.layout @@ -78,8 +78,11 @@ Style Software LabelFont Shape Italic EndFont - DocBookWrapperTag para - DocBookTag application + DocBookTag remark + DocBookAttr role='software' + # Override what's taken from Keywords, but not really wanted. + DocBookWrapperTag NONE + DocBookInInfo never End # other new commands are mainly for the user preamble From 976bd91fc2bfea65f22babcc7a9f4762a46f7795 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 03:30:56 +0200 Subject: [PATCH 41/88] DocBook: bug fixing with wrapper merging. --- .../docbook/bibliography_precooked_aastex.xml | 22 ++++++++----------- src/output_docbook.cpp | 15 ++++++++----- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/autotests/export/docbook/bibliography_precooked_aastex.xml b/autotests/export/docbook/bibliography_precooked_aastex.xml index 70b19af60c..2ab4a79d31 100644 --- a/autotests/export/docbook/bibliography_precooked_aastex.xml +++ b/autotests/export/docbook/bibliography_precooked_aastex.xml @@ -40,16 +40,15 @@ Patron, Alonso's Bar and Grill - -clusters: globular, peanut—bosons: bozos - - - + + +clusters: globular, peanut—bosons: bozos + + This is a preliminary report on surface photometry of the major fraction of known globular clusters, to see which of them show the signs of a collapsed core. We also explore some diversionary mathematics and recreational tables. + - - -
+
Introduction A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades , , , but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 , seemed a unique anomaly. Then suggested a central peak in NGC 6397, and a limited photographic survey of ours found three more cases, including NGC 6624, whose sharp center had often been remarked on . @@ -1005,11 +1004,8 @@ v(p,\lambda)_{\pm} & = & \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi of the electronically submitted abstracts for AAS meetings are error-free. We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section . More information on the AASTeX macros package are available at http://www.aas.org/publications/aastex or the AAS ftp site. - -IRAF, AIPS, Astropy, ... - - - + +IRAF, AIPS, Astropy, ...
Aurière, M. 1982, diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 19bd1d841f..2bffb0a958 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -274,8 +274,10 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar if (prevpar != nullptr) { Layout const & prevlay = prevpar->layout(); if (prevlay.docbookwrappertag() != "NONE") { - openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag() - && !lay.docbookwrappermergewithprevious(); + if (prevlay.docbookwrappertag() == lay.docbookwrappertag()) + openWrapper = !lay.docbookwrappermergewithprevious(); + else + openWrapper = true; } } @@ -308,8 +310,10 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa if (nextpar != nullptr) { Layout const & nextlay = nextpar->layout(); if (nextlay.docbookwrappertag() != "NONE") { - closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag() - && !nextlay.docbookwrappermergewithprevious(); + if (nextlay.docbookwrappertag() == lay.docbookwrappertag()) + closeWrapper = !nextlay.docbookwrappermergewithprevious(); + else + closeWrapper = true; } } @@ -948,8 +952,7 @@ void outputDocBookInfo( // that mandating a wrapper like would repel users. Thus, generate them first. makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); for (auto pit : info.mustBeInInfo) - if (info.abstract.find(pit) == info.abstract.end()) // The abstract must be in info, but is dealt with after. - makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); + makeAny(text, buf, xs, runparams, paragraphs.iterator_at(pit)); // Always output the abstract as the last item of the , as it requires special treatment (especially if // it contains several paragraphs that are empty). From 5b01c80635f9d33d405c4d9cac05aaf9f75c6aa2 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 21:51:40 +0200 Subject: [PATCH 42/88] DocBook: fix titles in KOMA Script. --- .../export/docbook/description_list_nested.xml | 13 ++++--------- autotests/export/docbook/deutsches_ert.xml | 17 ++++++++++++----- lib/layouts/scrartcl.layout | 8 ++++++-- lib/layouts/scrbook.layout | 4 +++- src/output_docbook.cpp | 3 +++ 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/autotests/export/docbook/description_list_nested.xml b/autotests/export/docbook/description_list_nested.xml index fc50c2cf6f..ec57aaac81 100644 --- a/autotests/export/docbook/description_list_nested.xml +++ b/autotests/export/docbook/description_list_nested.xml @@ -6,22 +6,19 @@ New valid value for an existing setting, - - e. g. +e. g. Automatically loaded math package - - The reason +The reason New language - - that is stored +that is stored @@ -29,11 +26,9 @@ New inset - - Of course a new inset requires a file format update. +Of course a new inset requires a file format update. - \ No newline at end of file diff --git a/autotests/export/docbook/deutsches_ert.xml b/autotests/export/docbook/deutsches_ert.xml index 1d9b725e5f..3e1260345d 100644 --- a/autotests/export/docbook/deutsches_ert.xml +++ b/autotests/export/docbook/deutsches_ert.xml @@ -5,12 +5,19 @@ Erweiterte LyX Features Version 2.3.x -vom LyX-TeamÜbersetzung und Bearbeitung: Hartmut Haase (HHa, bis März 2010),Jürgen Spitzmüller (Version 2.3.x, 2017) + +vom LyX-Team +Übersetzung und Bearbeitung: Hartmut Haase (HHa, bis März 2010), +Jürgen Spitzmüller (Version 2.3.x, 2017) + + -Einleitung -Wählen Sie hierfür Dokument⇒Einstellungen⇒LaTeX-Vorspann. Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben können.Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie nicht, dass die LyXTastenkombinationen darin funktionieren. - LyX fügt alles im LaTeX-Vorspann-Fenster zu seinem eingebauten Vorspann hinzu. Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie prüfen, ob LyX das nicht bereits unterstützt (Erinnern Sie sich, was wir über das Rad noch einmal erfinden sagten?). Außerdem: stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind. LyX prüft das nicht. Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die Fehlermeldung Missing \begin{document}. Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!. +Einleitung +Wählen Sie hierfür Dokument⇒Einstellungen⇒LaTeX-Vorspann. Dies öffnet ein Editierfenster, in das Sie Ihre bevorzugten Befehle schreiben können. +Das Editierverhalten in diesem Fenster ist spezifisch, also erwarten Sie nicht, dass die LyX +Tastenkombinationen darin funktionieren. + LyX fügt alles im LaTeX-Vorspann-Fenster zu seinem eingebauten Vorspann hinzu. Bevor Sie Ihre eigenen Deklarationen zum Vorspann hinzufügen, sollten Sie prüfen, ob LyX das nicht bereits unterstützt (Erinnern Sie sich, was wir über das Rad noch einmal erfinden sagten?). Außerdem: stellen Sie sicher, dass Ihre Vorspannzeilen richtig sind. LyX prüft das nicht. Wenn der Vorspann fehlerhaft ist, bekommen Sie sehr wahrscheinlich die Fehlermeldung Missing \begin{document}. Sollten Sie diese jemals bekommen, prüfen Sie Ihren Vorspann!. + - \ No newline at end of file diff --git a/lib/layouts/scrartcl.layout b/lib/layouts/scrartcl.layout index 1b27e898df..4f2a8d4611 100644 --- a/lib/layouts/scrartcl.layout +++ b/lib/layouts/scrartcl.layout @@ -26,7 +26,9 @@ Style Part Font Size Larger EndFont - DocBookTag part + DocBookTag title + DocBookTagType paragraph + DocBookSectionTag part End Style Part* @@ -36,5 +38,7 @@ Style Part* Font Size Larger EndFont - DocBookTag part + DocBookTag title + DocBookTagType paragraph + DocBookSectionTag part End diff --git a/lib/layouts/scrbook.layout b/lib/layouts/scrbook.layout index 60caa1c9f3..01d16ca9d8 100644 --- a/lib/layouts/scrbook.layout +++ b/lib/layouts/scrbook.layout @@ -18,7 +18,9 @@ NoStyle Abstract Style Chapter LabelString "\thechapter" TocLevel 0 - DocBookTag chapter + DocBookTag title + DocBookTagType paragraph + DocBookSectionTag chapter End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 2bffb0a958..cf76bf4ee8 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -978,6 +978,9 @@ void outputDocBookInfo( // End the tag if it was started. if (needInfo) { + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::EndTag("info"); xs << xml::CR(); xs.endDivision(); From 6688b076cc6994b57564ba575d8276bd68f4bd2d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 22:05:40 +0200 Subject: [PATCH 43/88] DocBook: fixes in lists. Actually output something when list item is empty. XMLStream discarded the sequence StartTag/EndTag (nothing in between). New-line behaviour around term in description lists. --- autotests/export/docbook/Development.xml | 83 ++++++++++++------------ lib/layouts/beamer.layout | 1 + lib/layouts/egs.layout | 1 + lib/layouts/hollywood.layout | 1 + lib/layouts/scrclass.inc | 1 + lib/layouts/svcommon.inc | 1 + src/output_docbook.cpp | 22 ++++++- src/xml.cpp | 3 +- 8 files changed, 68 insertions(+), 45 deletions(-) diff --git a/autotests/export/docbook/Development.xml b/autotests/export/docbook/Development.xml index d0bc9a4fbf..9ec891d0b3 100644 --- a/autotests/export/docbook/Development.xml +++ b/autotests/export/docbook/Development.xml @@ -6,7 +6,7 @@ Version 2.3.x
File formats -
+
When is an update of the .lyx file format number needed? When you are working on a new feature you may ask yourself whether it needs an update of the .lyx file format number. Whether an update is needed or not is not always obvious. Rule of thumb:
@@ -17,30 +17,30 @@ New document setting - Whenever you introduce a new setting that is stored in the document header, a file format update is needed. +Whenever you introduce a new setting that is stored in the document header, a file format update is needed. Removed document setting - If a certain setting becomes obsolete and gets removed, a file format update is needed. +If a certain setting becomes obsolete and gets removed, a file format update is needed. New valid value for an existing setting, - e. g. +e. g. Automatically loaded math package - The reason for this is that there is no true ERT inset for math formulas: Each command is parsed, and if a user happens to define a local command with the same name as a command that triggers an automatic load of a package, they need to be able to switch off the automatic loading of that package. This switch is stored by the use_package header setting. +The reason for this is that there is no true ERT inset for math formulas: Each command is parsed, and if a user happens to define a local command with the same name as a command that triggers an automatic load of a package, they need to be able to switch off the automatic loading of that package. This switch is stored by the use_package header setting. New language - that is stored in \language. +that is stored in \language. @@ -49,49 +49,49 @@ New inset - Of course a new inset requires a file format update. +Of course a new inset requires a file format update. New style - If a new style or inset layout is added to any layout file or module shipped with LyX, then a new file format is needed in the master (development) branch. It is possible to backport new styles to the stable version without a file format change. +If a new style or inset layout is added to any layout file or module shipped with LyX, then a new file format is needed in the master (development) branch. It is possible to backport new styles to the stable version without a file format change. Removed style - If a style or inset layout is removed in any layout file or module shipped with LyX, a new file format is required. +If a style or inset layout is removed in any layout file or module shipped with LyX, a new file format is required. However, new layouts and modules do not require a file format update (changed 03/16). If you are still unsure, please ask on the development list. -
+
Output formats The following output formats are currently tested for each sample document: LyX: - + lyx16 - LyX 1.6 file format (lyx2lyx) +LyX 1.6 file format (lyx2lyx) lyx21 - LyX 2.1 file format (lyx2lyx) +LyX 2.1 file format (lyx2lyx) xhtml - LyXHTML (native LyX HTML export) +LyXHTML (native LyX HTML export) @@ -100,54 +100,54 @@ LyX + LaTeX: - + dvi - DVI (8-bit latex) +DVI (8-bit latex) dvi3_texF - DVI (LuaTeX with 8-bit TeX fonts) +DVI (LuaTeX with 8-bit TeX fonts) dvi3_systemF - DVI (LuaTeX with Unicode fonts) +DVI (LuaTeX with Unicode fonts) pdf2 - PDF (pdflatex) +PDF (pdflatex) pdf4_texF - PDF (XeTeX with 8-bit TeX fonts) +PDF (XeTeX with 8-bit TeX fonts) pdf4_systemF - PDF (XeTeX with Unicode fonts) +PDF (XeTeX with Unicode fonts) pdf5_texF - PDF (LuaTeX with 8-bit TeX fonts) +PDF (LuaTeX with 8-bit TeX fonts) pdf5_systemF - PDF (LuaTeX with Unicode fonts) +PDF (LuaTeX with Unicode fonts) @@ -156,18 +156,18 @@ LyX + LaTeX + postprocessing: - + pdf - DVI -> PS (dvips) -> PDF (ps2pdf) +DVI -> PS (dvips) -> PDF (ps2pdf) pdf3 - DVI -> PDF (dvipdfm) +DVI -> PDF (dvipdfm) @@ -176,90 +176,90 @@ not tested: - (or only if set as default output format in the document source) +(or only if set as default output format in the document source) latex - LaTeX (plain) +LaTeX (plain) luatex - LaTeX (LuaTeX) +LaTeX (LuaTeX) dviluatex - LaTeX (dviluatex) +LaTeX (dviluatex) pdflatex - LaTeX (pdflatex) +LaTeX (pdflatex) platex - LaTeX (pLaTeX) +LaTeX (pLaTeX) xetex - LaTeX (XeTeX) +LaTeX (XeTeX) eps3 - EPS (encapsulated Postscript) (cropped) +EPS (encapsulated Postscript) (cropped) ps - DVI -> Postscript (dvips) +DVI -> Postscript (dvips) odf - + text - (nor text2, ..., text4) +(nor text2, ..., text4) textparagraph - + word - + word2 - + wordhtml - + @@ -269,5 +269,4 @@
- \ No newline at end of file diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index b316b14159..f6d17c3b7e 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -234,6 +234,7 @@ Style Description DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout index 0298b69e3b..6ee01ed970 100644 --- a/lib/layouts/egs.layout +++ b/lib/layouts/egs.layout @@ -269,6 +269,7 @@ Style Description DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End diff --git a/lib/layouts/hollywood.layout b/lib/layouts/hollywood.layout index 38767c40c3..7d10bb9846 100644 --- a/lib/layouts/hollywood.layout +++ b/lib/layouts/hollywood.layout @@ -142,6 +142,7 @@ Style Description DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End diff --git a/lib/layouts/scrclass.inc b/lib/layouts/scrclass.inc index 1a41a4d9d6..9524ec0f81 100644 --- a/lib/layouts/scrclass.inc +++ b/lib/layouts/scrclass.inc @@ -69,6 +69,7 @@ Style Labeling DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End Input stdsections.inc diff --git a/lib/layouts/svcommon.inc b/lib/layouts/svcommon.inc index 57573cc1e4..67ed799652 100644 --- a/lib/layouts/svcommon.inc +++ b/lib/layouts/svcommon.inc @@ -620,6 +620,7 @@ Style Description DocBookItemTag listitem DocBookItemInnerTag para DocBookItemLabelTag term + DocBookItemLabelTagType paragraph End Style Petit diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index cf76bf4ee8..d672144d1d 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -255,6 +255,25 @@ void closeTag(XMLStream & xs, const std::string & tag, const std::string & tagty } +void compTag(XMLStream & xs, const std::string & tag, const std::string & attr, const std::string & tagtype) +{ + if (tag.empty() || tag == "NONE") + return; + + // Special case for : always considered as a paragraph. + if (tag == "para" || tagtype == "paragraph" || tagtype == "block") { + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::CompTag(tag, attr); + xs << xml::CR(); + } else if (tagtype == "inline") { + xs << xml::CompTag(tag, attr); + } else { + xs.writeError("Unrecognised tag type '" + tagtype + "' for '" + tag + "'"); + } +} + + // Higher-level convenience functions. void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) @@ -692,9 +711,8 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text, } } else { // DocBook doesn't like emptiness. - openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), + compTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); - closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); } // If the next item is deeper, it must go entirely within this item (do it recursively). diff --git a/src/xml.cpp b/src/xml.cpp index 557bb01f4b..150f4c52b9 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -651,7 +651,8 @@ docstring xml::cleanID(docstring const & orig) // as both of them would be transformed as "a.b". With this procedure, one will become "a.b" and the other "a.b-1". if (mangle && mangledNames.find(content) != mangledNames.end()) { int & mangleID = tMangleID.localData(); - content += "-" + convert(mangleID); + if (mangleID > 0) + content += "-" + convert(mangleID); mangleID += 1; } From c3aa843da8ad1d56b54ac287a585022946422661 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 22:08:01 +0200 Subject: [PATCH 44/88] DocBook: fixes in bibliography (missing new line at the end). --- autotests/export/docbook/easy.xml | 5 +++-- autotests/export/docbook/issue_infinite_loop.xml | 5 +++-- src/insets/InsetBibtex.cpp | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/autotests/export/docbook/easy.xml b/autotests/export/docbook/easy.xml index 883c98226e..e3013211bc 100644 --- a/autotests/export/docbook/easy.xml +++ b/autotests/export/docbook/easy.xml @@ -12,8 +12,9 @@ I am an abstract I am also an abstract + -
+
I am the first section I am the first paragraph of the first section. I am the second paragraph of the first section. @@ -50,7 +51,7 @@
I am the second section I am the only paragraph of the second section. Hyperlink. “Text between quotes.” -See . +See .
I am the third section and I deal with star sections diff --git a/autotests/export/docbook/issue_infinite_loop.xml b/autotests/export/docbook/issue_infinite_loop.xml index d6e55ee90e..e262ed48aa 100644 --- a/autotests/export/docbook/issue_infinite_loop.xml +++ b/autotests/export/docbook/issue_infinite_loop.xml @@ -5,7 +5,8 @@ William Shakespeare
Publications -First Folio. Me. 1623..
- + +First Folio. Me. 1623.. + \ No newline at end of file diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index c03a8e24d3..05fd23dfb8 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1411,6 +1411,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const // Footer for bibliography. xs << xml::EndTag("bibliography"); + xs << xml::CR(); } From 7a1b82a16ae5594e7354c507ecb47082abada9f4 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 23:29:02 +0200 Subject: [PATCH 45/88] DocBook: fix issue with fonts. --- autotests/export/docbook/issue1732_charstyles-docbook.xml | 1 - src/xml.cpp | 3 --- 2 files changed, 4 deletions(-) diff --git a/autotests/export/docbook/issue1732_charstyles-docbook.xml b/autotests/export/docbook/issue1732_charstyles-docbook.xml index 0ed9b879ae..fc9bffed0d 100644 --- a/autotests/export/docbook/issue1732_charstyles-docbook.xml +++ b/autotests/export/docbook/issue1732_charstyles-docbook.xml @@ -3,5 +3,4 @@ See http://www.lyx.org/ for more information -->
Fett hervorgehoben monospace unterstrichen. -
\ No newline at end of file diff --git a/src/xml.cpp b/src/xml.cpp index 150f4c52b9..dd9790f2e8 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -208,9 +208,6 @@ bool XMLStream::closeFontTags() if (**curtag != xml::parsep_tag) os_ << (*curtag)->writeEndTag(); tag_stack_.pop_back(); - // this shouldn't happen, since then the font tags - // weren't in any other tag. - LASSERT(!tag_stack_.empty(), return true); if (tag_stack_.empty()) return true; curtag = &tag_stack_.back(); From 9d3a717ef1eda27ab2b58ae84b483d044364e156 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 23:38:40 +0200 Subject: [PATCH 46/88] DocBook: fix font issues when a paragraph has an InsetNewline. --- autotests/export/docbook/issue5165.xml | 5 +++-- .../export/docbook/labeling_list_nested.xml | 19 ++++++------------- autotests/export/docbook/list_depth.xml | 5 ++--- src/Paragraph.cpp | 5 ++++- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/autotests/export/docbook/issue5165.xml b/autotests/export/docbook/issue5165.xml index 2e24ebcaf2..81d840d582 100644 --- a/autotests/export/docbook/issue5165.xml +++ b/autotests/export/docbook/issue5165.xml @@ -4,9 +4,10 @@
Title -Author + +Author + Date Content -
\ No newline at end of file diff --git a/autotests/export/docbook/labeling_list_nested.xml b/autotests/export/docbook/labeling_list_nested.xml index 261605c4d9..4ecb1c6360 100644 --- a/autotests/export/docbook/labeling_list_nested.xml +++ b/autotests/export/docbook/labeling_list_nested.xml @@ -7,22 +7,19 @@ LyX: - - + lyx16 - - LyX 1.6 file format (lyx2lyx) +LyX 1.6 file format (lyx2lyx) lyx21 - - + @@ -30,27 +27,23 @@ LyX: - - + lyx16 - - LyX 1.6 file format (lyx2lyx) +LyX 1.6 file format (lyx2lyx) lyx21 - - + - \ No newline at end of file diff --git a/autotests/export/docbook/list_depth.xml b/autotests/export/docbook/list_depth.xml index 3833931da9..5eaa83c2b1 100644 --- a/autotests/export/docbook/list_depth.xml +++ b/autotests/export/docbook/list_depth.xml @@ -1,7 +1,7 @@ -
+
Test document @@ -9,5 +9,4 @@ Content. - -
+
\ No newline at end of file diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index aad1ccf142..b4e4bc3ddb 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3358,12 +3358,15 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, if (isDeleted(i)) continue; - // If this is an InsetNewline, generate a new paragraph. + // If this is an InsetNewline, generate a new paragraph. Also reset the fonts, so that tags are closed in + // this paragraph. if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) { + xs->closeFontTags(); generatedParagraphs.push_back(os.str()); os = odocstringstream(); delete xs; xs = new XMLStream(os); + font_old = outerfont.fontInfo(); } // Determine which tags should be opened or closed. From 654559feb8b4ed357647554b4043b6c631482b4e Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 30 Aug 2020 23:56:16 +0200 Subject: [PATCH 47/88] DocBook: fix line issues around programlisting. --- autotests/export/docbook/listings.xml | 3 +-- src/Paragraph.cpp | 7 +++++-- src/Paragraph.h | 3 ++- src/insets/InsetListings.cpp | 4 ++++ src/output_docbook.cpp | 6 +++--- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/autotests/export/docbook/listings.xml b/autotests/export/docbook/listings.xml index e65de60a90..1ed2694db3 100644 --- a/autotests/export/docbook/listings.xml +++ b/autotests/export/docbook/listings.xml @@ -5,6 +5,5 @@ Test document This is a programlisting: First line of programlisting -Second line of programlisting - +Second line of programlisting \ No newline at end of file diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b4e4bc3ddb..b88c381c9d 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3332,7 +3332,8 @@ std::tuple, vector> computeDocBookFontSwit std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, OutputParams const & runparams, Font const & outerfont, - pos_type initial) const + pos_type initial, + bool is_last_par) const { // Track whether we have opened these tags DocBookFontState fs; @@ -3409,7 +3410,9 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, // I'm worried about what happens if a branch, say, is itself // wrapped in some font stuff. I think that will not work. xs->closeFontTags(); - if (runparams.docbook_in_listing) + + // In listings, new lines are very important. Avoid generating one for the last line. + if (runparams.docbook_in_listing && !is_last_par) *xs << xml::CR(); // Finalise the last (and most likely only) paragraph. diff --git a/src/Paragraph.h b/src/Paragraph.h index ee314031ba..96c19c0f49 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -213,7 +213,8 @@ public: std::vector simpleDocBookOnePar(Buffer const & buf, OutputParams const & runparams, Font const & outerfont, - pos_type initial = 0) const; + pos_type initial = 0, + bool is_last_par = false) const; /// \return any material that has had to be deferred until after the /// paragraph has closed. diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 848e4ae45a..93daab4a33 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -485,6 +485,9 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const { InsetLayout const & il = getLayout(); + if (!xs.isLastTagCR()) + xs << xml::CR(); + // Forge the attributes. string attrs; if (!il.docbookattr().empty()) @@ -517,6 +520,7 @@ void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const // Done with the listing. xs.endDivision(); xs << xml::EndTag(il.docbooktag()); + xs << xml::CR(); } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index d672144d1d..808b4cf66c 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -504,8 +504,6 @@ void makeParagraph( // or we're not in the last paragraph, anyway. // (ii) We didn't open it and docbook_in_par is true, // but we are in the first par, and there is a next par. - auto nextpar = par; - ++nextpar; bool const close_par = open_par && (!runparams.docbook_in_par); // Determine if this paragraph has some real content. Things like new pages are not caught @@ -513,7 +511,9 @@ void makeParagraph( // Thus, remove all spaces (including new lines: \r, \n) before checking for emptiness. // std::all_of allows doing this check without having to copy the string. // Open and close tags around each contained paragraph. - auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0); + auto nextpar = par; + ++nextpar; + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end); for (auto & parXML : pars) { if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) { if (open_par) From e995414917937e1fd8bdf108c8269777cf215719 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:18:35 +0200 Subject: [PATCH 48/88] DocBook: avoid generating fonts for "special cases" like equations. --- autotests/export/docbook/lists.xml | 2 +- autotests/export/docbook/math_in_font.xml | 8 +++-- src/Paragraph.cpp | 42 +++++++++++++---------- src/Paragraph.h | 3 +- src/output_docbook.cpp | 2 +- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/autotests/export/docbook/lists.xml b/autotests/export/docbook/lists.xml index 6812230064..ce2d9701d1 100644 --- a/autotests/export/docbook/lists.xml +++ b/autotests/export/docbook/lists.xml @@ -125,7 +125,7 @@ LyX: - + lyx16 diff --git a/autotests/export/docbook/math_in_font.xml b/autotests/export/docbook/math_in_font.xml index 0758a2e0e6..45bb5442a2 100644 --- a/autotests/export/docbook/math_in_font.xml +++ b/autotests/export/docbook/math_in_font.xml @@ -4,7 +4,8 @@
LyX Some text before. -\cfrac[l]{A}{B+C}\,,\,\cfrac{A}{B+C}\,,\,\cfrac[r]{A}{B+C} + +\cfrac[l]{A}{B+C}\,,\,\cfrac{A}{B+C}\,,\,\cfrac[r]{A}{B+C} @@ -35,6 +36,7 @@ - Some text after. - + + +Some text after.
\ No newline at end of file diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index b88c381c9d..9dea24b1e7 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3333,7 +3333,8 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, OutputParams const & runparams, Font const & outerfont, pos_type initial, - bool is_last_par) const + bool is_last_par, + bool ignore_fonts) const { // Track whether we have opened these tags DocBookFontState fs; @@ -3362,33 +3363,37 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, // If this is an InsetNewline, generate a new paragraph. Also reset the fonts, so that tags are closed in // this paragraph. if (getInset(i) != nullptr && getInset(i)->lyxCode() == NEWLINE_CODE) { - xs->closeFontTags(); + if (!ignore_fonts) + xs->closeFontTags(); generatedParagraphs.push_back(os.str()); os = odocstringstream(); delete xs; xs = new XMLStream(os); - font_old = outerfont.fontInfo(); + if (!ignore_fonts) + font_old = outerfont.fontInfo(); } - // Determine which tags should be opened or closed. + // Determine which tags should be opened or closed regarding fonts. Font const font = getFont(buf.masterBuffer()->params(), i, outerfont); - tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs); + if (!ignore_fonts) { + tie(tagsToOpen, tagsToClose) = computeDocBookFontSwitch(font_old, font, default_family, fs); - // FIXME XHTML - // Other such tags? What about the other text ranges? + // FIXME XHTML + // Other such tags? What about the other text ranges? - vector::const_iterator cit = tagsToClose.begin(); - vector::const_iterator cen = tagsToClose.end(); - for (; cit != cen; ++cit) - *xs << *cit; + vector::const_iterator cit = tagsToClose.begin(); + vector::const_iterator cen = tagsToClose.end(); + for (; cit != cen; ++cit) + *xs << *cit; - vector::const_iterator sit = tagsToOpen.begin(); - vector::const_iterator sen = tagsToOpen.end(); - for (; sit != sen; ++sit) - *xs << *sit; + vector::const_iterator sit = tagsToOpen.begin(); + vector::const_iterator sen = tagsToOpen.end(); + for (; sit != sen; ++sit) + *xs << *sit; - tagsToClose.clear(); - tagsToOpen.clear(); + tagsToClose.clear(); + tagsToOpen.clear(); + } if (Inset const * inset = getInset(i)) { if (!runparams.for_toc || inset->isInToc()) { @@ -3409,7 +3414,8 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, // FIXME, this code is just imported from XHTML // I'm worried about what happens if a branch, say, is itself // wrapped in some font stuff. I think that will not work. - xs->closeFontTags(); + if (!ignore_fonts) + xs->closeFontTags(); // In listings, new lines are very important. Avoid generating one for the last line. if (runparams.docbook_in_listing && !is_last_par) diff --git a/src/Paragraph.h b/src/Paragraph.h index 96c19c0f49..597a10b764 100644 --- a/src/Paragraph.h +++ b/src/Paragraph.h @@ -214,7 +214,8 @@ public: OutputParams const & runparams, Font const & outerfont, pos_type initial = 0, - bool is_last_par = false) const; + bool is_last_par = false, + bool ignore_fonts = false) const; /// \return any material that has had to be deferred until after the /// paragraph has closed. diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 808b4cf66c..c80988b492 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -513,7 +513,7 @@ void makeParagraph( // Open and close tags around each contained paragraph. auto nextpar = par; ++nextpar; - auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end); + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case); for (auto & parXML : pars) { if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) { if (open_par) From 91982ee105c84395cebb637444e52342938edc39 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:21:12 +0200 Subject: [PATCH 49/88] DocBook: new lines around formulae. --- .../export/docbook/mathml_ns_entities.xml | 29 ++++++++++--------- src/mathed/InsetMathHull.cpp | 12 +++++--- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/autotests/export/docbook/mathml_ns_entities.xml b/autotests/export/docbook/mathml_ns_entities.xml index 2ee7f39b61..0c1509e8c9 100644 --- a/autotests/export/docbook/mathml_ns_entities.xml +++ b/autotests/export/docbook/mathml_ns_entities.xml @@ -1,21 +1,24 @@ -
+
Test document A formula: - - - \Vert,\vert + +\Vert,\vert + + ,| - - A second formula: - - - \left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0} + + +A second formula: + +\left\Vert \mathbf{a^{T}\,x}\right\Vert _{2}\leq x_{0} + + @@ -45,7 +48,7 @@ - - - -
+ + + +
\ No newline at end of file diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index af30e8eea7..e7326b64e5 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -2418,13 +2418,11 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons { // Choose the tag around the MathML equation. docstring name; + bool doCR = false; if (getType() == hullSimple) name = from_ascii("inlineequation"); else { - // This is a block equation, always have on its own line. - if (!xs.isLastTagCR()) - xs << xml::CR(); - + doCR = true; // This is a block equation, always have on its own line. name = from_ascii("informalequation"); } @@ -2439,6 +2437,10 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons } } + if (doCR) + if (!xs.isLastTagCR()) + xs << xml::CR(); + xs << xml::StartTag(name, attr); xs << xml::CR(); @@ -2485,6 +2487,8 @@ void InsetMathHull::docbook(XMLStream & xs, OutputParams const & runparams) cons xs << XMLStream::ESCAPE_NONE << osmath.str(); xs << xml::CR(); xs << xml::EndTag(name); + if (doCR) + xs << xml::CR(); } From 6d246bba695bdfd414c0359891fbbb4e9a061f99 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:42:32 +0200 Subject: [PATCH 50/88] DocBook: fix margin notes. They were nested twice in . Also fixes a new line issue. --- lib/layouts/stdinsets.inc | 3 +-- src/insets/InsetMarginal.cpp | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index 04c464a1e3..ab15f77456 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -44,8 +44,7 @@ InsetLayout Marginal EndHTMLStyle AddToToc marginalnote IsTocCaption true - DocBookTag sidebar - DocBookAttr role="margin" + DocBookTag para End InsetLayout Foot diff --git a/src/insets/InsetMarginal.cpp b/src/insets/InsetMarginal.cpp index 5d2fb909f2..3a5296d089 100644 --- a/src/insets/InsetMarginal.cpp +++ b/src/insets/InsetMarginal.cpp @@ -49,6 +49,7 @@ void InsetMarginal::docbook(XMLStream & xs, OutputParams const & runparams) cons xs << xml::StartTag("sidebar", "role=\"margin\""); xs << xml::CR(); xs << XMLStream::ESCAPE_NONE << ""; + xs << xml::CR(); InsetText::docbook(xs, runparams); xs << xml::EndTag("sidebar"); } From ff2e4ec7e65f43bf09b92f4b6b4be9ce135223d3 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:43:02 +0200 Subject: [PATCH 51/88] DocBook: support Full Width from Tufte Book. --- autotests/export/docbook/Tufte_Book.xml | 28 +++++++++++++++---------- lib/layouts/tufte-book.layout | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/autotests/export/docbook/Tufte_Book.xml b/autotests/export/docbook/Tufte_Book.xml index 3fb7f2405d..4968e25a7b 100644 --- a/autotests/export/docbook/Tufte_Book.xml +++ b/autotests/export/docbook/Tufte_Book.xml @@ -3,26 +3,32 @@ See http://www.lyx.org/ for more information --> - Tufte Examples + +Fake Author + -The Features of the Tufte-book Class + +The Features of the Tufte-book Class + In this document, it was endeavored to show some of the features of the Tufte-book class. In the first chapter, their use is outlined. In the second chapter, their use through a handout that was created in a calculus class is demonstrated.
-Working with Text -One of the most prominent and distinctive features of this style is the extensive use of sidenotes. There is a wide margin to provide ample room for sidenotes and small figures. Any footnotes will automatically be converted to sidenotes.This is a sidenote that was entered using a footnote. - Alternatively, you can also use the Sidenote inset directly; you'll find it in the Insert⇒Custom Insets menu.This is a sidenote that was entered using a sidenote. + +Working with Text + +One of the most prominent and distinctive features of this style is the extensive use of sidenotes. There is a wide margin to provide ample room for sidenotes and small figures. Any footnotes will automatically be converted to sidenotes. +This is a sidenote that was entered using a footnote. + Alternatively, you can also use the Sidenote inset directly; you'll find it in the Insert⇒Custom Insets menu.This is a sidenote that was entered using a sidenote. If you like to place ancillary information in the margin without the sidenote mark (the superscript number), you can use the Marginnote inset. This is Tufte's margin note. Notice that there isn't a number preceding the note, and there is no number in the main text where this note was written. The normal margin note will work as well, but it will look rather odd. -<?dbfo float-type="margin.note"?>This is a normal margin note. Don't use it. -Another useful innovation is Tufte's NewThought character style (Edit⇒TextStyle⇒NewThought). It introduces new thoughts by means of small caps, as demonstrated in this paragraph. + +This is a normal margin note. Don't use it. +Another useful innovation is Tufte's NewThought character style (Edit⇒TextStyle⇒NewThought). It introduces new thoughts by means of small caps, as demonstrated in this paragraph. The Tufte document classes include two new character styles and some improvements on existing commands for letterspacing. -When setting strings of ALL CAPS or small caps, the letterspacing—that is, the spacing between the letters—should be increased slightly. The AllCaps character style (Edit⇒TextStyle⇒AllCaps) has proper letterspacing for strings of FULL CAPITAL LETTERS, and the SmallCaps character style (Edit⇒TextStyle⇒SmallCaps) has letterspacing for small capital letters. These commands will also automatically convert the case of the text to upper- or lowercase, respectively. +When setting strings of ALL CAPS or small caps, the letterspacing—that is, the spacing between the letters—should be increased slightly. The AllCaps character style (Edit⇒TextStyle⇒AllCaps) has proper letterspacing for strings of FULL CAPITAL LETTERS, and the SmallCaps character style (Edit⇒TextStyle⇒SmallCaps) has letterspacing for small capital letters. These commands will also automatically convert the case of the text to upper- or lowercase, respectively. The normal Small Caps shape has also been redefined to include letterspacing. Its case is left as is, however. This allows one to use both uppercase and lowercase letters: The Initial Letters Of The Words In This Sentence Are Capitalized. Finally, the Full Width paragraph environment provides a paragraph layout that stretches across the main text block and the sidenotes area: - -Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. - +Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.
diff --git a/lib/layouts/tufte-book.layout b/lib/layouts/tufte-book.layout index 2b88ca308f..e469996b42 100644 --- a/lib/layouts/tufte-book.layout +++ b/lib/layouts/tufte-book.layout @@ -243,6 +243,8 @@ Style Full_Width Align Block AlignPossible Block, Left, Right, Center LabelType No_Label + DocBookTag para + DocBookAttr role='fullwidth' End # this steps the counters From 8f3d0fd88fa69d2b8b3f523a02fed88d55cdc22a Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:45:19 +0200 Subject: [PATCH 52/88] DocBook: new-line behaviour in bibliographies. --- autotests/export/docbook/Tufte_Book.xml | 7 +++++-- src/BiblioInfo.cpp | 2 ++ src/insets/InsetBibtex.cpp | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/autotests/export/docbook/Tufte_Book.xml b/autotests/export/docbook/Tufte_Book.xml index 4968e25a7b..3289cfd763 100644 --- a/autotests/export/docbook/Tufte_Book.xml +++ b/autotests/export/docbook/Tufte_Book.xml @@ -34,12 +34,15 @@ Working with Text References -The Elements of Typographic Style3.1book +The Elements of Typographic Style +3.1 +book Hartley & Marks 2005 - + + Robert Bringhurst diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 7005519ac3..6d2af6cd47 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -1700,6 +1700,8 @@ docstring authorsToDocBookAuthorGroup(docstring const & authorsString, XMLStream // Output the list of authors. xs << xml::StartTag("authorgroup"); + xs << xml::CR(); + auto it = authors.cbegin(); auto en = authors.cend(); for (size_t i = 0; it != en; ++it, ++i) { diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 05fd23dfb8..bee485eeb6 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -1200,6 +1200,7 @@ void InsetBibtex::docbook(XMLStream & xs, OutputParams const &) const xs << xml::StartTag(toDocBookTag[match[1]]); xs << from_utf8(match[2].str()); xs << xml::EndTag(toDocBookTag[match[1]]); + xs << xml::CR(); } } else { LYXERR0("The BibTeX field " << match[1].str() << " is unknown."); From b5312cf51f7371044539aa492144cc6992374847 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:46:49 +0200 Subject: [PATCH 53/88] DocBook: subfigures example is fixed. Probably thanks to the magic of the previous commits. --- autotests/export/docbook/subfigures.xml | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/autotests/export/docbook/subfigures.xml b/autotests/export/docbook/subfigures.xml index 4a7c122291..622edb87c8 100644 --- a/autotests/export/docbook/subfigures.xml +++ b/autotests/export/docbook/subfigures.xml @@ -1,7 +1,7 @@ -
+
Test document Formalgroup with two images: @@ -10,7 +10,7 @@ Subfigure a. - + @@ -18,7 +18,7 @@ Subfigure b. - + @@ -29,7 +29,7 @@ Subfigure a. - + @@ -37,11 +37,12 @@ Subfigure b. - + + Formalgroup with two tables: Formalgroup, tables above. @@ -51,10 +52,12 @@ a b - + + c d - + + @@ -62,7 +65,8 @@ - + + @@ -77,10 +81,12 @@ - + + - + +
Subtable b.
a b
c d
a b
c d
@@ -88,11 +94,12 @@ - + + - + +
Subtable b.
a b
c d
- -
+
\ No newline at end of file From bc9d3ec262c0002827c2b1970350c7dec5ec860d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 00:50:37 +0200 Subject: [PATCH 54/88] DocBook: is not valid per se, rather use . The cleanest solution would still be , but this ought to be enough. Otherwise, that would imply having two tags for some fonts... --- src/output_docbook.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index c80988b492..ce631e9dae 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -49,7 +49,7 @@ std::string fontToDocBookTag(xml::FontTypes type) case xml::FontTypes::FT_BOLD: return "emphasis"; case xml::FontTypes::FT_NOUN: - return "person"; + return "personname"; case xml::FontTypes::FT_UBAR: case xml::FontTypes::FT_WAVE: case xml::FontTypes::FT_DBAR: From 19734ea4543be66a186d6bf0592386d735c3a8cb Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 01:24:28 +0200 Subject: [PATCH 55/88] DocBook: implement LyX-Code. This is quite ugly. --- lib/layouts/beamer.layout | 3 ++ lib/layouts/egs.layout | 3 ++ lib/layouts/lyxmacros.inc | 3 ++ src/output_docbook.cpp | 85 +++++++++++++-------------------------- 4 files changed, 36 insertions(+), 58 deletions(-) diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index f6d17c3b7e..4438482a6d 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -1408,6 +1408,9 @@ Style LyX-Code Font Family Typewriter EndFont + DocBookTag programlisting + DocBookTagType paragraph + DocBookAttr language='lyx' End Style NoteItem diff --git a/lib/layouts/egs.layout b/lib/layouts/egs.layout index 6ee01ed970..0bd4543c00 100644 --- a/lib/layouts/egs.layout +++ b/lib/layouts/egs.layout @@ -734,6 +734,9 @@ Style LyX-Code Font Family Typewriter EndFont + DocBookTag programlisting + DocBookTagType paragraph + DocBookAttr language='lyx' End diff --git a/lib/layouts/lyxmacros.inc b/lib/layouts/lyxmacros.inc index 1696ffda3e..4cf5cf6d95 100644 --- a/lib/layouts/lyxmacros.inc +++ b/lib/layouts/lyxmacros.inc @@ -38,6 +38,9 @@ Style LyX-Code Font Family Typewriter EndFont + DocBookTag programlisting + DocBookTagType paragraph + DocBookAttr language='lyx' End diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ce631e9dae..cf3873bd7a 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -534,8 +534,19 @@ void makeEnvironment(Text const &text, OutputParams const &runparams, ParagraphList::const_iterator const & par) { - // TODO: simplify me! auto const end = text.paragraphs().end(); + auto nextpar = par; + ++nextpar; + + // Special cases for listing-like environments provided in layouts. This is quite ad-hoc, but provides a useful + // default. This should not be used by too many environments (only LyX-Code right now). + // This would be much simpler if LyX-Code was implemented as InsetListings... + bool mimicListing = false; + bool ignoreFonts = false; + if (par->layout().docbooktag() == "programlisting") { + mimicListing = true; + ignoreFonts = true; + } // Output the opening tag for this environment, but only if it has not been previously opened (condition // implemented in openParTag). @@ -547,65 +558,25 @@ void makeEnvironment(Text const &text, if (style.latextype == LATEX_COMMAND) { // Nothing to do (otherwise, infinite loops). } else if (style.latextype == LATEX_ENVIRONMENT) { - // Open a wrapper tag if needed. - if (style.docbookitemwrappertag() != "NONE") - openTag(xs, style.docbookitemwrappertag(), style.docbookitemwrapperattr(), style.docbookitemwrappertagtype()); + // Generate the paragraph, if need be. + auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), 0, false, ignoreFonts); - // Generate the label, if need be. If it is taken from the text, sep != 0 and corresponds to the first - // character after the label. - pos_type sep = 0; - if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") { - // At least one condition must be met: - // - this environment is not a list - // - if this is a list, the label must not be manual (i.e. it must be taken from the layout) - if (style.latextype != LATEX_LIST_ENVIRONMENT || style.labeltype != LABEL_MANUAL) { - // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. - docstring const lbl = par->params().labelString(); - - if (!lbl.empty()) { - openLabelTag(xs, style); - xs << lbl; - closeLabelTag(xs, style); - } - } else { - // Only variablelist gets here (or similar items defined as an extension in the layout). - openLabelTag(xs, style); - sep = par->firstWordDocBook(xs, runparams); - closeLabelTag(xs, style); - } - } - - // Maybe the item is completely empty, i.e. if the first word ends at the end of the current paragraph - // AND if the next paragraph doesn't have the same depth (if there is such a paragraph). - // Common case: there is only the first word on the line, but there is a nested list instead - // of more text. - bool emptyItem = false; - if (sep == par->size()) { // If the separator is already at the end of this paragraph... - auto next_par = par; - ++next_par; - if (next_par == text.paragraphs().end()) // There is no next paragraph. - emptyItem = true; - else // There is a next paragraph: check depth. - emptyItem = par->params().depth() >= next_par->params().depth(); - } - - if (emptyItem) { - // Avoid having an empty item, this is not valid DocBook. A single character is enough to force - // generation of a full . - // TODO: this always worked only by magic... - xs << ' '; - } else { - // Generate the rest of the paragraph, if need be. Open as many inner tags as necessary. - auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(std::distance(text.paragraphs().begin(), par)), sep); + if (mimicListing) { auto p = pars.begin(); - while (true) { + while (p != pars.end()) { + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); xs << XMLStream::ESCAPE_NONE << *p; + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); ++p; - if (p != pars.end()) { - closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); - openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); - } else - break; + + if (p != pars.end()) + xs << xml::CR(); + } + } else { + for (auto const & p : pars) { + openTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnerattr(), par->layout().docbookiteminnertagtype()); + xs << XMLStream::ESCAPE_NONE << p; + closeTag(xs, par->layout().docbookiteminnertag(), par->layout().docbookiteminnertagtype()); } } } else { @@ -613,8 +584,6 @@ void makeEnvironment(Text const &text, } // Close the environment. - auto nextpar = par; - ++nextpar; closeParTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); // TODO: switch in layout for par/block? } From e3da8b65f644df5d7de79c233187144825b9e7f1 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 01:41:09 +0200 Subject: [PATCH 56/88] DocBook: several missing features for Additional.lyx. Includes: semantic markup (sorry about noun: Additional.lyx uses it to mark menus; there is something better in DocBook, but it looks like the LaTeX equivalent is really for person names), boxes, info layouts. --- .../export/docbook/Additional_lyxcode.lyx | 371 ++++++++++++++++++ .../export/docbook/Additional_lyxcode.xml | 40 ++ lib/layouts/logicalmkup.module | 9 + lib/layouts/stdinsets.inc | 36 ++ src/insets/InsetBox.cpp | 18 + src/insets/InsetLayout.cpp | 20 + src/insets/InsetLayout.h | 16 + src/output_docbook.cpp | 4 + 8 files changed, 514 insertions(+) create mode 100644 autotests/export/docbook/Additional_lyxcode.lyx create mode 100644 autotests/export/docbook/Additional_lyxcode.xml diff --git a/autotests/export/docbook/Additional_lyxcode.lyx b/autotests/export/docbook/Additional_lyxcode.lyx new file mode 100644 index 0000000000..fe2d4281b1 --- /dev/null +++ b/autotests/export/docbook/Additional_lyxcode.lyx @@ -0,0 +1,371 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass scrbook +\begin_preamble +% DO NOT ALTER THIS PREAMBLE!!! +% +% This preamble is designed to ensure that the manual prints +% out as advertised. If you mess with this preamble, +% parts of the manual may not print out as expected. If you +% have problems LaTeXing this file, please contact +% the documentation team +% email: lyx-docs@lists.lyx.org + +% the pages of the TOC are numbered roman +% and a PDF-bookmark for the TOC is added +\pagenumbering{roman} +\let\myTOC\tableofcontents +\renewcommand{\tableofcontents}{% + \pdfbookmark[1]{\contentsname}{} + \myTOC + \cleardoublepage + \pagenumbering{arabic}} + +% extra space for tables +\newcommand{\extratablespace}[1]{\noalign{\vskip#1}} +\end_preamble +\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading +\use_default_options false +\begin_modules +logicalmkup +theorems-ams +theorems-ams-extended +multicol +shapepar +\end_modules +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "lmodern" "default" +\font_sans "lmss" "default" +\font_typewriter "lmtt" "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 true +\graphics default +\default_output_format pdf2 +\output_sync 0 +\bibtex_command default +\index_command default +\paperfontsize 12 +\spacing single +\use_hyperref true +\pdf_title "LyX's Additional Features manual" +\pdf_author "LyX Team" +\pdf_subject "LyX's additional features documentation" +\pdf_keywords "LyX, Documentation, Additional" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen false +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref false +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" +\papersize a4 +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\notefontcolor #0000ff +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 3 +\tocdepth 3 +\paragraph_separation indent +\paragraph_indentation default +\is_math_indent 1 +\math_indentation default +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 +\papercolumns 1 +\papersides 2 +\paperpagestyle headings +\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 true +\docbook_table_output 0 +\end_header + +\begin_body + +\begin_layout Title +Additional \SpecialChar LyX + Features +\end_layout + +\begin_layout Subtitle +Version 2.3.x +\end_layout + +\begin_layout Author +by the \SpecialChar LyX + Team +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +\noindent +Principal maintainer of this file is +\noun on + Richard Heck +\noun default +. + If you have comments or error corrections, please send them to the \SpecialChar LyX + Documentati +on mailing list, +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout + +\end_layout + +\end_inset + +. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset CommandInset toc +LatexCommand tableofcontents + +\end_inset + + +\end_layout + +\begin_layout Chapter +\begin_inset CommandInset label +LatexCommand label +name "sec:Inserting-TeX-Code" + +\end_inset + +Inserting \SpecialChar TeX + Code into \SpecialChar LyX + Documents +\end_layout + +\begin_layout Standard +Anything you can do in \SpecialChar LaTeX + you can do in \SpecialChar LyX +, for a very simple reason: You can + always insert \SpecialChar TeX + code into any \SpecialChar LyX + document. + \SpecialChar LyX + cannot, and will never be able to, display every possible \SpecialChar LaTeX + construct. + If ever you need to insert \SpecialChar LaTeX + commands into your \SpecialChar LyX + document, you can use the + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout +\SpecialChar TeX + Code +\end_layout + +\end_inset + + box, which you can insert into your document with +\begin_inset Flex Noun +status collapsed + +\begin_layout Plain Layout +Insert\SpecialChar menuseparator + +\family sans +TeX +\family default + Code +\end_layout + +\end_inset + + or the keyboard shortcut +\begin_inset Info +type "shortcut" +arg "ert-insert" +\end_inset + +. +\end_layout + +\begin_layout Standard +Here's an example of inserting \SpecialChar LaTeX + commands in a \SpecialChar LyX + document. + The code looks like this: +\end_layout + +\begin_layout LyX-Code + +\backslash +begin{tabular}{ll} +\begin_inset Newline newline +\end_inset + + +\backslash +begin{minipage}{5cm} +\begin_inset Newline newline +\end_inset + +This is an example of a minipage environment. + You +\begin_inset Newline newline +\end_inset + +can put nearly everything in it, even (non-floating) +\begin_inset Newline newline +\end_inset + +figures and tables. + +\begin_inset Newline newline +\end_inset + + +\backslash +end{minipage} +\begin_inset Newline newline +\end_inset + +& +\begin_inset Newline newline +\end_inset + + +\backslash +begin{minipage}{5cm} +\begin_inset Newline newline +\end_inset + + +\backslash +begin{verbatim} +\begin_inset Newline newline +\end_inset + + +\backslash +begin{minipage}{5cm} +\begin_inset Newline newline +\end_inset + +This ... + +\begin_inset Newline newline +\end_inset + + +\backslash +end{minipage} +\begin_inset Newline newline +\end_inset + + +\backslash +end{verbatim} +\begin_inset Newline newline +\end_inset + + +\backslash +end{minipage} +\begin_inset Newline newline +\end_inset + + +\backslash +end{tabular} +\end_layout + +\begin_layout Section +Cross-References Between Files +\end_layout + +\begin_layout Standard +\begin_inset Box Shadowbox +position "t" +hor_pos "c" +has_inner_box 1 +inner_pos "t" +use_parbox 0 +use_makebox 0 +width "100col%" +special "none" +height "1in" +height_special "totalheight" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Plain Layout +This section is somewhat out of date. + Need to describe default master documents and how children are opened when + the master is. + [[FIXME]] +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/Additional_lyxcode.xml b/autotests/export/docbook/Additional_lyxcode.xml new file mode 100644 index 0000000000..b677971f0a --- /dev/null +++ b/autotests/export/docbook/Additional_lyxcode.xml @@ -0,0 +1,40 @@ + + + + +Additional LyX Features +Version 2.3.x + +by the LyX Team +Principal maintainer of this file is Richard Heck. If you have comments or error corrections, please send them to the LyX Documentation mailing list, <lyx-docs@lists.lyx.org>. + + + + +Inserting TeX Code into LyX Documents +Anything you can do in LaTeX you can do in LyX, for a very simple reason: You can always insert TeX code into any LyX document. LyX cannot, and will never be able to, display every possible LaTeX construct. If ever you need to insert LaTeX commands into your LyX document, you can use the TeX Code box, which you can insert into your document with Insert⇒TeX Code or the keyboard shortcut Ctrl+L. +Here's an example of inserting LaTeX commands in a LyX document. The code looks like this: +\begin{tabular}{ll} +\begin{minipage}{5cm} +This is an example of a minipage environment. You +can put nearly everything in it, even (non-floating) +figures and tables. +\end{minipage} +& +\begin{minipage}{5cm} +\begin{verbatim} +\begin{minipage}{5cm} +This ... +\end{minipage} +\end{verbatim} +\end{minipage} +\end{tabular} +
+Cross-References Between Files + +This section is somewhat out of date. Need to describe default master documents and how children are opened when the master is. [[FIXME]] + +
+
+
\ No newline at end of file diff --git a/lib/layouts/logicalmkup.module b/lib/layouts/logicalmkup.module index bedf6dc765..005a3c9456 100644 --- a/lib/layouts/logicalmkup.module +++ b/lib/layouts/logicalmkup.module @@ -27,6 +27,8 @@ InsetLayout Flex:Noun EndHTMLStyle ResetsFont true CustomPars false + DocBookTag personname + DocBookTagType inline End @@ -42,6 +44,8 @@ InsetLayout Flex:Emph HTMLTag em ResetsFont true CustomPars false + DocBookTag emphasis + DocBookTagType inline End @@ -60,6 +64,9 @@ InsetLayout Flex:Strong HTMLTag strong ResetsFont true CustomPars false + DocBookTag personname + DocBookAttr role='bold' + DocBookTagType inline End @@ -79,4 +86,6 @@ InsetLayout Flex:Code ResetsFont true CustomPars false Spellcheck false + DocBookTag code + DocBookTagType inline End diff --git a/lib/layouts/stdinsets.inc b/lib/layouts/stdinsets.inc index ab15f77456..fd2b75e2f5 100644 --- a/lib/layouts/stdinsets.inc +++ b/lib/layouts/stdinsets.inc @@ -434,6 +434,8 @@ InsetLayout Box Size Small EndFont MultiPar true + DocBookWrapperTag sidebar + DocBookTag para End InsetLayout Box:Frameless @@ -441,6 +443,9 @@ InsetLayout Box:Frameless HTMLStyle div.Frameless { margin: 1em; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='frameless' End InsetLayout Box:Shaded @@ -452,6 +457,9 @@ InsetLayout Box:Shaded padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='shaded' End InsetLayout Box:Boxed @@ -462,6 +470,9 @@ InsetLayout Box:Boxed padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='boxed' End InsetLayout Box:Framed @@ -472,6 +483,9 @@ InsetLayout Box:Framed padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='framed' End InsetLayout Box:ovalbox @@ -482,6 +496,9 @@ InsetLayout Box:ovalbox padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='ovalbox' End InsetLayout Box:Ovalbox @@ -492,6 +509,9 @@ InsetLayout Box:Ovalbox padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='ovalbox-var' End InsetLayout Box:Shadowbox @@ -499,6 +519,9 @@ InsetLayout Box:Shadowbox HTMLStyle div.Shadowbox { border: solid gray medium; border-bottom: solid black 1ex; border-right: solid black 1ex; padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='shadowbox' End InsetLayout Box:Doublebox @@ -509,6 +532,9 @@ InsetLayout Box:Doublebox padding: 0.5ex; } EndHTMLStyle + DocBookWrapperTag sidebar + DocBookTag para + DocBookWrapperAttr role='doublebox' End InsetLayout Float @@ -609,6 +635,8 @@ InsetLayout Info:menu HTMLStyle span.menu { font-family: sans-serif; } EndHTMLStyle + DocBookTag guimenu + DocBookTagType inline End InsetLayout Info:shortcut @@ -626,6 +654,10 @@ InsetLayout Info:shortcut HTMLStyle span.shortcut { font-family: sans-serif; } EndHTMLStyle + DocBookWrapperTag keycombo + DocBookWrapperTagType inline + DocBookTag keycap + DocBookTagType inline End InsetLayout Info:shortcuts @@ -643,6 +675,10 @@ InsetLayout Info:shortcuts HTMLStyle span.shortcuts { font-family: sans-serif; } EndHTMLStyle + DocBookWrapperTag keycombo + DocBookWrapperTagType inline + DocBookTag keycap + DocBookTagType inline End InsetLayout Caption:Standard diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index c61efe6d01..db76f53753 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -717,7 +717,25 @@ int InsetBox::plaintext(odocstringstream & os, void InsetBox::docbook(XMLStream & xs, OutputParams const & runparams) const { + if (!getLayout().docbookwrappertag().empty()) { + if (!xs.isLastTagCR()) + xs << xml::CR(); + + xs << xml::StartTag(getLayout().docbookwrappertag(), getLayout().docbookwrapperattr()); + xs << xml::CR(); + } else { + LYXERR0("Assertion failed: box layout " + getLayout().name() + " missing DocBookWrapperTag."); + } + InsetText::docbook(xs, runparams); + + if (!getLayout().docbookwrappertag().empty()) { + if (!xs.isLastTagCR()) + xs << xml::CR(); + + xs << xml::EndTag(getLayout().docbookwrappertag()); + xs << xml::CR(); + } } diff --git a/src/insets/InsetLayout.cpp b/src/insets/InsetLayout.cpp index ce0d25a13a..d758a1c3a4 100644 --- a/src/insets/InsetLayout.cpp +++ b/src/insets/InsetLayout.cpp @@ -110,7 +110,11 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, IL_HTMLSTYLE, IL_HTMLPREAMBLE, IL_DOCBOOKTAG, + IL_DOCBOOKTAGTYPE, IL_DOCBOOKATTR, + IL_DOCBOOKWRAPPERTAG, + IL_DOCBOOKWRAPPERTAGTYPE, + IL_DOCBOOKWRAPPERATTR, IL_INTOC, IL_ISTOCCAPTION, IL_LABELFONT, @@ -157,6 +161,10 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, { "display", IL_DISPLAY }, { "docbookattr", IL_DOCBOOKATTR }, { "docbooktag", IL_DOCBOOKTAG }, + { "docbooktagtype", IL_DOCBOOKTAGTYPE }, + { "docbookwrapperattr", IL_DOCBOOKWRAPPERATTR }, + { "docbookwrappertag", IL_DOCBOOKWRAPPERTAG }, + { "docbookwrappertagtype", IL_DOCBOOKWRAPPERTAGTYPE }, { "editexternal", IL_EDITEXTERNAL }, { "end", IL_END }, { "fixedwidthpreambleencoding", IL_FIXEDWIDTH_PREAMBLE_ENCODING }, @@ -500,9 +508,21 @@ bool InsetLayout::read(Lexer & lex, TextClass const & tclass, case IL_DOCBOOKTAG: lex >> docbooktag_; break; + case IL_DOCBOOKTAGTYPE: + lex >> docbooktagtype_; + break; case IL_DOCBOOKATTR: lex >> docbookattr_; break; + case IL_DOCBOOKWRAPPERTAG: + lex >> docbookwrappertag_; + break; + case IL_DOCBOOKWRAPPERTAGTYPE: + lex >> docbookwrappertagtype_; + break; + case IL_DOCBOOKWRAPPERATTR: + lex >> docbookwrapperattr_; + break; case IL_REQUIRES: { lex.eatLine(); vector const req diff --git a/src/insets/InsetLayout.h b/src/insets/InsetLayout.h index 00e3ba64d7..f11071fb6c 100644 --- a/src/insets/InsetLayout.h +++ b/src/insets/InsetLayout.h @@ -150,8 +150,16 @@ public: /// std::string docbooktag() const { return docbooktag_; } /// + std::string docbooktagtype() const { return docbooktagtype_; } + /// std::string docbookattr() const { return docbookattr_; } /// + std::string docbookwrappertag() const { return docbookwrappertag_; } + /// + std::string docbookwrappertagtype() const { return docbookwrappertagtype_; } + /// + std::string docbookwrapperattr() const { return docbookwrapperattr_; } + /// std::set required() const { return required_; } /// bool isMultiPar() const { return multipar_; } @@ -281,8 +289,16 @@ private: /// std::string docbooktag_; /// + std::string docbooktagtype_; + /// std::string docbookattr_; /// + std::string docbookwrappertag_; + /// + std::string docbookwrappertagtype_; + /// + std::string docbookwrapperattr_; + /// std::set required_; /// bool multipar_; diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index cf3873bd7a..1f17351d3f 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -493,6 +493,10 @@ void makeParagraph( // Listings should not get into their own paragraph. if (!special_case && firstInset->lyxCode() == lyx::LISTINGS_CODE) special_case = true; + + // Boxes cannot get into their own paragraph. + if (!special_case && firstInset->lyxCode() == lyx::BOX_CODE) + special_case = true; } bool const open_par = runparams.docbook_make_pars From ca1ca4326b027d7781c6ff31c1dfb1b5e4e53d8c Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 02:39:37 +0200 Subject: [PATCH 57/88] DocBook: implement theorems. This is a minimal implementation, as DocBook lacks a serious way of encoding all of this. Maybe a could do the trick, but I'd need to find a way to shoehorn a title through the styles (i.e. a first complete tag): Theorem: Bla bla Theorem Bla bla This would also only be a solution for single-paragraph things, as formalpara only allows one paragraph. Or a sidebar, but it's semantically very remote. --- .../export/docbook/Additional_lyxcode.lyx | 164 ++++++++++++++++++ .../export/docbook/Additional_lyxcode.xml | 35 ++++ development/DocBookToDo | 23 ++- lib/layouts/theorems-ams-bytype.inc | 26 +++ lib/layouts/theorems-ams-chap-bytype.inc | 26 +++ .../theorems-ams-extended-bytype.module | 64 +++++++ .../theorems-ams-extended-chap-bytype.module | 64 +++++++ lib/layouts/theorems-ams-extended.module | 64 +++++++ lib/layouts/theorems-ams.inc | 26 +++ lib/layouts/theorems-bytype.inc | 26 +++ lib/layouts/theorems-case.inc | 2 + lib/layouts/theorems-proof-std.inc | 2 + lib/layouts/theorems-proof.inc | 2 + lib/layouts/theorems-starred.inc | 28 +++ lib/layouts/theorems-without-preamble.inc | 42 +++++ lib/layouts/theorems.inc | 28 +++ 16 files changed, 621 insertions(+), 1 deletion(-) diff --git a/autotests/export/docbook/Additional_lyxcode.lyx b/autotests/export/docbook/Additional_lyxcode.lyx index fe2d4281b1..797e315e87 100644 --- a/autotests/export/docbook/Additional_lyxcode.lyx +++ b/autotests/export/docbook/Additional_lyxcode.lyx @@ -367,5 +367,169 @@ This section is somewhat out of date. \end_layout +\begin_layout Section +AMS \SpecialChar LaTeX + +\end_layout + +\begin_layout Standard +These same environments are provided only in the starred versions by the + +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout +Theorems (Starred) +\end_layout + +\end_inset + + module: +\end_layout + +\begin_layout Theorem +This is typically used for the statements of major results. + +\end_layout + +\begin_layout Corollary* +This is used for statements which follow fairly directly from previous statement +s. + Again, these can be major results. + +\end_layout + +\begin_layout Lemma +These are smaller results needed to prove other statements. +\end_layout + +\begin_layout Proposition +These are less major results which (hopefully) add to the general theory + being discussed. +\end_layout + +\begin_layout Conjecture +These are statements provided without justification, which the author does + not know how to prove, but which seem to be true (to the author, at least). +\end_layout + +\begin_layout Definition* +Guess what this is for. + The font is different for this environment than for the previous ones. + +\end_layout + +\begin_layout Example* +Used for examples illustrating proven results. +\end_layout + +\begin_layout Problem +It's not really known what this is for. + You should figure it out. +\end_layout + +\begin_layout Exercise* +Write a description for this one. +\end_layout + +\begin_layout Remark +This environment is also a type of theorem, usually a lesser sort of observation. +\end_layout + +\begin_layout Claim* +Often used in the course of giving a proof of a larger result. +\end_layout + +\begin_layout Case +Generally, these are used to break up long arguments, using specific instances + of some condition. + +\end_layout + +\begin_layout Case +The numbering scheme for cases is on its own, not together with other numbered + statements. + +\end_layout + +\begin_layout Proof +At the end of this environment, a QED symbol (usually a square, but it can + vary with different styles) is placed. + If you want to have other environments within this one—for example, Case + environments—and have the QED symbol appear only after them, then the other + environments need to be nested within the proof environment. + See the section +\emph on +Nesting Environments +\emph default + of the +\emph on +User's Guide +\emph default + for information on nesting. +\end_layout + +\begin_layout Standard +And these environments are provided by +\begin_inset Flex Code +status collapsed + +\begin_layout Plain Layout +Theorems (AMS-Extended) +\end_layout + +\end_inset + +: +\end_layout + +\begin_layout Criterion* +A required condition. +\end_layout + +\begin_layout Algorithm* +A general procedure to be used. +\end_layout + +\begin_layout Axiom* +This is a property or statement taken as true within the system being discussed. +\end_layout + +\begin_layout Condition* +Sometimes used to state a condition assumed within the present context of + discussion. +\end_layout + +\begin_layout Note* +Similar to a Remark. +\end_layout + +\begin_layout Notation* +Used for the explanation of, yes, notation. +\end_layout + +\begin_layout Summary +Do we really need to tell you? +\end_layout + +\begin_layout Acknowledgement* +Acknowledgement. +\end_layout + +\begin_layout Conclusion* +Sometimes used at the end of a long train of argument. +\end_layout + +\begin_layout Fact +Used in a way similar to Proposition, though perhaps lower on the scale. +\end_layout + +\begin_layout Standard +In addition, the AMS classes automatically provide the AMS \SpecialChar LaTeX + and AMS fonts + packages. + They need to be available on your system in order to use these environments. +\end_layout + \end_body \end_document diff --git a/autotests/export/docbook/Additional_lyxcode.xml b/autotests/export/docbook/Additional_lyxcode.xml index b677971f0a..f42ac9fb2c 100644 --- a/autotests/export/docbook/Additional_lyxcode.xml +++ b/autotests/export/docbook/Additional_lyxcode.xml @@ -36,5 +36,40 @@ This ... This section is somewhat out of date. Need to describe default master documents and how children are opened when the master is. [[FIXME]]
+
+AMS LaTeX +These same environments are provided only in the starred versions by the Theorems (Starred) module: +This is typically used for the statements of major results. +This is used for statements which follow fairly directly from previous statements. Again, these can be major results. +These are smaller results needed to prove other statements. +These are less major results which (hopefully) add to the general theory being discussed. +These are statements provided without justification, which the author does not know how to prove, but which seem to be true (to the author, at least). +Guess what this is for. The font is different for this environment than for the previous ones. + +Used for examples illustrating proven results. + +It's not really known what this is for. You should figure it out. +Write a description for this one. + +This environment is also a type of theorem, usually a lesser sort of observation. + +Often used in the course of giving a proof of a larger result. +Generally, these are used to break up long arguments, using specific instances of some condition. The numbering scheme for cases is on its own, not together with other numbered statements. +At the end of this environment, a QED symbol (usually a square, but it can vary with different styles) is placed. If you want to have other environments within this one—for example, Case environments—and have the QED symbol appear only after them, then the other environments need to be nested within the proof environment. See the section Nesting Environments of the User's Guide for information on nesting. +And these environments are provided by Theorems (AMS-Extended): +A required condition. +A general procedure to be used. +This is a property or statement taken as true within the system being discussed. +Sometimes used to state a condition assumed within the present context of discussion. + +Similar to a Remark. + +Used for the explanation of, yes, notation. +Do we really need to tell you? +Acknowledgement. +Sometimes used at the end of a long train of argument. +Used in a way similar to Proposition, though perhaps lower on the scale. +In addition, the AMS classes automatically provide the AMS LaTeX and AMS fonts packages. They need to be available on your system in order to use these environments. +
\ No newline at end of file diff --git a/development/DocBookToDo b/development/DocBookToDo index 39ca534ecb..6b6ca342ce 100644 --- a/development/DocBookToDo +++ b/development/DocBookToDo @@ -17,4 +17,25 @@ TableRefs, TableComments: no mapping in DocBook, not really a way to add these t Clearly, with this kind of template, we're reaching the limits of such a system! Having a really good converter for all these cases would require a lot of very specific code. -More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. \ No newline at end of file +More general: what the heck with appendices? It's not handled in the LyX way (Document > Start Appendix Here), but in a custom way. Making this work would solve some correctness issues with this template. + + + +Things specific to modules +========================== + +AMS +--- + +Theorems and the like do not have counter parts in DocBook. Maybe a could do the trick, but I'd need to find a way to shoehorn a title through the styles (i.e. a first complete tag): + + LyX: + Theorem: Bla bla + + DocBook: + + Theorem + Bla bla + + +This would also only be a solution for single-paragraph things, as formalpara only allows one paragraph. Or a sidebar, but it's semantically very remote. \ No newline at end of file diff --git a/lib/layouts/theorems-ams-bytype.inc b/lib/layouts/theorems-ams-bytype.inc index a306f15962..fede0e8b31 100644 --- a/lib/layouts/theorems-ams-bytype.inc +++ b/lib/layouts/theorems-ams-bytype.inc @@ -110,6 +110,8 @@ Style Theorem \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -128,6 +130,8 @@ Style Corollary BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -146,6 +150,8 @@ Style Lemma \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble LabelCounter lemma + DocBookTag para + DocBookAttr role='lemma' End @@ -164,6 +170,8 @@ Style Proposition \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble LabelCounter proposition + DocBookTag para + DocBookAttr role='proposition' End @@ -182,6 +190,8 @@ Style Conjecture \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble LabelCounter conjecture + DocBookTag para + DocBookAttr role='conjecture' End @@ -200,6 +210,8 @@ Style Fact \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble LabelCounter fact + DocBookTag para + DocBookAttr role='fact' End @@ -225,6 +237,8 @@ Style Definition \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble LabelCounter definition + DocBookTag para + DocBookAttr role='definition' End @@ -244,6 +258,9 @@ Style Example \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble LabelCounter example + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -263,6 +280,8 @@ Style Problem \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble LabelCounter problem + DocBookTag para + DocBookAttr role='problem' End @@ -282,6 +301,8 @@ Style Exercise \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble LabelCounter exercise + DocBookTag para + DocBookAttr role='exercise' End @@ -301,6 +322,8 @@ Style Solution \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble LabelCounter solution + DocBookTag para + DocBookAttr role='solution' End @@ -348,6 +371,9 @@ Style Claim \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble LabelCounter claim + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End Input theorems-case.inc diff --git a/lib/layouts/theorems-ams-chap-bytype.inc b/lib/layouts/theorems-ams-chap-bytype.inc index e4528f712f..faaa2d0dca 100644 --- a/lib/layouts/theorems-ams-chap-bytype.inc +++ b/lib/layouts/theorems-ams-chap-bytype.inc @@ -129,6 +129,8 @@ Style Theorem \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -151,6 +153,8 @@ Style Corollary BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -173,6 +177,8 @@ Style Lemma \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble LabelCounter lemma + DocBookTag para + DocBookAttr role='lemma' End @@ -195,6 +201,8 @@ Style Proposition \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble LabelCounter proposition + DocBookTag para + DocBookAttr role='proposition' End @@ -217,6 +225,8 @@ Style Conjecture \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble LabelCounter conjecture + DocBookTag para + DocBookAttr role='conjecture' End @@ -239,6 +249,8 @@ Style Fact \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble LabelCounter fact + DocBookTag para + DocBookAttr role='fact' End @@ -268,6 +280,8 @@ Style Definition \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble LabelCounter definition + DocBookTag para + DocBookAttr role='definition' End @@ -291,6 +305,9 @@ Style Example \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble LabelCounter example + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -314,6 +331,8 @@ Style Problem \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble LabelCounter problem + DocBookTag para + DocBookAttr role='problem' End @@ -337,6 +356,8 @@ Style Exercise \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble LabelCounter exercise + DocBookTag para + DocBookAttr role='exercise' End @@ -360,6 +381,8 @@ Style Solution \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble LabelCounter solution + DocBookTag para + DocBookAttr role='solution' End @@ -415,6 +438,9 @@ Style Claim \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble LabelCounter claim + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End diff --git a/lib/layouts/theorems-ams-extended-bytype.module b/lib/layouts/theorems-ams-extended-bytype.module index e031a74362..c537defc78 100644 --- a/lib/layouts/theorems-ams-extended-bytype.module +++ b/lib/layouts/theorems-ams-extended-bytype.module @@ -87,6 +87,9 @@ Style Criterion \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble LabelCounter criterion + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End Style Criterion* @@ -103,6 +106,9 @@ Style Criterion* BabelPreamble \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End @@ -121,6 +127,9 @@ Style Algorithm \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble LabelCounter algorithm + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -138,6 +147,9 @@ Style Algorithm* BabelPreamble \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -156,6 +168,9 @@ Style Axiom \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble LabelCounter axiom + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -173,6 +188,9 @@ Style Axiom* BabelPreamble \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -191,6 +209,9 @@ Style Condition \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble LabelCounter condition + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -208,6 +229,9 @@ Style Condition* BabelPreamble \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -226,6 +250,8 @@ Style Note \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble LabelCounter note + DocBookTag note + DocBookItemTag para End @@ -243,6 +269,8 @@ Style Note* BabelPreamble \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -261,6 +289,9 @@ Style Notation \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble LabelCounter notation + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -278,6 +309,9 @@ Style Notation* BabelPreamble \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -296,6 +330,9 @@ Style Summary \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble LabelCounter summary + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -313,6 +350,9 @@ Style Summary* BabelPreamble \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -331,6 +371,9 @@ Style Acknowledgement \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble LabelCounter acknowledgement + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -348,6 +391,9 @@ Style Acknowledgement* BabelPreamble \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -366,6 +412,9 @@ Style Conclusion \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble LabelCounter conclusion + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -383,6 +432,9 @@ Style Conclusion* BabelPreamble \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -401,6 +453,9 @@ Style Assumption \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble LabelCounter assumption + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End @@ -418,6 +473,9 @@ Style Assumption* BabelPreamble \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End Style Question @@ -436,6 +494,9 @@ Style Question \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble LabelCounter question + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Style Question* @@ -452,6 +513,9 @@ Style Question* BabelPreamble \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Input theorems-refprefix.inc diff --git a/lib/layouts/theorems-ams-extended-chap-bytype.module b/lib/layouts/theorems-ams-extended-chap-bytype.module index 435eb65ab3..7252073e64 100644 --- a/lib/layouts/theorems-ams-extended-chap-bytype.module +++ b/lib/layouts/theorems-ams-extended-chap-bytype.module @@ -105,6 +105,9 @@ Style Criterion \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble LabelCounter criterion + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End @@ -122,6 +125,9 @@ Style Criterion* BabelPreamble \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End @@ -144,6 +150,9 @@ Style Algorithm \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble LabelCounter algorithm + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -161,6 +170,9 @@ Style Algorithm* BabelPreamble \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -183,6 +195,9 @@ Style Axiom \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble LabelCounter axiom + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -200,6 +215,9 @@ Style Axiom* BabelPreamble \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -222,6 +240,9 @@ Style Condition \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble LabelCounter condition + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -239,6 +260,9 @@ Style Condition* BabelPreamble \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -261,6 +285,8 @@ Style Note \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble LabelCounter note + DocBookTag note + DocBookItemTag para End @@ -278,6 +304,8 @@ Style Note* BabelPreamble \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -300,6 +328,9 @@ Style Notation \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble LabelCounter notation + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -317,6 +348,9 @@ Style Notation* BabelPreamble \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -340,6 +374,9 @@ Style Summary \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble LabelCounter summary + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -357,6 +394,9 @@ Style Summary* BabelPreamble \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -379,6 +419,9 @@ Style Acknowledgement \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble LabelCounter acknowledgement + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -396,6 +439,9 @@ Style Acknowledgement* BabelPreamble \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -418,6 +464,9 @@ Style Conclusion \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble LabelCounter conclusion + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -435,6 +484,9 @@ Style Conclusion* BabelPreamble \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -457,6 +509,9 @@ Style Assumption \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble LabelCounter assumption + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End @@ -474,6 +529,9 @@ Style Assumption* BabelPreamble \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End Style Question @@ -496,6 +554,9 @@ Style Question \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble LabelCounter question + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Style Question* @@ -512,6 +573,9 @@ Style Question* BabelPreamble \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Input theorems-refprefix.inc diff --git a/lib/layouts/theorems-ams-extended.module b/lib/layouts/theorems-ams-extended.module index 0f33a90af3..f2c4cf030f 100644 --- a/lib/layouts/theorems-ams-extended.module +++ b/lib/layouts/theorems-ams-extended.module @@ -48,6 +48,9 @@ Style Criterion BabelPreamble \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End Style Criterion* @@ -64,6 +67,9 @@ Style Criterion* BabelPreamble \addto\captions$$lang{\renewcommand{\criterionname}{_(Criterion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='criterion' + DocBookItemTag "" End @@ -82,6 +88,9 @@ Style Algorithm BabelPreamble \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -99,6 +108,9 @@ Style Algorithm* BabelPreamble \addto\captions$$lang{\renewcommand{\algorithmname}{_(Algorithm)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='algorithm' + DocBookItemTag "" End @@ -117,6 +129,9 @@ Style Axiom BabelPreamble \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -134,6 +149,9 @@ Style Axiom* BabelPreamble \addto\captions$$lang{\renewcommand{\axiomname}{_(Axiom)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='axiom' + DocBookItemTag "" End @@ -151,6 +169,9 @@ Style Condition BabelPreamble \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -168,6 +189,9 @@ Style Condition* BabelPreamble \addto\captions$$lang{\renewcommand{\conditionname}{_(Condition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='condition' + DocBookItemTag "" End @@ -185,6 +209,8 @@ Style Note BabelPreamble \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -202,6 +228,8 @@ Style Note* BabelPreamble \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -219,6 +247,9 @@ Style Notation BabelPreamble \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -236,6 +267,9 @@ Style Notation* BabelPreamble \addto\captions$$lang{\renewcommand{\notationname}{_(Notation)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='notation' + DocBookItemTag "" End @@ -253,6 +287,9 @@ Style Summary BabelPreamble \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -270,6 +307,9 @@ Style Summary* BabelPreamble \addto\captions$$lang{\renewcommand{\summaryname}{_(Summary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='summary' + DocBookItemTag "" End @@ -287,6 +327,9 @@ Style Acknowledgement BabelPreamble \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -304,6 +347,9 @@ Style Acknowledgement* BabelPreamble \addto\captions$$lang{\renewcommand{\acknowledgementname}{_(Acknowledgement)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='acknowledgement' + DocBookItemTag "" End @@ -321,6 +367,9 @@ Style Conclusion BabelPreamble \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -338,6 +387,9 @@ Style Conclusion* BabelPreamble \addto\captions$$lang{\renewcommand{\conclusionname}{_(Conclusion)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conclusion' + DocBookItemTag "" End @@ -356,6 +408,9 @@ Style Assumption BabelPreamble \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End @@ -373,6 +428,9 @@ Style Assumption* BabelPreamble \addto\captions$$lang{\renewcommand{\assumptionname}{_(Assumption)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='assumption' + DocBookItemTag "" End Style Question @@ -390,6 +448,9 @@ Style Question BabelPreamble \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Style Question* @@ -406,6 +467,9 @@ Style Question* BabelPreamble \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='question' + DocBookItemTag "" End Input theorems-refprefix.inc diff --git a/lib/layouts/theorems-ams.inc b/lib/layouts/theorems-ams.inc index 99fcbf9149..44cc806b26 100644 --- a/lib/layouts/theorems-ams.inc +++ b/lib/layouts/theorems-ams.inc @@ -69,6 +69,8 @@ Style Theorem \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -87,6 +89,8 @@ Style Corollary BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -105,6 +109,8 @@ Style Lemma BabelPreamble \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='lemma' End @@ -123,6 +129,8 @@ Style Proposition BabelPreamble \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='proposition' End @@ -141,6 +149,8 @@ Style Conjecture BabelPreamble \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conjecture' End @@ -159,6 +169,8 @@ Style Fact BabelPreamble \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='fact' End @@ -184,6 +196,8 @@ Style Definition BabelPreamble \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='definition' End @@ -201,6 +215,9 @@ Style Example BabelPreamble \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -218,6 +235,8 @@ Style Problem BabelPreamble \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='problem' End @@ -235,6 +254,8 @@ Style Exercise BabelPreamble \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='exercise' End @@ -252,6 +273,8 @@ Style Solution BabelPreamble \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='solution' End @@ -297,6 +320,9 @@ Style Claim BabelPreamble \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End Input theorems-case.inc diff --git a/lib/layouts/theorems-bytype.inc b/lib/layouts/theorems-bytype.inc index a61a4dfb8f..a40098b963 100644 --- a/lib/layouts/theorems-bytype.inc +++ b/lib/layouts/theorems-bytype.inc @@ -66,6 +66,8 @@ Style Theorem \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -84,6 +86,8 @@ Style Corollary \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble LabelCounter corollary + DocBookTag para + DocBookAttr role='corollary' End @@ -102,6 +106,8 @@ Style Lemma \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble LabelCounter lemma + DocBookTag para + DocBookAttr role='lemma' End @@ -120,6 +126,8 @@ Style Proposition \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble LabelCounter proposition + DocBookTag para + DocBookAttr role='proposition' End @@ -138,6 +146,8 @@ Style Conjecture \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble LabelCounter conjecture + DocBookTag para + DocBookAttr role='conjecture' End @@ -156,6 +166,8 @@ Style Fact \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble LabelCounter fact + DocBookTag para + DocBookAttr role='fact' End @@ -181,6 +193,8 @@ Style Definition \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble LabelCounter definition + DocBookTag para + DocBookAttr role='definition' End @@ -200,6 +214,9 @@ Style Example \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble LabelCounter example + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -219,6 +236,8 @@ Style Problem \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble LabelCounter problem + DocBookTag para + DocBookAttr role='problem' End @@ -238,6 +257,8 @@ Style Exercise \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble LabelCounter exercise + DocBookTag para + DocBookAttr role='exercise' End @@ -257,6 +278,8 @@ Style Solution \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble LabelCounter solution + DocBookTag para + DocBookAttr role='solution' End @@ -304,6 +327,9 @@ Style Claim \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble LabelCounter claim + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End Input theorems-case.inc diff --git a/lib/layouts/theorems-case.inc b/lib/layouts/theorems-case.inc index cf85b48a13..1ee52a34ac 100644 --- a/lib/layouts/theorems-case.inc +++ b/lib/layouts/theorems-case.inc @@ -86,4 +86,6 @@ Style Case \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} EndBabelPreamble RefPrefix OFF + DocBookTag para + DocBookAttr role='cases' End diff --git a/lib/layouts/theorems-proof-std.inc b/lib/layouts/theorems-proof-std.inc index 89c4173d44..8ba18cf614 100644 --- a/lib/layouts/theorems-proof-std.inc +++ b/lib/layouts/theorems-proof-std.inc @@ -18,4 +18,6 @@ Style Proof \fi EndPreamble # No LangPreamble or BabelPreamble, since babel knows \proofname already. + DocBookTag para + DocBookAttr role='proof' End diff --git a/lib/layouts/theorems-proof.inc b/lib/layouts/theorems-proof.inc index 345ba38339..949a35ee42 100644 --- a/lib/layouts/theorems-proof.inc +++ b/lib/layouts/theorems-proof.inc @@ -40,5 +40,7 @@ Style Proof LabelFont Shape Italic EndFont + DocBookTag para + DocBookAttr role='proof' End diff --git a/lib/layouts/theorems-starred.inc b/lib/layouts/theorems-starred.inc index 4add989880..fa02b21a7c 100644 --- a/lib/layouts/theorems-starred.inc +++ b/lib/layouts/theorems-starred.inc @@ -67,6 +67,8 @@ Style Theorem* \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -84,6 +86,8 @@ Style Corollary* BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -101,6 +105,8 @@ Style Lemma* BabelPreamble \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='lemma' End @@ -118,6 +124,8 @@ Style Proposition* BabelPreamble \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='proposition' End @@ -135,6 +143,8 @@ Style Conjecture* BabelPreamble \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conjecture' End @@ -152,6 +162,8 @@ Style Fact* BabelPreamble \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='fact' End @@ -177,6 +189,8 @@ Style Definition* BabelPreamble \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='definition' End @@ -194,6 +208,9 @@ Style Example* BabelPreamble \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -211,6 +228,8 @@ Style Problem* BabelPreamble \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='problem' End @@ -228,6 +247,8 @@ Style Exercise* BabelPreamble \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='exercise' End @@ -245,6 +266,8 @@ Style Solution* BabelPreamble \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='solution' End @@ -270,6 +293,8 @@ Style Remark* BabelPreamble \addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -287,5 +312,8 @@ Style Claim* BabelPreamble \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End diff --git a/lib/layouts/theorems-without-preamble.inc b/lib/layouts/theorems-without-preamble.inc index 80beb8ebdb..43b8c0cdd9 100644 --- a/lib/layouts/theorems-without-preamble.inc +++ b/lib/layouts/theorems-without-preamble.inc @@ -72,6 +72,8 @@ Style Theorem BabelPreamble \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='theorem' End @@ -89,6 +91,8 @@ Style Corollary BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -106,6 +110,8 @@ Style Lemma BabelPreamble \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='lemma' End @@ -123,6 +129,8 @@ Style Proposition BabelPreamble \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='proposition' End @@ -140,6 +148,8 @@ Style Prop LabelFont Series Medium EndFont + DocBookTag para + DocBookAttr role='proposition' End @@ -164,6 +174,8 @@ Style Conjecture BabelPreamble \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conjecture' End @@ -181,6 +193,8 @@ Style Fact BabelPreamble \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='fact' End @@ -206,6 +220,8 @@ Style Definition BabelPreamble \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='definition' End @@ -224,6 +240,9 @@ Style Example BabelPreamble \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -243,6 +262,8 @@ Style Problem BabelPreamble \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='problem' End @@ -276,6 +297,8 @@ Style Prob EndFont AddToToc thm IsTocCaption true + DocBookTag para + DocBookAttr role='problem' End @@ -294,6 +317,8 @@ Style Solution BabelPreamble \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='solution' End @@ -308,6 +333,8 @@ Style Sol Tooltip "Label of the corresponding problem" IsTocCaption true EndArgument + DocBookTag para + DocBookAttr role='solution' End @@ -326,6 +353,8 @@ Style Exercise BabelPreamble \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='exercise' End @@ -344,6 +373,8 @@ Style Remark BabelPreamble \addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -357,6 +388,9 @@ Style Claim BabelPreamble \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End @@ -375,6 +409,8 @@ Style Case BabelPreamble \addto\captions$$lang{\renewcommand{\casename}{_(Case)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='case' End @@ -393,6 +429,8 @@ Style Property BabelPreamble \addto\captions$$lang{\renewcommand{\propertyname}{_(Property)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='property' End @@ -411,6 +449,8 @@ Style Question BabelPreamble \addto\captions$$lang{\renewcommand{\questionname}{_(Question)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='question' End @@ -429,5 +469,7 @@ Style Note BabelPreamble \addto\captions$$lang{\renewcommand{\notename}{_(Note)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End diff --git a/lib/layouts/theorems.inc b/lib/layouts/theorems.inc index 9017ca6c4f..822ee94625 100644 --- a/lib/layouts/theorems.inc +++ b/lib/layouts/theorems.inc @@ -69,6 +69,8 @@ Style Theorem \addto\captions$$lang{\renewcommand{\theoremname}{_(Theorem)}} EndBabelPreamble Requires amsthm + DocBookTag para + DocBookAttr role='theorem' End @@ -87,6 +89,8 @@ Style Corollary BabelPreamble \addto\captions$$lang{\renewcommand{\corollaryname}{_(Corollary)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='corollary' End @@ -105,6 +109,8 @@ Style Lemma BabelPreamble \addto\captions$$lang{\renewcommand{\lemmaname}{_(Lemma)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='lemma' End @@ -123,6 +129,8 @@ Style Proposition BabelPreamble \addto\captions$$lang{\renewcommand{\propositionname}{_(Proposition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='proposition' End @@ -141,6 +149,8 @@ Style Conjecture BabelPreamble \addto\captions$$lang{\renewcommand{\conjecturename}{_(Conjecture)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='conjecture' End @@ -159,6 +169,8 @@ Style Fact BabelPreamble \addto\captions$$lang{\renewcommand{\factname}{_(Fact)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='fact' End @@ -184,6 +196,8 @@ Style Definition BabelPreamble \addto\captions$$lang{\renewcommand{\definitionname}{_(Definition)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='definition' End @@ -201,6 +215,9 @@ Style Example BabelPreamble \addto\captions$$lang{\renewcommand{\examplename}{_(Example)}} EndBabelPreamble + DocBookWrapperTag informalexample + DocBookTag para + DocBookAttr "" End @@ -218,6 +235,8 @@ Style Problem BabelPreamble \addto\captions$$lang{\renewcommand{\problemname}{_(Problem)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='problem' End @@ -235,6 +254,8 @@ Style Exercise BabelPreamble \addto\captions$$lang{\renewcommand{\exercisename}{_(Exercise)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='exercise' End @@ -252,6 +273,8 @@ Style Solution BabelPreamble \addto\captions$$lang{\renewcommand{\solutionname}{_(Solution)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='solution' End @@ -278,6 +301,8 @@ Style Remark BabelPreamble \addto\captions$$lang{\renewcommand{\remarkname}{_(Remark)}} EndBabelPreamble + DocBookTag note + DocBookItemTag para End @@ -295,6 +320,9 @@ Style Claim BabelPreamble \addto\captions$$lang{\renewcommand{\claimname}{_(Claim)}} EndBabelPreamble + DocBookTag para + DocBookAttr role='claim' + DocBookItemTag "" End Input theorems-case.inc From 632bad62c9eb7939ed2d6eadf2f3bb5fdf4d31fe Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Mon, 31 Aug 2020 03:09:16 +0200 Subject: [PATCH 58/88] DocBook: do a little something for shapepar. --- lib/layouts/shapepar.module | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/layouts/shapepar.module b/lib/layouts/shapepar.module index f5068dcd8a..6b38cdfbbf 100644 --- a/lib/layouts/shapepar.module +++ b/lib/layouts/shapepar.module @@ -35,41 +35,51 @@ Style "CD label" ParSkip 0.4 Align Block LabelType No_Label + DocBookWrapperTag sidebar + DocBookWrapperAttr role="cd-label" + DocBookTag para End Style "Circle" CopyStyle "CD label" LatexName circlepar + DocBookWrapperAttr role="circle" End Style "Diamond" CopyStyle "CD label" LatexName diamondpar + DocBookWrapperAttr role="diamond" End Style "Heart" CopyStyle "CD label" LatexName heartpar + DocBookWrapperAttr role="heart" End Style "Hexagon" CopyStyle "CD label" LatexName hexagonpar + DocBookWrapperAttr role="hexagon" End Style "Nut" CopyStyle "CD label" LatexName nutpar + DocBookWrapperAttr role="nut" End Style "Square" CopyStyle "CD label" LatexName squarepar + DocBookWrapperAttr role="square" End Style "Star" CopyStyle "CD label" LatexName starpar + DocBookWrapperAttr role="star" End # now the shapes defined in the .def files @@ -77,41 +87,49 @@ End Style "Candle" CopyStyle "CD label" LatexName shapepar{\candle} + DocBookWrapperAttr role="candle" End Style "Drop down" CopyStyle "CD label" LatexName droppar + DocBookWrapperAttr role="drop-down" End Style "Drop up" CopyStyle "CD label" LatexName dropuppar + DocBookWrapperAttr role="drop-up" End Style "TeX" CopyStyle "CD label" LatexName shapepar{\TeXshape} + DocBookWrapperAttr role="tex" End Style "Triangle up" CopyStyle "CD label" LatexName triangleuppar + DocBookWrapperAttr role="triangle-up" End Style "Triangle down" CopyStyle "CD label" LatexName triangledownpar + DocBookWrapperAttr role="triangle-down" End Style "Triangle left" CopyStyle "CD label" LatexName triangleleftpar + DocBookWrapperAttr role="triangle-left" End Style "Triangle right" CopyStyle "CD label" LatexName trianglerightpar + DocBookWrapperAttr role="triangle-right" End # finally the low-level commands From 594a4763b784edeaa96f875673dd3b5b4742ffc7 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 2 Sep 2020 00:00:54 +0200 Subject: [PATCH 59/88] Fix a few warnings. --- src/Paragraph.cpp | 4 ++-- src/insets/InsetNewline.cpp | 2 +- src/output_docbook.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 9dea24b1e7..a409d20d3e 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3860,8 +3860,8 @@ bool Paragraph::isHardHyphenOrApostrophe(pos_type pos) const char_type const c = d->text_[pos]; if (c != '-' && c != '\'') return false; - int nextpos = pos + 1; - int prevpos = pos > 0 ? pos - 1 : 0; + pos_type nextpos = pos + 1; + pos_type prevpos = pos > 0 ? pos - 1 : 0; if ((nextpos == psize || isSpace(nextpos)) && (pos == 0 || isSpace(prevpos))) return false; diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index b33cf00768..4c6f17e1d1 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -172,7 +172,7 @@ int InsetNewline::plaintext(odocstringstream & os, } -void InsetNewline::docbook(XMLStream & xs, OutputParams const & runparams) const +void InsetNewline::docbook(XMLStream &, OutputParams const &) const { // New lines are handled by Paragraph::simpleDocBookOnePar. } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 1f17351d3f..087d5a9f67 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -471,7 +471,7 @@ void makeParagraph( // Plain layouts must be ignored. special_case |= buf.params().documentClass().isPlainLayout(par->layout()) && !runparams.docbook_force_pars; // Equations do not deserve their own paragraph (DocBook allows them outside paragraphs). - special_case |= nInsets == par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) { + special_case |= nInsets == (size_t) par->size() && std::all_of(par->insetList().begin(), par->insetList().end(), [](InsetList::Element inset) { return inset.inset && inset.inset->asInsetMath(); }); From abed1f3e6e3654e60f5f4db877fc7f3c3180bbb2 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 2 Sep 2020 00:36:46 +0200 Subject: [PATCH 60/88] DocBook: fix crash with Linguistics example. This was due to Floating::docbookTag not returning anything with the floattype_ tableau. Another issue that happened with that document is that the standard library's isspace crashed for some characters. I therefore implemented a more efficient version of the part that required it, and inlined the definition of isspace (even though that part becomes irrespective of locale, but was that feature ever used?). --- src/Floating.cpp | 4 ++++ src/output_docbook.cpp | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Floating.cpp b/src/Floating.cpp index 19fbf5f49b..a610c73b29 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -98,6 +98,10 @@ string Floating::docbookTag(bool hasTitle) const // TODO: no good translation for now! Figures are the closest match, as they can contain text. // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. return "figure"; + } else { + // If nothing matches, return something that will not be valid. + LYXERR0("Unrecognised float type: " + floattype_); + return "float"; } } diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 087d5a9f67..28d2e1e457 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -427,6 +427,16 @@ void makeBibliography( } +bool isNotOnlySpace(docstring const & str) +{ + for (auto const & c: str) { + if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') + return true; + } + return false; +} + + void makeParagraph( Text const & text, Buffer const & buf, @@ -518,8 +528,8 @@ void makeParagraph( auto nextpar = par; ++nextpar; auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case); - for (auto & parXML : pars) { - if (!std::all_of(parXML.begin(), parXML.end(), ::isspace)) { + for (docstring const & parXML : pars) { + if (isNotOnlySpace(parXML)) { if (open_par) openParTag(xs, &*par, prevpar); From 08a58242c157868efc5b3d52577e09f898725198 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 2 Sep 2020 00:46:08 +0200 Subject: [PATCH 61/88] DocBook: better output with the Linguistics module. One issue left: output within an , that does not make sense... I'm debugging it. --- autotests/export/docbook/Linguistics.lyx | 3209 ++++++++++++++++++++++ autotests/export/docbook/Linguistics.xml | 339 +++ lib/layouts/linguistics.module | 8 + src/Floating.cpp | 5 +- src/output_docbook.cpp | 6 +- 5 files changed, 3563 insertions(+), 4 deletions(-) create mode 100644 autotests/export/docbook/Linguistics.lyx create mode 100644 autotests/export/docbook/Linguistics.xml diff --git a/autotests/export/docbook/Linguistics.lyx b/autotests/export/docbook/Linguistics.lyx new file mode 100644 index 0000000000..39978c3841 --- /dev/null +++ b/autotests/export/docbook/Linguistics.lyx @@ -0,0 +1,3209 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass article +\begin_preamble +%% Kommentieren Sie das Folgende aus, um Tableaux-Überschriften zu erzeugen: +%\floatstyle{plaintop} +%\restylefloat{tableau} + +% Rückwärtskompatibilität zu forest 1.x +% Wenn Sie forest 2.0.1 oder neuer verwenden, +% können Sie das Folgende löschen. +\@ifpackageloaded{forest}{% + \@ifpackagelater{forest}{2016/02/20}{}{% + \forestset{ + roof/.style={edge path={\noexpand\path[\forestoption{edge}]% + (.north west)--(!u.south)--(.north east)--cycle + \forestoption{edge label}; + } + }, + sn edges/.style={ + for tree={parent anchor=south, child anchor=north}, + }, + linguistics preamble/.style={sn edges, baseline, for tree={align=center}} + } + \preto\forest@do{% + \forestOpreto{\forest@root}{given options}{linguistics preamble,}% + } + } +}{} + +% Trennausnahmen +\hyphenation{Dis-kurs-reprä-sen-ta-tions-struk-tur} +\end_preamble +\use_default_options false +\begin_modules +linguistics +\end_modules +\maintain_unincluded_children no +\language ngerman +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "lmodern" "FreeSerif" +\font_sans "default" "FreeSans" +\font_typewriter "default" "FreeMono" +\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 +\float_placement class +\float_alignment class +\paperfontsize default +\spacing single +\use_hyperref true +\pdf_bookmarks true +\pdf_bookmarksnumbered false +\pdf_bookmarksopen false +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder true +\pdf_colorlinks false +\pdf_backref false +\pdf_pdfusetitle true +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\index Stichwortverzeichnis +\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 german +\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 +Linguistische Arbeiten mit \SpecialChar LyX + +\end_layout + +\begin_layout Author +Jürgen Spitzmüller +\begin_inset Newline newline +\end_inset + + +\begin_inset CommandInset href +LatexCommand href +target "spitz@lyx.org" +type "mailto:" +literal "false" + +\end_inset + + +\end_layout + +\begin_layout Date +21.04.2015 +\end_layout + +\begin_layout Abstract +In diesem Text werden einige Funktionen von \SpecialChar LyX + vorgestellt, die spezifisch + auf die Bedürfnisse von Linguistinnen und Linguisten ausgerichtet sind. + Es wird gezeigt, wie nummerierte Beispiele, Interlinear-Glossierung, OT-Tableau +x, semantische Auszeichnung, Strukturbäume, Diskursrepräsentationsstrukturen + und phonetische Notation (IPA) erzeugt werden können. +\end_layout + +\begin_layout Section +Voraussetzungen und Ziele +\end_layout + +\begin_layout Standard +Die meisten der hier beschriebenen Funktionen werden vom +\begin_inset Quotes gld +\end_inset + +Linguistik +\begin_inset Quotes grd +\end_inset + +-Modul bereitgestellt, das seit Version 1.6.0 mit \SpecialChar LyX + mitgeliefert wird. + +\begin_inset Quotes gld +\end_inset + +Module +\begin_inset Quotes grd +\end_inset + + – das Konzept wurde ebenfalls mit \SpecialChar LyX + 1.6.0 eingeführt – sind Ergänzungsdateien, + welche die von der Dokumentklasse bereitgestellten Möglichkeiten zumeist + für sehr spezifische Aufgaben erweitern und die für jedes Dokument (egal + welcher Klasse) einfach ausgewählt werden können. + Um das Linguistik-Modul zu verwenden, gehen sie zu +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +Module +\family default +, wählen Sie +\begin_inset Quotes gld +\end_inset + +Linguistik +\begin_inset Quotes grd +\end_inset + + aus der Liste der verfügbaren Module und drücken auf den Knopf +\family sans +Hinzufügen +\family default + (so wie es für dieses Dokument bereits getan wurde). +\end_layout + +\begin_layout Standard +Grundsätzlich sollte das Modul in jeder von \SpecialChar LyX + unterstützten Dokumentklasse + funktionieren (falls nicht, informieren Sie bitte den Autor dieses Textes). + Allerdings müssen Sie, um alle Features nutzen zu können, die folgenden + \SpecialChar LaTeX +-Pakete installiert haben: +\end_layout + +\begin_layout Enumerate + +\emph on +covington.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "covington" +literal "true" + +\end_inset + +: Dieses Paket wird benötigt, um nummerierte Beispiele, Glossen und semantische + Auszeichnungen zu erzeugen. + Beachten Sie, dass mindestens Version 2.3 des Pakets erforderlich ist, um + alle Funktionen zu nutzen. +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "covington" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate + +\emph on +csquotes.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "csquotes" +literal "true" + +\end_inset + +: Voraussetzung für den Textstil +\emph on +Bedeutung +\emph default + und für Glossen. + Das Paket erlaubt es, kontextsensible Anführungszeichen zu generieren (bspw. + je nach aktuell verwendeter Sprache). +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "csquotes" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate + +\emph on +drs.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "drs" +literal "true" + +\end_inset + +: Voraussetzung für Diskursrepräsentationsstrukturen. + Beachten Sie, dass mindestens Version 2.3 des Pakets +\emph on +covington +\emph default + erforderlich ist, um dies mit anderen Funktionen gemeinsam zu nutzen. +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "drs" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate + +\emph on +float.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "float" +literal "true" + +\end_inset + +: Dieses Paket brauchen wir für die OT-Tableaux und das Tableaux-Verzeichnis. + Es sollte Bestandteil jeder \SpecialChar LaTeX +-Distribution sein. +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "float" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate + +\emph on +forest.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "forest" +literal "true" + +\end_inset + +: Dieses Paket wird zur Erzeugung von Strukturbäumen verwendet. +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "forest" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Enumerate + +\emph on +pict2e.sty +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "pict2e" +literal "true" + +\end_inset + +: Voraussetzung für +\emph on +Duplex-Bedingungs-DRS +\emph default +. +\end_layout + +\begin_deeper +\begin_layout Itemize +Auf Ihrem System installiert: +\begin_inset Info +type "package" +arg "pict2e" +\end_inset + +. +\end_layout + +\end_deeper +\begin_layout Section +Nummerierte Beispiele +\end_layout + +\begin_layout Standard +Nummerierte Beispiele werden über die Absatzstil-Auswahlliste in der Werkzeuglei +ste eingefügt. + Es gibt drei Varianten: +\end_layout + +\begin_layout Numbered Example (multiline) +Das ist ein mehrzeiliges Beispiel [Stil +\emph on +Nummeriertes Beispiel (mehrere Zeilen) +\emph default +] +\end_layout + +\begin_layout Numbered Example (multiline) +Wie der Name sagt, kann es mehrere Absätze enthalten +\end_layout + +\begin_layout Numbered Examples (consecutive) +Das ist ein einzeiliges Beispiel +\begin_inset CommandInset label +LatexCommand label +name "exa:Beispiel-einzeilig" + +\end_inset + + [Stil +\emph on +Nummeriertes Beispiel (konsekutiv) +\emph default +] +\end_layout + +\begin_layout Numbered Examples (consecutive) +Jeder Absatz wird in diesem Stil neu nummeriert +\end_layout + +\begin_layout Subexample +Dies ist ein Unterbeispiel +\begin_inset CommandInset label +LatexCommand label +name "subsec:Unterbeispiel" + +\end_inset + + [Stil +\emph on +Unterbeispiel +\emph default +] +\end_layout + +\begin_layout Subexample +Und hier noch eines +\end_layout + +\begin_layout Standard +Querverweise auf Beispiele erzeugen Sie wie gewohnt: Sie fügen im Beispiel + eine Marke ein, und an der Stelle, an der der Querverweis erscheinen soll, + einen Verweis mittels +\family sans +Einfügen\SpecialChar menuseparator +Querverweis\SpecialChar ldots + +\family default + +\end_layout + +\begin_layout Standard +Als kleine Demonstration verweisen wir hier auf die Beispiele +\begin_inset CommandInset ref +LatexCommand ref +reference "exa:Beispiel-einzeilig" + +\end_inset + + und +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:Unterbeispiel" + +\end_inset + +. +\end_layout + +\begin_layout Standard +Wenn Sie die Nummerierung für einzelne Beispiele ändern möchten, verwenden + Sie +\family sans +Einfügen\SpecialChar menuseparator +Benutzerdef. + Nummerierung +\family default +. + Für globale Anpassungen bietet +\emph on +covington +\emph default + selbst Möglichkeiten. + Bitte konsultieren Sie das Handbuch des Pakets +\begin_inset CommandInset citation +LatexCommand cite +key "covington" +literal "false" + +\end_inset + + für Einzelheiten. +\end_layout + +\begin_layout Standard +Ab Version 2.3 bietet +\emph on +covingtons +\emph default + subexamples-Umgebung ein optionales Argument (mit dem man Text zwischen + der Hauptnummer und dem ersten Unterbeispiel einfügen kann). + Dieses können Sie über +\family sans +Einfügen\SpecialChar menuseparator +Optionen für Unterbeispiele +\family default + eingeben. + Bitte konsultieren Sie auch hier das Handbuch des Pakets +\begin_inset CommandInset citation +LatexCommand cite +key "covington" +literal "false" + +\end_inset + + für Einzelheiten. +\end_layout + +\begin_layout Section +Interlinear-Glossierung +\end_layout + +\begin_layout Standard +Das Linguistikmodul stellt zwei Arten von Glossen zur Verfügung. + Beide sind über +\family sans +Einfügen\SpecialChar menuseparator +Spezifische Einfügung +\family default + zugänglich. + Die +\emph on +Interlinear-Glosse (2 +\begin_inset space ~ +\end_inset + +Zeilen) +\emph default + besteht aus zwei Zeilen für das Glossenpaar (bestehend aus der Darstellung + in der zu beschreibenden Sprache und einer interlinearen Wort-zu-Wort-Übersetzu +ng) sowie einer weiteren Zeile für die freie Übersetzung, die +\emph on +Interlinear-Glosse (3 +\begin_inset space ~ +\end_inset + +Zeilen) +\emph default + bietet eine zusätzliche Zeile für Interlinear-Glossierung (diese dritte + Zeile wird zumeist für morphologische oder phonologische Angaben verwendet). + Die freie Übersetzung kann länger sein als eine Zeile, sie wird dann einfach + automatisch und korrekt umbrochen. + Die Version in der zu beschreibenden Sprache (erste Zeile der Glosse) wird + direkt in die Glosse-Einfügung geschrieben, alle anderen Teile der Glosse + in spezifische Unter-Einfügungen ( +\family sans +Interlinear-Glosse +\family default +, bzw. + mit dreizeiligen Glossen: +\family sans +Interlinear-Glosse (Zeile +\begin_inset space ~ +\end_inset + +1) +\family default + und +\family sans +Interlinear-Glosse (Zeile +\begin_inset space ~ +\end_inset + +2) +\family default +, sowie +\family sans +Glossen-Übersetzung +\family default +). + \SpecialChar LyX + fügt diese Unter-Einfügungen automatisch ein, wenn Sie eine neue Glosse + einfügen. + Sie können aber auch manuell eingefügt werden, und zwar über +\family sans +Einfügen\SpecialChar menuseparator +Glossen-Übersetzung +\family default + und +\family sans +Einfügen\SpecialChar menuseparator +Interlinear-Glosse +\family default +. + Ungeachtet wo Sie diese Untereinfügungen innerhalb der Glosse einfügen, + wird alles in der richtigen Reihenfolge ausgegeben. + Schließlich können Sie über +\family sans +Einfügen\SpecialChar menuseparator +Glossen-Optionen +\family default + auch Glossen-Optionen eingeben. + Diese Optionen erlauben es Ihnen, die Darstellung der einzelnen Zeilen + zu verändern, eine Nummerierung oder vorangestellten Text hinzuzufügen. + Bitte konsultieren Sie das Handbuch des Pakets +\emph on +covington +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "covington" +literal "false" + +\end_inset + + für Einzelheiten. +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +Bitte beachten Sie, dass die Unterstützung für Glossen für \SpecialChar LyX + 2.4 komplett + überarbeitet wurde. + Nun werden die neuen und verbesserten Glossen-Makros verwendet, die +\emph on +covington +\emph default + seit der Version 2.0 anbietet. + Wegen der erheblichen Veränderungen können alte Glossen leider nicht in + die neuen konvertiert werden. + Statt dessen werden sie in ihrer ursprünglichen Form importiert (und als + +\family sans +Lokales Format +\family default + im Dokument gespeichert). + Umgekehrt werden neue Glossen in \SpecialChar TeX +-Code exportier, wenn Sie in eine ältere + \SpecialChar LyX +-Version exportieren. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Hier ist ein einfaches Beispiel für eine zweizeilige Glosse: +\end_layout + +\begin_layout Standard +\begin_inset Flex Interlinear Gloss (2 Lines) +status open + +\begin_layout Plain Layout +C'est un exemple simple +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +\begin_inset Flex GroupGlossedWords +status open + +\begin_layout Plain Layout +Dies ist +\end_layout + +\end_inset + + ein Beispiel einfach +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +Dies ist ein einfaches Beispiel +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\noindent +Verwenden Sie +\family sans +Bearbeiten\SpecialChar menuseparator +Textstil\SpecialChar menuseparator +Glossierte Wortgruppen +\family default +, um Mehrwortelemente zusammenzuhalten (alternativ können Sie auch im TeX-Modus + +\begin_inset ERT +status open + +\begin_layout Plain Layout + +{ +\end_layout + +\end_inset + +diese Wörter geschweift einklammern +\begin_inset ERT +status open + +\begin_layout Plain Layout + +} +\end_layout + +\end_inset + +). + Beachten Sie, dass Sie im \SpecialChar LyX +-Fenster mehrere Leerzeichen nacheinander einfügen + können, um die Glossen dort schöner auszurichten. + Die Ausgabe wird davon nicht berührt. +\end_layout + +\begin_layout Standard +Hier ist eine dreizeilige Glosse. + Sie wird analog erzeugt: +\end_layout + +\begin_layout Standard +\begin_inset Flex Interlinear Gloss (3 Lines) +status open + +\begin_layout Plain Layout +Hoc est aliud exemplum +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +n.sg.nom 3sg n.sg.nom n.sg.nom +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +Dies ist anderes Beispiel +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout +Dies ist ein anderes Beispiel +\end_layout + +\end_inset + + +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +\begin_inset ERT +status open + +\begin_layout Plain Layout + +fsii={ +\backslash +normalfont +\backslash +scshape} +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Beachten Sie, wie wir hier mit Hilfe der Glossen-Optionen die zweite Zeile + in Kapitälchen ausgeben lassen. +\end_layout + +\begin_layout Standard +\noindent +Wenn Sie nummerierte Glossen benötigen, fügen Sie die Glosse entweder einfach + in einen Absatz mit dem Format +\emph on +Nummeriertes Beispiel +\emph default + ein, so wie hier: +\end_layout + +\begin_layout Numbered Examples (consecutive) +\begin_inset Flex Interlinear Gloss (3 Lines) +status open + +\begin_layout Plain Layout +Mein Luftkissenfahrzeug ist voller Aale +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +My skeertuig is vol palings +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +My hovercraft is +\begin_inset Flex GroupGlossedWords +status open + +\begin_layout Plain Layout +full of +\end_layout + +\end_inset + + eels +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout +Do you have matches? +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +oder verwenden Sie die Glossen-Option +\emph on +ex +\emph default +: +\end_layout + +\begin_layout Standard +\begin_inset Flex Interlinear Gloss (3 Lines) +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +ex +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Mein Luftkissenfahrzeug ist voller Aale +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +My skeertuig is vol palings +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +My hovercraft is +\begin_inset Flex GroupGlossedWords +status open + +\begin_layout Plain Layout +full of +\end_layout + +\end_inset + + eels +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout +Do you have matches? +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Subsection* +Tipps & Tricks +\end_layout + +\begin_layout Subsubsection* +Seitenumbrüche innerhalb von Glossen vermeiden +\end_layout + +\begin_layout Standard +In der Standardeinstellung können innerhalb von Glossen Seiten umbrochen + werden, was natürlich nicht erwünscht ist. + Um dies zu umgehen, können Sie in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar ldots +\SpecialChar menuseparator +Dokumentklasse\SpecialChar menuseparator +Klassenoptionen\SpecialChar menuseparator +Benutzerdefiniert +\family default + die Option +\emph on +noglossbreaks +\emph default + eingeben; dies wird die meisten Umbrüche verhindern. + Wenn trotzdem welche vorkommen, können Sie Glossen in Boxen packen (über + +\family sans +Einfügen\SpecialChar menuseparator +Box\SpecialChar menuseparator +Rahmenlos +\family default +). +\end_layout + +\begin_layout Subsubsection* +Fußnoten in Glossen +\end_layout + +\begin_layout Standard +Sie können zwar eine Fußnote in eine +\emph on +Glosse +\emph default +einfügen, dies führt aber zu einem LaTeX-Fehler. + Wenn Sie Fußnoten benötigen, schreiben Sie an der Stelle, an der das Fußnotenze +ichen erscheinen soll, im TeX-Modus +\family typewriter + +\backslash +footnotemark +\family default + in die Glosse. + Direkt nach (und außerhalb) der Glosse schreiben Sie, ebenfalls im TeX-Modus, +\family typewriter + +\backslash +footnotetext{Die Fußnote ...} +\family default +. + Sollten Sie mehrere Fußnoten brauchen, geben Sie einfach mehrere dieser + Befehlspaare ein. +\end_layout + +\begin_layout Subsubsection* +Glossen (und Beispiele) in Beamer-Präsentationen +\end_layout + +\begin_layout Standard +Wenn Sie das Linguistik-Modul in einer Beamer-Präsentation verwenden wollen, + beachten Sie bitte folgendes: +\end_layout + +\begin_layout Itemize +Für Glossen müssen Sie in Beamer immer einen +\begin_inset Quotes gld +\end_inset + +fragilen +\begin_inset Quotes grd +\end_inset + + Rahmen verwenden. + +\end_layout + +\begin_layout Itemize +Ältere Versionen des Pakets +\emph on +covington +\emph default + und die +\emph on +Beamer +\emph default +-Klasse arbeiten von Haus aus nicht gut zusammen, da beide die Befehle +\family typewriter + +\backslash +example +\family default + und +\family typewriter + +\backslash +examples +\family default + zu definieren versuchen, was in diesen älteren Versionen eine \SpecialChar LaTeX +-Fehlermeldung + erzeugt, sobald sie Glossen oder Beispiele einfügen. + Sie können das Problem beheben, indem Sie in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +Lokales Format +\family default + folgenden Code kopieren: +\end_layout + +\begin_deeper +\begin_layout Quote +\begin_inset listings +lstparams "basicstyle={\footnotesize\ttfamily},tabsize=4" +inline false +status open + +\begin_layout Plain Layout + +Provides covington 1 +\end_layout + +\begin_layout Plain Layout + +AddToPreamble +\end_layout + +\begin_layout Plain Layout + + +\backslash +let +\backslash +example +\backslash +relax +\end_layout + +\begin_layout Plain Layout + + +\backslash +let +\backslash +endexample +\backslash +relax +\end_layout + +\begin_layout Plain Layout + + +\backslash +let +\backslash +examples +\backslash +relax +\end_layout + +\begin_layout Plain Layout + + +\backslash +let +\backslash +endexamples +\backslash +relax +\end_layout + +\begin_layout Plain Layout + + +\backslash +usepackage{covington} +\end_layout + +\begin_layout Plain Layout + +EndPreamble +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Drücken Sie +\begin_inset Quotes gld +\end_inset + +Validieren +\begin_inset Quotes grd +\end_inset + + und dann +\begin_inset Quotes gld +\end_inset + +OK +\begin_inset Quotes grd +\end_inset + +. + Dies hat den Effekt, dass die Beispiel-Umgebungen von Beamer deaktiviert + werden (und also nicht mehr verwendet werden können), dafür können Sie + dann aber die des Linguistik-Moduls verwenden. +\end_layout + +\begin_layout Standard +Ab +\emph on +covington +\emph default + 1.1 besteht dieses Problem nicht mehr. +\end_layout + +\end_deeper +\begin_layout Section +Tableaux für Optimalitätstheorie +\end_layout + +\begin_layout Standard +Die OT-Tableaux selbst können natürlich einfach als normale Tabellen eingegeben + werden (Spezifika wie gestrichelte Tabellenlinien und schattierte Tabellenzelle +n, die man hierfür manchmal braucht, sind in +\family sans +Hilfe\SpecialChar menuseparator +Eingebettete Objekt +\family default +e beschrieben). + +\end_layout + +\begin_layout Standard +Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren + und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel + von \SpecialChar LyX + nicht aus. + Auch hier hilft das Linguistikmodul. + Wenn es ausgewählt ist, finden Sie unter +\family sans +Einfügen\SpecialChar menuseparator +Gleitobjekte +\family default + zusätzlich ein Tableau-Gleitobjekt (siehe Tableau +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "tab:Beispiel-Tableau" + +\end_inset + + für ein Beispiel). +\end_layout + +\begin_layout Standard +\begin_inset Float tableau +placement h +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\align center +\begin_inset Tabular + + + + + + + + + +\begin_inset Text + +\begin_layout Plain Layout +/atikap/ +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\noun on +Onset +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\noun on +NoCoda +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\noun on +Dep +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\noun on +Max +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\mbox{☞}$ +\end_inset + + +\begin_inset Formula $\mbox{\textipa{P}}$ +\end_inset + +a.ti.ka +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +* +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +* +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +a.ti.ka +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +*! +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +* +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +\begin_inset Formula $\mbox{\textipa{P}}$ +\end_inset + +a.ti.kap +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +*! +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +* +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Plain Layout +a.ti.kap +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +*! +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout +*! +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Plain Layout + +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +Beispiel-Tableau +\begin_inset CommandInset label +LatexCommand label +name "tab:Beispiel-Tableau" + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter + dem Tableau ausgegeben wird, egal, wohin Sie sie im \SpecialChar LyX +-Arbeitsfenster setzen. + Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code + in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +Präambel +\family default +eingeben: +\end_layout + +\begin_layout Quote +\begin_inset listings +lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}" +inline false +status open + +\begin_layout Plain Layout + + +\backslash +floatstyle{plaintop} +\end_layout + +\begin_layout Plain Layout + + +\backslash +restylefloat{tableau} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Wenn Sie eine KOMA-Klasse verwenden, nehmen Sie statt dessen das Folgende + (welches im Kontext der KOMA-Klassen bessere Abstände erzeugt): +\end_layout + +\begin_layout Quote +\begin_inset listings +lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}" +inline false +status open + +\begin_layout Plain Layout + + +\backslash +floatstyle{komaabove} +\end_layout + +\begin_layout Plain Layout + + +\backslash +restylefloat{tableau} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Ein Verzeichnis der Tableaux geben Sie, wie bei normalen Tabellen auch, + über +\family sans +Einfügen\SpecialChar menuseparator +Liste\SpecialChar breakableslash +Inhaltsverzeichnis +\family default + ein. + Dies sieht dann so aus: +\end_layout + +\begin_layout Standard +\begin_inset FloatList tableau + +\end_inset + + +\end_layout + +\begin_layout Section +Semantische Auszeichnung (Textstile) +\end_layout + +\begin_layout Standard +Das Linguistikmodul stellt einige Textstile zur Verfügung, die in linguistischen + Arbeiten allgemein gebräuchlich sind: +\end_layout + +\begin_layout Enumerate +Konzept (in Kapitälchen): +\begin_inset Flex Concepts +status collapsed + +\begin_layout Plain Layout +Konzept +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Ausdruck (hervorgehoben): +\begin_inset Flex Expression +status collapsed + +\begin_layout Plain Layout +Ausdruck +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +Bedeutung (in einfachen Anführungszeichen): +\begin_inset Flex Meaning +status collapsed + +\begin_layout Plain Layout +Bedeutung +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Diese Textstile finden Sie unter +\family sans +Bearbeiten\SpecialChar menuseparator +Textstil +\family default +. + Der Vorteil solcher Stile gegenüber direkter Hervorhebung und Auszeichnung + ist vor allem der, dass sie alle (und nur die) damit markierten Textteile + leicht global verändern können. + Wenn Sie (oder Ihr Verlag) also etwa Ausdrücke doch fett gesetzt haben + wollen, geben Sie einfach den folgenden Code in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +Präambel +\family default + ein: +\end_layout + +\begin_layout Quote +\begin_inset listings +lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}" +inline false +status open + +\begin_layout Plain Layout + + +\backslash +renewcommand +\backslash +lexp[1]{ +\backslash +textbf{#1}} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Auf ähnliche Weise kann auch das Aussehen von +\emph on +Konzept +\emph default + ( +\family typewriter + +\backslash +lcon +\family default +) und +\emph on +Bedeutung +\emph default + ( +\family typewriter + +\backslash +lmean +\family default +) verändert werden. + Bitte konsultieren Sie das Handbuch des Pakets +\emph on +covington +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "covington" +literal "false" + +\end_inset + + für Einzelheiten. +\end_layout + +\begin_layout Section +Linguistische Strukturbäume +\end_layout + +\begin_layout Standard +Mittlerweile gibt es mehrere \SpecialChar LaTeX +-Pakete, die bei der Erstellung von Strukturbäumen + helfen. + \SpecialChar LyX + unterstützt das Paket +\family sans +forest +\family default +, welches hohe Flexibilität und Mächtigkeit mit einer intuitiven Syntax + vereint. + Das Linguistik-Modul enthält eine Strukturbaum-Einfügung, die unter +\family sans +Einfügen\SpecialChar menuseparator +Spezifische Einfügung +\family default + zu finden ist. + Innerhalb dieser Einfügung können Sie die Klammernotation verwenden, die + das Paket +\family sans +forest +\family default + (wie auch andere Pakete, z. +\begin_inset space \thinspace{} +\end_inset + +B. + +\family sans +qtree +\family default +) anbietet. +\end_layout + +\begin_layout Standard +Hier ist ein einfaches Beispiel: +\end_layout + +\begin_layout Standard +\begin_inset Flex Structure Tree +status open + +\begin_layout Plain Layout +[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]] ] + ] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\noindent +Wenn Sie die PDF-Ausgabe ansehen, sehen Sie, dass die Notation +\end_layout + +\begin_layout Quote + +\family typewriter +\size footnotesize +[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]]]] +\end_layout + +\begin_layout Standard +als Strukturbaum ausgegeben wird. + Um das Ergebnis bereits im \SpecialChar LyX + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +"= +\end_layout + +\end_inset + +Eingabefenster zu sehen, können Sie die Strukturbaum-Einfügung einfach in + eine Vorschau-Einfügung ( +\family sans +Einfügen\SpecialChar menuseparator +Vorschau +\family default +) einbetten. + Wenn +\begin_inset Quotes gld +\end_inset + +Sofortige Vorschau +\begin_inset Quotes grd +\end_inset + + richtig eingerichtet und aktiviert ist, sollten Sie den Baum sofort sehen + (zur Bearbeitung klicken Sie einfach auf das Bild): +\end_layout + +\begin_layout Standard +\begin_inset Preview + +\begin_layout Standard +\begin_inset Flex Structure Tree +status open + +\begin_layout Plain Layout +[VP [DP[Maria]] [V' [V[schickt]] [DP[Hans]] [DP[D[eine]][NP[Antwort]]] ] + ] +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\noindent +Dächer ( +\begin_inset Quotes gld +\end_inset + +roofs +\begin_inset Quotes grd +\end_inset + +) können mittels der Option +\begin_inset Quotes gld +\end_inset + +roof +\begin_inset Quotes grd +\end_inset + + +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +\noindent +Bitte beachten Sie, dass die Option +\begin_inset Quotes gld +\end_inset + +roof +\begin_inset Quotes grd +\end_inset + + erst ab Version 2.0 des Pakets +\family sans +forest +\family default + verfügbar ist. + Für frühere Versionen haben wir in den Vorspann dieses Dokuments Code eingefügt +, die die Verwendung dennoch gestattet. + Wenn Ihre Version des Pakets +\family sans +forest +\family default + kleiner ist als 2.0 und Sie +\begin_inset Quotes gld +\end_inset + +roof +\begin_inset Quotes grd +\end_inset + + verwenden wollen, müssen Sie diesen Code in den Vorspann Ihres Dokuments + kopieren. + Statt dessen können Sie auch die alte Option +\begin_inset Quotes gld +\end_inset + +triangle +\begin_inset Quotes grd +\end_inset + + (statt +\begin_inset Quotes gld +\end_inset + +roof +\begin_inset Quotes grd +\end_inset + +) verwenden. +\end_layout + +\end_inset + + erzeugt werden (beachten Sie, dass Kommata eine spezielle Bedeutung haben; + sie markieren Optionen): +\end_layout + +\begin_layout Standard +\begin_inset Flex Structure Tree +status open + +\begin_layout Plain Layout +[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[einen weiteren Brief, roof]] + ] ] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\noindent +Um die Knoten des Baums besser auszurichten, verwenden Sie die Option +\begin_inset Quotes gld +\end_inset + +tier +\begin_inset Quotes grd +\end_inset + +. + Alle Knoten, denen dieselbe +\begin_inset Quotes gld +\end_inset + +tier +\begin_inset Quotes grd +\end_inset + + (Ebene) zugewiesen wurde, werden in einer vertikalen Linie ausgerichtet. + Hier ist ein Beispiel: +\end_layout + +\begin_layout Standard +\begin_inset Flex Structure Tree +status open + +\begin_layout Plain Layout +[VP [DP[Hans, tier=word]] [V' [V[schickt, tier=word]] [DP[Maria, tier=word]] + [DP[D[einen, tier=word]][NP[Brief, tier=word]]] ] ] +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\noindent +Das Paket bietet viel mehr Möglichkeiten, wie bspw. + Bewegungspfeile und Dekorationen. + Sie können hier nicht eingehend besprochen werden. + Bitte konsultieren Sie die ausführliche Dokumentation des Pakets +\begin_inset CommandInset citation +LatexCommand cite +key "forest" +literal "true" + +\end_inset + +. +\end_layout + +\begin_layout Section +Diskursrepräsentationsstrukturen +\end_layout + +\begin_layout Standard +Das Linguistik-Modul stellt auch Einfügungen zur Erzeugung von Diskursrepräsenta +tionsstrukturen (DRSen) in der Box-Notation von +\noun on +Hans Kamps +\noun default + +\emph on +Diskursrepräsentationstheorie +\emph default + zur Verfügung. + Diese Einfügungen finden Sie unter +\family sans +Einfügen\SpecialChar menuseparator +Spezifische Einfügung +\family default +. +\end_layout + +\begin_layout Standard +Eine einfache DRS erzeugen Sie mit der Einfügung +\family sans +Diskursrepräsentationsstruktur +\family default +. + Eine DRS besteht aus (Diskurs-) +\emph on +Bedingungen +\emph default +, die direkt in die Einfügung geschrieben werden, uns den (u. +\begin_inset space \thinspace{} +\end_inset + +U. + leeren) (Diskurs-) +\emph on +Referenten +\emph default + (bzw., im DRT-Jargon, dem +\emph on +Universum +\emph default +), welche in die (automatisch eingefügte) Untereinfügung +\emph on +Referenten +\emph default + geschrieben werden. +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +Sollte diese nicht eingefügt werden, finden Sie sie unter +\family sans +Einfügen\SpecialChar menuseparator +DRS-Referenten +\family default +. + +\end_layout + +\end_inset + + Zeilenwechsel müssen mittels +\begin_inset Info +type "shortcut" +arg "newline-insert newline" +\end_inset + + eingefügt werden. + Hier ist ein einfaches Beispiel: +\end_layout + +\begin_layout Standard +\begin_inset VSpace defskip +\end_inset + + +\begin_inset Flex DRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Esel(x) +\begin_inset Newline newline +\end_inset + +grün(x) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset VSpace defskip +\end_inset + + +\end_layout + +\begin_layout Standard +DRSen sind durch spezifische Layout-Anpassungen so gestaltet, dass Sie gut + auf der Seite platziert werden. + Die Variante +\family sans +Diskursrepräsentationsstruktur (einfach) +\family default + unterdrückt diese Anpassungen. + +\end_layout + +\begin_layout Standard +Zusätzlich zu diesen einfachen DRSen werden die folgenden konditionalen + DRSen unterstützt (sie werden in der Regel in einfache eingebettet): +\end_layout + +\begin_layout Enumerate +Die +\family sans +Implikative DRS +\family default + repräsentiert eine konditionale (implikative) Satzkonstruktion der Form + +\emph on +wenn S +\begin_inset script subscript + +\begin_layout Plain Layout + +\emph off +1 +\end_layout + +\end_inset + +, dann S +\emph default + +\begin_inset script subscript + +\begin_layout Plain Layout +2 +\end_layout + +\end_inset + +: +\end_layout + +\begin_deeper +\begin_layout Standard +\begin_inset Flex IfThen-DRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +x +\begin_inset space ~ +\end_inset + +y +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Joseph(x) +\begin_inset Newline newline +\end_inset + +Esel(y) +\begin_inset Newline newline +\end_inset + +besitzen(x,y) +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +z +\begin_inset space ~ +\end_inset + +w +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +z = x +\begin_inset Newline newline +\end_inset + +w = y +\begin_inset Newline newline +\end_inset + +füttern(z,w) +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate +Die +\family sans +Konditionale DRS +\family default + ist eine allgemeinere Variante, bei der Sie selbst eine beliebige Bedingung + (statt der implikativen) spezifizieren können. + In die Untereinfügung +\family sans +Bedingung +\family default + können Sie ein beliebiges Symbol eingeben: +\end_layout + +\begin_deeper +\begin_layout Standard +\begin_inset Flex Cond-DRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +x +\begin_inset space ~ +\end_inset + +y +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Joseph(x) +\begin_inset Newline newline +\end_inset + +Esel(y) +\begin_inset Newline newline +\end_inset + +besitzen(x,y) +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +\begin_inset Formula $\wedge\!\,$ +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +z +\begin_inset space ~ +\end_inset + +w +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout +z = x +\begin_inset Newline newline +\end_inset + +w = y +\begin_inset Newline newline +\end_inset + +lieben(w,z) +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate +Die +\family sans +Duplex-Bedingungs-DRS +\family default + können Sie für sog. + +\emph on +Duplex-Bedingungen +\emph default + verwenden: +\end_layout + +\begin_deeper +\begin_layout Standard +\begin_inset Flex QDRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +x +\begin_inset Formula $\in$ +\end_inset + + X +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:1 +status open + +\begin_layout Plain Layout +alle +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:2 +status open + +\begin_layout Plain Layout +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:3 +status open + +\begin_layout Plain Layout +y +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument post:4 +status open + +\begin_layout Plain Layout +Sekretärin(y) +\begin_inset Newline newline +\end_inset + +anstellen(x,y) +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Enumerate +Die +\family sans +Negierte DRS +\family default + fügt eine DRS ein, der ein Negationszeichen vorangestellt ist: +\end_layout + +\begin_deeper +\begin_layout Standard +\begin_inset Flex NegDRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Esel(x) +\begin_inset Newline newline +\end_inset + +grün(x) +\end_layout + +\end_inset + + +\end_layout + +\end_deeper +\begin_layout Standard + +\family sans +DRS mit Satz oberhalb +\family default + schließlich tut, was es verspricht: Es setzt einen Satz über die Box-Repräsenta +tion: +\end_layout + +\begin_layout Standard +\begin_inset VSpace defskip +\end_inset + + +\begin_inset Flex SDRS +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout +Ein Esel ist grün +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Argument 2 +status open + +\begin_layout Plain Layout +x +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +Esel(x) +\begin_inset Newline newline +\end_inset + +grün(x) +\end_layout + +\end_inset + + +\begin_inset VSpace defskip +\end_inset + + +\end_layout + +\begin_layout Standard +Das Paket +\emph on +drs +\emph default + bietet einige Möglichkeiten, um das Erscheinungsbild der DRS-Modelle anzupassen. + Bitte konsultieren Sie das Handbuch des Pakets +\begin_inset CommandInset citation +LatexCommand cite +key "drs" +literal "false" + +\end_inset + + für Einzelheiten. +\end_layout + +\begin_layout Section +Phonetische Notation (IPA) +\end_layout + +\begin_layout Standard +Um phonetische Zeichen einzugeben, brauchen Sie das Linguistikmodul nicht. + IPA-Unterstützung ist mittlerweile eine Grundfunktion von \SpecialChar LyX +. + Da IPA aber von Linguistinnen und Linguisten sehr häufig gebraucht wird, + wird die Verwendung der IPA-Funktion hier trotzdem (kurz) beschrieben. +\end_layout + +\begin_layout Standard +Um \SpecialChar LyX +' IPA-Funktion mit klassischem \SpecialChar LaTeX + oder PDF\SpecialChar LaTeX + zu benutzen, müssen Sie das + Paket +\emph on +tipa +\emph default + +\begin_inset CommandInset citation +LatexCommand cite +key "tipa" +literal "true" + +\end_inset + + installiert haben. + Es wird von \SpecialChar LyX + automatisch geladen, wenn Sie dem unten beschriebenen Vorgehen + folgen. + Wenn Sie Xe\SpecialChar TeX + oder Lua\SpecialChar TeX + verwenden (und +\begin_inset Quotes gld +\end_inset + +Nicht-\SpecialChar TeX +-Schriften verwenden +\begin_inset Quotes grd +\end_inset + + in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +Schriften +\family default + aktiviert haben), wird statt dessen das Paket +\emph on +xunicode +\emph default + geladen, da +\emph on +tipa +\emph default + in diesem Fall nicht funktioniert. + Das Paket +\emph on +xunicode +\emph default + emuliert die Ausgabe von +\emph on +tipa +\emph default +, ist aber nicht perfekt, so dass die Ausgabe möglicherweise nicht wie erwartet + ist. + Außerdem müssen Sie in diesem Fall darauf achten, dass die Nicht-\SpecialChar TeX +-Schrift + die IPA-Symbole auch enthält (empfehlenswert sind Schriften wie +\emph on +CMU Serif +\emph default + oder +\emph on +SIL Doulos +\emph default +). + Sie können auch eine Schrift nur für IPA definieren, indem sie das Folgende + in +\family sans +Dokument\SpecialChar menuseparator +Einstellungen\SpecialChar menuseparator +LaTeX-Vorspann +\family default + eingeben: +\end_layout + +\begin_layout Standard +\begin_inset listings +lstparams "language={[LaTeX]TeX},basicstyle={\footnotesize\ttfamily}" +inline false +status open + +\begin_layout Plain Layout + + +\backslash +AtBeginDocument{% +\end_layout + +\begin_layout Plain Layout + + +\backslash +newfontfamily{ +\backslash +ipafont}{CMU Serif}% oder eine ander Schriftart +\end_layout + +\begin_layout Plain Layout + + +\backslash +def +\backslash +useTIPAfont{ +\backslash +ipafont} +\end_layout + +\begin_layout Plain Layout + +} +\end_layout + +\end_inset + +Für eine direkte Vorschau der IPA-Symbole im Arbeitsfenster sollten Sie + weiterhin (egal, welche der oben beschriebenen Ausgabeformate Sie verwenden) + das +\emph on +preview-latex +\emph default +-Paket +\begin_inset CommandInset citation +LatexCommand cite +key "preview" +literal "true" + +\end_inset + + installiert haben. +\end_layout + +\begin_layout Standard +Phonetische Zeichen werden in eine spezielle Umgebung eingegeben, die Sie + über +\family sans +Einfügen\SpecialChar menuseparator +Sonderzeichen\SpecialChar menuseparator +Phonetische Symbole +\family default +aktivieren. + Es wird ein kleiner umrahmter Eingabebereich eingefügt, in den Sie einzelne + Zeichen, Wörter und Wortfolgen sowie auch mehrere Absätze mit phonetischer + Notation eingeben können. + Wenn Sie in dem Eingabebereich sind, wird eine Symbolleiste aktiviert, + die die wichtigsten IPA-Symbole (nach den IPA-Kategorien sortiert) bereitstellt. +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +Es fehlt ein Symbol: der (2005 in das IPA aufgenommene) labiodentale Flap. + Dieses Zeichen unterstützt das +\emph on +Tipa- +\emph default +Paket noch nicht; daher kann es auch nicht von LyX unterstützt werden. +\end_layout + +\end_inset + + Jeder Symbolbereich dieser Symbolleiste kann durch Klicken auf die gestrichelte + Linie abgetrennt werden. + Dadurch kann phonetische Notation recht komfortabel eingegeben werden: + +\begin_inset IPA + +\begin_layout Standard +[ˈɛtva zo:] +\end_layout + +\end_inset + +. +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +Wenn Sie ein diakritisches Zeichen einfügen möchten, müssen Sie das Diakritikum + +\emph on +nach +\emph default + dem Basiszeichen einfügen. + Das heißt, für +\begin_inset IPA + +\begin_layout Standard +[d̥] +\end_layout + +\end_inset + + geben Sie zuerst +\family typewriter + +\family default + ein und dann direkt danach das Diakritikum +\family typewriter + +\family default + von der Symbolleiste. + Wenn Sie nur ein Diakritikum eingeben möchten, können Sie das direkt nach + einem Leerzeichen tun, so wie hier: +\begin_inset IPA + +\begin_layout Standard + ̼ +\end_layout + +\end_inset + + ( +\family typewriter += +\begin_inset space ~ +\end_inset + ++ +\family default +). +\end_layout + +\end_inset + + Wenn +\emph on + preview-latex +\emph default + installiert ist und Sie außerdem in +\family sans + Werkzeuge\SpecialChar menuseparator +Einstellungen\SpecialChar ldots +\SpecialChar menuseparator +Grafik +\family default + +\begin_inset Quotes gld +\end_inset + +Sofortige Vorschau +\begin_inset Quotes grd +\end_inset + + aktiviert haben, zeigt \SpecialChar LyX + eine WYSIWYG-Vorschau der Notation an, sobald der + Cursor den IPA-Bereich verlässt. + Alternativ zur Symbolleiste können Sie die Zeichen auch direkt mithilfe + der Kurznotation eingeben können, die im +\emph on +tipa +\emph default +-Handbuch erläutert wird: hier eine +\begin_inset IPA + +\begin_layout Standard +[kOst"pro:b@] +\end_layout + +\end_inset + + ( +\emph on +tipa +\emph default +-Kurznotation: +\family typewriter +[kOst"pro:b@ +\family default +]). + Alternativ können Sie die meisten IPA-Zeichen auch über +\family sans +Einfügen\SpecialChar menuseparator +Sonderzeichen\SpecialChar menuseparator +Symbole\SpecialChar ldots + +\family default + in das Eingabefeld eingeben oder sie aus einem anderen Dokument kopieren + und dort einfügen. + Die Ausgabe sollte immer identisch sein, egal welche Eingabemethode Sie + wählen. +\end_layout + +\begin_layout Standard +Bitte beachten Sie, dass Sie die meisten IPA-Zeichen über die zuletzt genannten + Methoden auch außerhalb des IPA-Eingabebereichs einfügen können: [zoː viː + hiːɐ̯]. + In der Ausgabe werden diese Zeichen dann ebenfalls direkt in die korrekten + +\emph on +tipa +\emph default +-Makros umgewandelt (lassen Sie es uns wissen, falls das nicht der Fall + ist). + Dieses Verfahren hat aber gravierende Nachteile gegenüber der IPA-Umgebung, + denn die direkte Eingabe resultiert in der Regel in unerwünschter Schriftmischu +ng (die lateinischen Buchstaben werden aus der Grundschrift, die speziellen + IPA-Zeichen aber aus der IPA-Schrift genommen, und diese beiden Schriften + passen nicht notwendigerweise zusammen). + Innerhalb der IPA-Eingabeumgebung wird dagegen für alle Zeichen dieselbe + Schrift verwendet. + Deshalb sollten Sie, wenn Sie nicht nur Einzelzeichen eingeben, unbedingt + den IPA-Eingabebereich verwenden. +\end_layout + +\begin_layout Section +Weitere Informationen +\end_layout + +\begin_layout Standard +Mehr und ausführlichere Informationen über die Möglichkeiten des Einsatzes + von \SpecialChar LyX + für linguistische Zwecke finden Sie auf der (englischsprachigen) +\emph on +Linguist\SpecialChar LyX + +\emph default +-Seite auf dem \SpecialChar LyX +-Wiki +\begin_inset CommandInset citation +LatexCommand cite +key "linguistlyx" +literal "true" + +\end_inset + +. + Sie sind übrigens herzlich eingeladen, dort aktiv mitzuschreiben! +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "covington" +literal "true" + +\end_inset + +Das covington-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/macros/latex/contrib/covington/ +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "csquotes" +literal "true" + +\end_inset + +Das csquotes-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/ +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "drs" +literal "false" + +\end_inset + + Das drs-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +https://ctan.org/tex-archive/macros/latex/contrib/drs +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "enumitem" +literal "true" + +\end_inset + +Das enumitem-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/macros/latex/contrib/enumitem/ +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "float" +literal "true" + +\end_inset + +Das float-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/macros/latex/contrib/float/ +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "forest" +literal "true" + +\end_inset + +Das forest-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/graphics/pgf/contrib/forest +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "linguistlyx" +literal "true" + +\end_inset + +Maria Gouskova, Stacia Hartleben und Jürgen Spitzmüller: Using \SpecialChar LyX + for Linguistic + Papers. + +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +https://wiki.lyx.org/LyX/LinguistLyX +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "pict2e" +literal "false" + +\end_inset + +Das pict2e-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +https://ctan.org/tex-archive/macros/latex/contrib/pict2e +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "preview" +literal "true" + +\end_inset + +Das preview-latex-Paket: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/macros/latex/contrib/preview/ +\end_layout + +\end_inset + +. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +key "tipa" +literal "true" + +\end_inset + +Das tipa-Paket und die zugehörigen Schriften: +\begin_inset Flex URL +status collapsed + +\begin_layout Plain Layout + +http://www.ctan.org/tex-archive/fonts/tipa/ +\end_layout + +\end_inset + +. +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/Linguistics.xml b/autotests/export/docbook/Linguistics.xml new file mode 100644 index 0000000000..688ee2dd99 --- /dev/null +++ b/autotests/export/docbook/Linguistics.xml @@ -0,0 +1,339 @@ + + +
+ +Linguistische Arbeiten mit LyX + +Jürgen Spitzmüller + +21.04.2015 + +In diesem Text werden einige Funktionen von LyX vorgestellt, die spezifisch auf die Bedürfnisse von Linguistinnen und Linguisten ausgerichtet sind. Es wird gezeigt, wie nummerierte Beispiele, Interlinear-Glossierung, OT-Tableaux, semantische Auszeichnung, Strukturbäume, Diskursrepräsentationsstrukturen und phonetische Notation (IPA) erzeugt werden können. + + + +
+Voraussetzungen und Ziele +Die meisten der hier beschriebenen Funktionen werden vom „Linguistik“-Modul bereitgestellt, das seit Version 1.6.0 mit LyX mitgeliefert wird. „Module“ – das Konzept wurde ebenfalls mit LyX 1.6.0 eingeführt – sind Ergänzungsdateien, welche die von der Dokumentklasse bereitgestellten Möglichkeiten zumeist für sehr spezifische Aufgaben erweitern und die für jedes Dokument (egal welcher Klasse) einfach ausgewählt werden können. Um das Linguistik-Modul zu verwenden, gehen sie zu Dokument⇒Einstellungen⇒Module, wählen Sie „Linguistik“ aus der Liste der verfügbaren Module und drücken auf den Knopf Hinzufügen (so wie es für dieses Dokument bereits getan wurde). +Grundsätzlich sollte das Modul in jeder von LyX unterstützten Dokumentklasse funktionieren (falls nicht, informieren Sie bitte den Autor dieses Textes). Allerdings müssen Sie, um alle Features nutzen zu können, die folgenden LaTeX-Pakete installiert haben: + + +covington.sty : Dieses Paket wird benötigt, um nummerierte Beispiele, Glossen und semantische Auszeichnungen zu erzeugen. Beachten Sie, dass mindestens Version 2.3 des Pakets erforderlich ist, um alle Funktionen zu nutzen. + + +Auf Ihrem System installiert: nein. + + + + +csquotes.sty : Voraussetzung für den Textstil Bedeutung und für Glossen. Das Paket erlaubt es, kontextsensible Anführungszeichen zu generieren (bspw. je nach aktuell verwendeter Sprache). + + +Auf Ihrem System installiert: nein. + + + + +drs.sty : Voraussetzung für Diskursrepräsentationsstrukturen. Beachten Sie, dass mindestens Version 2.3 des Pakets covington erforderlich ist, um dies mit anderen Funktionen gemeinsam zu nutzen. + + +Auf Ihrem System installiert: nein. + + + + +float.sty : Dieses Paket brauchen wir für die OT-Tableaux und das Tableaux-Verzeichnis. Es sollte Bestandteil jeder LaTeX-Distribution sein. + + +Auf Ihrem System installiert: nein. + + + + +forest.sty : Dieses Paket wird zur Erzeugung von Strukturbäumen verwendet. + + +Auf Ihrem System installiert: nein. + + + + +pict2e.sty : Voraussetzung für Duplex-Bedingungs-DRS. + + +Auf Ihrem System installiert: nein. + + + + +
+
+Nummerierte Beispiele +Nummerierte Beispiele werden über die Absatzstil-Auswahlliste in der Werkzeugleiste eingefügt. Es gibt drei Varianten: + +Das ist ein mehrzeiliges Beispiel [Stil Nummeriertes Beispiel (mehrere Zeilen)] +Wie der Name sagt, kann es mehrere Absätze enthalten + + +Das ist ein einzeiliges Beispiel [Stil Nummeriertes Beispiel (konsekutiv)]Jeder Absatz wird in diesem Stil neu nummeriert + + +Dies ist ein Unterbeispiel [Stil Unterbeispiel]Und hier noch eines + +Querverweise auf Beispiele erzeugen Sie wie gewohnt: Sie fügen im Beispiel eine Marke ein, und an der Stelle, an der der Querverweis erscheinen soll, einen Verweis mittels Einfügen⇒Querverweis… +Als kleine Demonstration verweisen wir hier auf die Beispiele und . +Wenn Sie die Nummerierung für einzelne Beispiele ändern möchten, verwenden Sie Einfügen⇒Benutzerdef. Nummerierung. Für globale Anpassungen bietet covington selbst Möglichkeiten. Bitte konsultieren Sie das Handbuch des Pakets für Einzelheiten. +Ab Version 2.3 bietet covingtons subexamples-Umgebung ein optionales Argument (mit dem man Text zwischen der Hauptnummer und dem ersten Unterbeispiel einfügen kann). Dieses können Sie über Einfügen⇒Optionen für Unterbeispiele eingeben. Bitte konsultieren Sie auch hier das Handbuch des Pakets für Einzelheiten. +
+
+Interlinear-Glossierung +Das Linguistikmodul stellt zwei Arten von Glossen zur Verfügung. Beide sind über Einfügen⇒Spezifische Einfügung zugänglich. Die Interlinear-Glosse (2 Zeilen) besteht aus zwei Zeilen für das Glossenpaar (bestehend aus der Darstellung in der zu beschreibenden Sprache und einer interlinearen Wort-zu-Wort-Übersetzung) sowie einer weiteren Zeile für die freie Übersetzung, die Interlinear-Glosse (3 Zeilen) bietet eine zusätzliche Zeile für Interlinear-Glossierung (diese dritte Zeile wird zumeist für morphologische oder phonologische Angaben verwendet). Die freie Übersetzung kann länger sein als eine Zeile, sie wird dann einfach automatisch und korrekt umbrochen. Die Version in der zu beschreibenden Sprache (erste Zeile der Glosse) wird direkt in die Glosse-Einfügung geschrieben, alle anderen Teile der Glosse in spezifische Unter-Einfügungen (Interlinear-Glosse, bzw. mit dreizeiligen Glossen: Interlinear-Glosse (Zeile 1) und Interlinear-Glosse (Zeile 2), sowie Glossen-Übersetzung). LyX fügt diese Unter-Einfügungen automatisch ein, wenn Sie eine neue Glosse einfügen. Sie können aber auch manuell eingefügt werden, und zwar über Einfügen⇒Glossen-Übersetzung und Einfügen⇒Interlinear-Glosse. Ungeachtet wo Sie diese Untereinfügungen innerhalb der Glosse einfügen, wird alles in der richtigen Reihenfolge ausgegeben. Schließlich können Sie über Einfügen⇒Glossen-Optionen auch Glossen-Optionen eingeben. Diese Optionen erlauben es Ihnen, die Darstellung der einzelnen Zeilen zu verändern, eine Nummerierung oder vorangestellten Text hinzuzufügen. Bitte konsultieren Sie das Handbuch des Pakets covington für Einzelheiten. +Bitte beachten Sie, dass die Unterstützung für Glossen für LyX 2.4 komplett überarbeitet wurde. Nun werden die neuen und verbesserten Glossen-Makros verwendet, die covington seit der Version 2.0 anbietet. Wegen der erheblichen Veränderungen können alte Glossen leider nicht in die neuen konvertiert werden. Statt dessen werden sie in ihrer ursprünglichen Form importiert (und als Lokales Format im Dokument gespeichert). Umgekehrt werden neue Glossen in TeX-Code exportier, wenn Sie in eine ältere LyX-Version exportieren. + +Hier ist ein einfaches Beispiel für eine zweizeilige Glosse: +C'est un exemple simple +Verwenden Sie Bearbeiten⇒Textstil⇒Glossierte Wortgruppen, um Mehrwortelemente zusammenzuhalten (alternativ können Sie auch im TeX-Modus +diese Wörter geschweift einklammern +). Beachten Sie, dass Sie im LyX-Fenster mehrere Leerzeichen nacheinander einfügen können, um die Glossen dort schöner auszurichten. Die Ausgabe wird davon nicht berührt. +Hier ist eine dreizeilige Glosse. Sie wird analog erzeugt: +Hoc est aliud exemplum +Beachten Sie, wie wir hier mit Hilfe der Glossen-Optionen die zweite Zeile in Kapitälchen ausgeben lassen. +Wenn Sie nummerierte Glossen benötigen, fügen Sie die Glosse entweder einfach in einen Absatz mit dem Format Nummeriertes Beispiel ein, so wie hier: + +Mein Luftkissenfahrzeug ist voller Aale + +oder verwenden Sie die Glossen-Option ex: +Mein Luftkissenfahrzeug ist voller Aale +Tipps & Tricks +Seitenumbrüche innerhalb von Glossen vermeiden +In der Standardeinstellung können innerhalb von Glossen Seiten umbrochen werden, was natürlich nicht erwünscht ist. Um dies zu umgehen, können Sie in Dokument⇒Einstellungen…⇒Dokumentklasse⇒Klassenoptionen⇒Benutzerdefiniert die Option noglossbreaks eingeben; dies wird die meisten Umbrüche verhindern. Wenn trotzdem welche vorkommen, können Sie Glossen in Boxen packen (über Einfügen⇒Box⇒Rahmenlos). +Fußnoten in Glossen +Sie können zwar eine Fußnote in eine Glosse einfügen, dies führt aber zu einem LaTeX-Fehler. Wenn Sie Fußnoten benötigen, schreiben Sie an der Stelle, an der das Fußnotenzeichen erscheinen soll, im TeX-Modus \footnotemark in die Glosse. Direkt nach (und außerhalb) der Glosse schreiben Sie, ebenfalls im TeX-Modus, \footnotetext{Die Fußnote ...}. Sollten Sie mehrere Fußnoten brauchen, geben Sie einfach mehrere dieser Befehlspaare ein. +Glossen (und Beispiele) in Beamer-Präsentationen +Wenn Sie das Linguistik-Modul in einer Beamer-Präsentation verwenden wollen, beachten Sie bitte folgendes: + + +Für Glossen müssen Sie in Beamer immer einen „fragilen“ Rahmen verwenden. + + +Ältere Versionen des Pakets covington und die Beamer-Klasse arbeiten von Haus aus nicht gut zusammen, da beide die Befehle \example und \examples zu definieren versuchen, was in diesen älteren Versionen eine LaTeX-Fehlermeldung erzeugt, sobald sie Glossen oder Beispiele einfügen. Sie können das Problem beheben, indem Sie in Dokument⇒Einstellungen⇒Lokales Format folgenden Code kopieren: +
+Provides covington 1 +AddToPreamble + \let\example\relax + \let\endexample\relax + \let\examples\relax + \let\endexamples\relax + \usepackage{covington} +EndPreamble + +
+Drücken Sie „Validieren“ und dann „OK“. Dies hat den Effekt, dass die Beispiel-Umgebungen von Beamer deaktiviert werden (und also nicht mehr verwendet werden können), dafür können Sie dann aber die des Linguistik-Moduls verwenden. +Ab covington 1.1 besteht dieses Problem nicht mehr. +
+
+
+
+Tableaux für Optimalitätstheorie +Die OT-Tableaux selbst können natürlich einfach als normale Tabellen eingegeben werden (Spezifika wie gestrichelte Tabellenlinien und schattierte Tabellenzellen, die man hierfür manchmal braucht, sind in Hilfe⇒Eingebettete Objekte beschrieben). +Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es ausgewählt ist, finden Sie unter Einfügen⇒Gleitobjekte zusätzlich ein Tableau-Gleitobjekt (siehe Tableau  für ein Beispiel). +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Beispiel-Tableau
/atikap/OnsetNoCodaDepMax
+\mbox{☞} + + + + ☞ + + + + +\mbox{\textipa{P}} + + + + P + + + +a.ti.ka**
a.ti.ka*!*
+\mbox{\textipa{P}} + + + + P + + + +a.ti.kap*!*
a.ti.kap*!*!
+ +Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code in Dokument⇒Einstellungen⇒Präambel eingeben: +
+\floatstyle{plaintop} +\restylefloat{tableau} + +
+Wenn Sie eine KOMA-Klasse verwenden, nehmen Sie statt dessen das Folgende (welches im Kontext der KOMA-Klassen bessere Abstände erzeugt): +
+\floatstyle{komaabove} +\restylefloat{tableau} + +
+Ein Verzeichnis der Tableaux geben Sie, wie bei normalen Tabellen auch, über Einfügen⇒Liste⁄Inhaltsverzeichnis ein. Dies sieht dann so aus: +
+
+Semantische Auszeichnung (Textstile) +Das Linguistikmodul stellt einige Textstile zur Verfügung, die in linguistischen Arbeiten allgemein gebräuchlich sind: + + +Konzept (in Kapitälchen): Konzept + + +Ausdruck (hervorgehoben): Ausdruck + + +Bedeutung (in einfachen Anführungszeichen): Bedeutung + + +Diese Textstile finden Sie unter Bearbeiten⇒Textstil. Der Vorteil solcher Stile gegenüber direkter Hervorhebung und Auszeichnung ist vor allem der, dass sie alle (und nur die) damit markierten Textteile leicht global verändern können. Wenn Sie (oder Ihr Verlag) also etwa Ausdrücke doch fett gesetzt haben wollen, geben Sie einfach den folgenden Code in Dokument⇒Einstellungen⇒Präambel ein: +
+\renewcommand\lexp[1]{\textbf{#1}} + +
+Auf ähnliche Weise kann auch das Aussehen von Konzept (\lcon) und Bedeutung (\lmean) verändert werden. Bitte konsultieren Sie das Handbuch des Pakets covington für Einzelheiten. +
+
+Linguistische Strukturbäume +Mittlerweile gibt es mehrere LaTeX-Pakete, die bei der Erstellung von Strukturbäumen helfen. LyX unterstützt das Paket forest, welches hohe Flexibilität und Mächtigkeit mit einer intuitiven Syntax vereint. Das Linguistik-Modul enthält eine Strukturbaum-Einfügung, die unter Einfügen⇒Spezifische Einfügung zu finden ist. Innerhalb dieser Einfügung können Sie die Klammernotation verwenden, die das Paket forest (wie auch andere Pakete, z. B. qtree) anbietet. +Hier ist ein einfaches Beispiel: +[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]] ] ] +Wenn Sie die PDF-Ausgabe ansehen, sehen Sie, dass die Notation +
+[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[D[einen]][NP[Brief]]]]] +
+als Strukturbaum ausgegeben wird. Um das Ergebnis bereits im LyX +Eingabefenster zu sehen, können Sie die Strukturbaum-Einfügung einfach in eine Vorschau-Einfügung (Einfügen⇒Vorschau) einbetten. Wenn „Sofortige Vorschau“ richtig eingerichtet und aktiviert ist, sollten Sie den Baum sofort sehen (zur Bearbeitung klicken Sie einfach auf das Bild): +[VP [DP[Maria]] [V' [V[schickt]] [DP[Hans]] [DP[D[eine]][NP[Antwort]]] ] ] +Dächer („roofs“) können mittels der Option „roof“ +Bitte beachten Sie, dass die Option „roof“ erst ab Version 2.0 des Pakets forest verfügbar ist. Für frühere Versionen haben wir in den Vorspann dieses Dokuments Code eingefügt, die die Verwendung dennoch gestattet. Wenn Ihre Version des Pakets forest kleiner ist als 2.0 und Sie „roof“ verwenden wollen, müssen Sie diesen Code in den Vorspann Ihres Dokuments kopieren. Statt dessen können Sie auch die alte Option „triangle“ (statt „roof“) verwenden. + erzeugt werden (beachten Sie, dass Kommata eine spezielle Bedeutung haben; sie markieren Optionen): +[VP [DP[Hans]] [V' [V[schickt]] [DP[Maria]] [DP[einen weiteren Brief, roof]] ] ] +Um die Knoten des Baums besser auszurichten, verwenden Sie die Option „tier“. Alle Knoten, denen dieselbe „tier“ (Ebene) zugewiesen wurde, werden in einer vertikalen Linie ausgerichtet. Hier ist ein Beispiel: +[VP [DP[Hans, tier=word]] [V' [V[schickt, tier=word]] [DP[Maria, tier=word]] [DP[D[einen, tier=word]][NP[Brief, tier=word]]] ] ] +Das Paket bietet viel mehr Möglichkeiten, wie bspw. Bewegungspfeile und Dekorationen. Sie können hier nicht eingehend besprochen werden. Bitte konsultieren Sie die ausführliche Dokumentation des Pakets . +
+
+Diskursrepräsentationsstrukturen +Das Linguistik-Modul stellt auch Einfügungen zur Erzeugung von Diskursrepräsentationsstrukturen (DRSen) in der Box-Notation von Hans Kamps Diskursrepräsentationstheorie zur Verfügung. Diese Einfügungen finden Sie unter Einfügen⇒Spezifische Einfügung. +Eine einfache DRS erzeugen Sie mit der Einfügung Diskursrepräsentationsstruktur. Eine DRS besteht aus (Diskurs-)Bedingungen, die direkt in die Einfügung geschrieben werden, uns den (u. U. leeren) (Diskurs-)Referenten (bzw., im DRT-Jargon, dem Universum), welche in die (automatisch eingefügte) Untereinfügung Referenten geschrieben werden. +Sollte diese nicht eingefügt werden, finden Sie sie unter Einfügen⇒DRS-Referenten. + Zeilenwechsel müssen mittels Ctrl+Return eingefügt werden. Hier ist ein einfaches Beispiel: + +Esel(x)grün(x) +DRSen sind durch spezifische Layout-Anpassungen so gestaltet, dass Sie gut auf der Seite platziert werden. Die Variante Diskursrepräsentationsstruktur (einfach) unterdrückt diese Anpassungen. +Zusätzlich zu diesen einfachen DRSen werden die folgenden konditionalen DRSen unterstützt (sie werden in der Regel in einfache eingebettet): + + +Die Implikative DRS repräsentiert eine konditionale (implikative) Satzkonstruktion der Form wenn S1, dann S2: +Joseph(x)Esel(y)besitzen(x,y) + + +Die Konditionale DRS ist eine allgemeinere Variante, bei der Sie selbst eine beliebige Bedingung (statt der implikativen) spezifizieren können. In die Untereinfügung Bedingung können Sie ein beliebiges Symbol eingeben: +Joseph(x)Esel(y)besitzen(x,y) + + +Die Duplex-Bedingungs-DRS können Sie für sog. Duplex-Bedingungen verwenden: +x +\in + + + + + + X + + +Die Negierte DRS fügt eine DRS ein, der ein Negationszeichen vorangestellt ist: +Esel(x)grün(x) + + +DRS mit Satz oberhalb schließlich tut, was es verspricht: Es setzt einen Satz über die Box-Repräsentation: + +Esel(x)grün(x) + +Das Paket drs bietet einige Möglichkeiten, um das Erscheinungsbild der DRS-Modelle anzupassen. Bitte konsultieren Sie das Handbuch des Pakets für Einzelheiten. +
+
+Phonetische Notation (IPA) +Um phonetische Zeichen einzugeben, brauchen Sie das Linguistikmodul nicht. IPA-Unterstützung ist mittlerweile eine Grundfunktion von LyX. Da IPA aber von Linguistinnen und Linguisten sehr häufig gebraucht wird, wird die Verwendung der IPA-Funktion hier trotzdem (kurz) beschrieben. +Um LyX' IPA-Funktion mit klassischem LaTeX oder PDFLaTeX zu benutzen, müssen Sie das Paket tipa installiert haben. Es wird von LyX automatisch geladen, wenn Sie dem unten beschriebenen Vorgehen folgen. Wenn Sie XeTeX oder LuaTeX verwenden (und „Nicht-TeX-Schriften verwenden“ in Dokument⇒Einstellungen⇒Schriften aktiviert haben), wird statt dessen das Paket xunicode geladen, da tipa in diesem Fall nicht funktioniert. Das Paket xunicode emuliert die Ausgabe von tipa, ist aber nicht perfekt, so dass die Ausgabe möglicherweise nicht wie erwartet ist. Außerdem müssen Sie in diesem Fall darauf achten, dass die Nicht-TeX-Schrift die IPA-Symbole auch enthält (empfehlenswert sind Schriften wie CMU Serif oder SIL Doulos). Sie können auch eine Schrift nur für IPA definieren, indem sie das Folgende in Dokument⇒Einstellungen⇒LaTeX-Vorspann eingeben: +\AtBeginDocument{% +\newfontfamily{\ipafont}{CMU Serif}% oder eine ander Schriftart +\def\useTIPAfont{\ipafont} +} +Für eine direkte Vorschau der IPA-Symbole im Arbeitsfenster sollten Sie weiterhin (egal, welche der oben beschriebenen Ausgabeformate Sie verwenden) das preview-latex-Paket installiert haben. +Phonetische Zeichen werden in eine spezielle Umgebung eingegeben, die Sie über Einfügen⇒Sonderzeichen⇒Phonetische Symbole aktivieren. Es wird ein kleiner umrahmter Eingabebereich eingefügt, in den Sie einzelne Zeichen, Wörter und Wortfolgen sowie auch mehrere Absätze mit phonetischer Notation eingeben können. Wenn Sie in dem Eingabebereich sind, wird eine Symbolleiste aktiviert, die die wichtigsten IPA-Symbole (nach den IPA-Kategorien sortiert) bereitstellt. +Es fehlt ein Symbol: der (2005 in das IPA aufgenommene) labiodentale Flap. Dieses Zeichen unterstützt das Tipa-Paket noch nicht; daher kann es auch nicht von LyX unterstützt werden. + Jeder Symbolbereich dieser Symbolleiste kann durch Klicken auf die gestrichelte Linie abgetrennt werden. Dadurch kann phonetische Notation recht komfortabel eingegeben werden: [ˈɛtva zo:]. +Wenn Sie ein diakritisches Zeichen einfügen möchten, müssen Sie das Diakritikum nach dem Basiszeichen einfügen. Das heißt, für [d̥] geben Sie zuerst <d> ein und dann direkt danach das Diakritikum <Stimmlos> von der Symbolleiste. Wenn Sie nur ein Diakritikum eingeben möchten, können Sie das direkt nach einem Leerzeichen tun, so wie hier: ̼ (= <Leerzeichen>+<Lingolabial>). + Wenn preview-latex installiert ist und Sie außerdem in Werkzeuge⇒Einstellungen…⇒Grafik „Sofortige Vorschau“ aktiviert haben, zeigt LyX eine WYSIWYG-Vorschau der Notation an, sobald der Cursor den IPA-Bereich verlässt. Alternativ zur Symbolleiste können Sie die Zeichen auch direkt mithilfe der Kurznotation eingeben können, die im tipa-Handbuch erläutert wird: hier eine [kOst"pro:b@] (tipa-Kurznotation: [kOst"pro:b@]). Alternativ können Sie die meisten IPA-Zeichen auch über Einfügen⇒Sonderzeichen⇒Symbole… in das Eingabefeld eingeben oder sie aus einem anderen Dokument kopieren und dort einfügen. Die Ausgabe sollte immer identisch sein, egal welche Eingabemethode Sie wählen. +Bitte beachten Sie, dass Sie die meisten IPA-Zeichen über die zuletzt genannten Methoden auch außerhalb des IPA-Eingabebereichs einfügen können: [zoː viː hiːɐ̯]. In der Ausgabe werden diese Zeichen dann ebenfalls direkt in die korrekten tipa-Makros umgewandelt (lassen Sie es uns wissen, falls das nicht der Fall ist). Dieses Verfahren hat aber gravierende Nachteile gegenüber der IPA-Umgebung, denn die direkte Eingabe resultiert in der Regel in unerwünschter Schriftmischung (die lateinischen Buchstaben werden aus der Grundschrift, die speziellen IPA-Zeichen aber aus der IPA-Schrift genommen, und diese beiden Schriften passen nicht notwendigerweise zusammen). Innerhalb der IPA-Eingabeumgebung wird dagegen für alle Zeichen dieselbe Schrift verwendet. Deshalb sollten Sie, wenn Sie nicht nur Einzelzeichen eingeben, unbedingt den IPA-Eingabebereich verwenden. +
+
+Weitere Informationen +Mehr und ausführlichere Informationen über die Möglichkeiten des Einsatzes von LyX für linguistische Zwecke finden Sie auf der (englischsprachigen) LinguistLyX-Seite auf dem LyX-Wiki . Sie sind übrigens herzlich eingeladen, dort aktiv mitzuschreiben! +
+ +Das covington-Paket: http://www.ctan.org/tex-archive/macros/latex/contrib/covington/. +Das csquotes-Paket: http://www.ctan.org/tex-archive/macros/latex/contrib/csquotes/. + Das drs-Paket: https://ctan.org/tex-archive/macros/latex/contrib/drs. +Das enumitem-Paket: http://www.ctan.org/tex-archive/macros/latex/contrib/enumitem/. +Das float-Paket: http://www.ctan.org/tex-archive/macros/latex/contrib/float/. +Das forest-Paket: http://www.ctan.org/tex-archive/graphics/pgf/contrib/forest. +Maria Gouskova, Stacia Hartleben und Jürgen Spitzmüller: Using LyX for Linguistic Papers. https://wiki.lyx.org/LyX/LinguistLyX. +Das pict2e-Paket: https://ctan.org/tex-archive/macros/latex/contrib/pict2e +Das preview-latex-Paket: http://www.ctan.org/tex-archive/macros/latex/contrib/preview/. +Das tipa-Paket und die zugehörigen Schriften: http://www.ctan.org/tex-archive/fonts/tipa/. + + \ No newline at end of file diff --git a/lib/layouts/linguistics.module b/lib/layouts/linguistics.module index d272c2565c..bcfc370155 100644 --- a/lib/layouts/linguistics.module +++ b/lib/layouts/linguistics.module @@ -82,6 +82,10 @@ Style Numbered_Example_(multiline) EndFont Requires covington Category Linguistics + DocBookWrapperTag informalexample + DocBookWrapperAttr role='numbered' + DocBookWrapperMergeWithPrevious true + DocBookTag para End @@ -107,6 +111,10 @@ Style Numbered_Examples_(consecutive) LabelString "Custom Numbering|s" Tooltip "Customize the numeration" EndArgument + DocBookWrapperTag informalexample + DocBookWrapperAttr role='consecutive' + DocBookWrapperMergeWithPrevious true + DocBookTag para End diff --git a/src/Floating.cpp b/src/Floating.cpp index a610c73b29..fe3c72c28d 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -90,9 +90,10 @@ string const & Floating::docbookAttr() const string Floating::docbookTag(bool hasTitle) const { + // TODO: configure this in the layouts? if (floattype_ == "figure") { return hasTitle ? "figure" : "informalfigure"; - } else if (floattype_ == "table") { + } else if (floattype_ == "table" || floattype_ == "tableau") { return hasTitle ? "table" : "informaltable"; } else if (floattype_ == "algorithm") { // TODO: no good translation for now! Figures are the closest match, as they can contain text. @@ -119,7 +120,7 @@ string const & Floating::docbookCaption() const docbook_caption_ = ""; if (floattype_ == "figure") { docbook_caption_ = "title"; - } else if (floattype_ == "table") { + } else if (floattype_ == "table" || floattype_ == "tableau") { docbook_caption_ = "caption"; } else if (floattype_ == "algorithm") { // TODO: no good translation for now! Figures are the closest match, as they can contain text. diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 28d2e1e457..addf24a99d 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -293,7 +293,8 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar if (prevpar != nullptr) { Layout const & prevlay = prevpar->layout(); if (prevlay.docbookwrappertag() != "NONE") { - if (prevlay.docbookwrappertag() == lay.docbookwrappertag()) + if (prevlay.docbookwrappertag() == lay.docbookwrappertag() && + prevlay.docbookwrapperattr() == lay.docbookwrapperattr()) openWrapper = !lay.docbookwrappermergewithprevious(); else openWrapper = true; @@ -329,7 +330,8 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa if (nextpar != nullptr) { Layout const & nextlay = nextpar->layout(); if (nextlay.docbookwrappertag() != "NONE") { - if (nextlay.docbookwrappertag() == lay.docbookwrappertag()) + if (nextlay.docbookwrappertag() == lay.docbookwrappertag() && + nextlay.docbookwrapperattr() == lay.docbookwrapperattr()) closeWrapper = !nextlay.docbookwrappermergewithprevious(); else closeWrapper = true; From 40f4da3c9f2ea863d3fe979000bfa095a75e88de Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 3 Sep 2020 00:23:31 +0200 Subject: [PATCH 62/88] DocBook: floats can no more override DocBookTag. This lead to a quite subtle bug. The major problem is that float tags depend on whether the LyX float has a title (formal) or nor (informal). This information cannot be encoded in the layout format as easily as a simple DocBookTag. --- src/Floating.cpp | 2 +- src/Floating.h | 2 +- src/TextClass.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Floating.cpp b/src/Floating.cpp index fe3c72c28d..7ee042c1e3 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -30,7 +30,7 @@ Floating::Floating(string const & type, string const & placement, string const & listName, std::string const & listCmd, string const & refPrefix, std::string const & allowedplacement, string const & htmlTag, string const & htmlAttrib, - docstring const & htmlStyle, string const & docbookTag, + docstring const & htmlStyle, string const & docbookAttr, string const & docbookTagType, string const & required, bool usesfloat, bool ispredefined, bool allowswide, bool allowssideways) diff --git a/src/Floating.h b/src/Floating.h index 977958bc15..46816afc8d 100644 --- a/src/Floating.h +++ b/src/Floating.h @@ -37,7 +37,7 @@ public: std::string const & listName, std::string const & listCmd, std::string const & refPrefix, std::string const & allowedplacement, std::string const & htmlType, std::string const & htmlClass, - docstring const & htmlStyle, std::string const & docbookTag, + docstring const & htmlStyle, std::string const & docbookAttr, std::string const & docbookTagType, std::string const & required, bool usesfloat, bool isprefined, bool allowswide, bool allowssideways); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 900d6b2634..2c467b6d4c 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -1574,7 +1574,7 @@ bool TextClass::readFloat(Lexer & lexrc) } Floating fl(type, placement, ext, within, style, name, listname, listcommand, refprefix, allowed_placement, - htmltag, htmlattr, htmlstyle, docbooktag, docbookattr, + htmltag, htmlattr, htmlstyle, docbookattr, docbooktagtype, required, usesfloat, ispredefined, allowswide, allowssideways); floatlist_.newFloat(fl); From 8ed8d36595617e20d7994346ad54aa0e50b36ec3 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 3 Sep 2020 00:37:52 +0200 Subject: [PATCH 63/88] Fix two warnings in BufferView. --- src/BufferView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 75d8a4e434..e75bc5e0b9 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -947,7 +947,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter) TextMetrics & tm = d->text_metrics_[bot.text()]; pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1); - int bot_pit = bot.pit(); + pos_type bot_pit = bot.pit(); if (bot_pit > max_pit) { // FIXME: Why does this happen? LYXERR0("bottom pit is greater that max pit: " From 2cd7a94f8b31f1b59d002c4861585c32059c4269 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Thu, 3 Sep 2020 00:48:55 +0200 Subject: [PATCH 64/88] DocBook: introduce Floating::docbookFloatType. This ensures that all comparisons for DocBook are made on the same normalised version of the float type. This cased a strange bug where was output within for Linguistics Tableaux. --- autotests/export/docbook/Linguistics.xml | 2 -- src/Floating.cpp | 27 ++++++++++++++++++++---- src/Floating.h | 2 ++ src/insets/InsetFloat.cpp | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/autotests/export/docbook/Linguistics.xml b/autotests/export/docbook/Linguistics.xml index 688ee2dd99..e7d7875826 100644 --- a/autotests/export/docbook/Linguistics.xml +++ b/autotests/export/docbook/Linguistics.xml @@ -140,7 +140,6 @@ EndPreamble Wenn Sie allerdings Ihre Tableaux durch das Dokument hindurch nummerieren und ein eigenes Tableaux-Verzeichnis einrichten möchten, reichen die Bordmittel von LyX nicht aus. Auch hier hilft das Linguistikmodul. Wenn es ausgewählt ist, finden Sie unter Einfügen⇒Gleitobjekte zusätzlich ein Tableau-Gleitobjekt (siehe Tableau  für ein Beispiel).
- @@ -205,7 +204,6 @@ EndPreamble -
Beispiel-Tableau
/atikap/
Bitte beachten Sie, dass die Legende in der Standardeinstellung immer unter dem Tableau ausgegeben wird, egal, wohin Sie sie im LyX-Arbeitsfenster setzen. Um die Legende über das Tableau zu setzen, müssen Sie den folgenden Code in Dokument⇒Einstellungen⇒Präambel eingeben: diff --git a/src/Floating.cpp b/src/Floating.cpp index 7ee042c1e3..6ae52b4d22 100644 --- a/src/Floating.cpp +++ b/src/Floating.cpp @@ -44,6 +44,25 @@ Floating::Floating(string const & type, string const & placement, {} +std::string Floating::docbookFloatType() const +{ + // TODO: configure this in the layouts? + if (floattype_ == "figure") { + return "figure"; + } else if (floattype_ == "table" || floattype_ == "tableau") { + return "table"; + } else if (floattype_ == "algorithm") { + // TODO: no good translation for now! Figures are the closest match, as they can contain text. + // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. + return "algorithm"; + } else { + // If nothing matches, return something that will not be valid. + LYXERR0("Unrecognised float type: " + floattype_); + return "unknown"; + } +} + + string const & Floating::htmlAttrib() const { if (html_attrib_.empty()) @@ -91,17 +110,17 @@ string const & Floating::docbookAttr() const string Floating::docbookTag(bool hasTitle) const { // TODO: configure this in the layouts? - if (floattype_ == "figure") { + if (docbookFloatType() == "figure") { return hasTitle ? "figure" : "informalfigure"; - } else if (floattype_ == "table" || floattype_ == "tableau") { + } else if (docbookFloatType() == "table") { return hasTitle ? "table" : "informaltable"; - } else if (floattype_ == "algorithm") { + } else if (docbookFloatType() == "algorithm") { // TODO: no good translation for now! Figures are the closest match, as they can contain text. // Solvable as soon as https://github.com/docbook/docbook/issues/157 has a definitive answer. return "figure"; } else { // If nothing matches, return something that will not be valid. - LYXERR0("Unrecognised float type: " + floattype_); + LYXERR0("Unrecognised float type: " + floattype()); return "float"; } } diff --git a/src/Floating.h b/src/Floating.h index 46816afc8d..0a2eb50bc9 100644 --- a/src/Floating.h +++ b/src/Floating.h @@ -44,6 +44,8 @@ public: /// std::string const & floattype() const { return floattype_; } /// + std::string docbookFloatType() const; + /// std::string const & placement() const { return placement_; } /// std::string const & ext() const {return ext_; } diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 86bcf9d474..981ba40427 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -639,7 +639,7 @@ void docbookNoSubfigures(XMLStream & xs, OutputParams const & runparams, const I // captions, they cannot appear at the end of the float, albeit LyX is happy with that). OutputParams rpNoTitle = runparams; rpNoTitle.docbook_in_float = true; - if (ftype.floattype() == "table") + if (ftype.docbookFloatType() == "table") rpNoTitle.docbook_in_table = true; // Organisation: <contents without title/> </float>. From 1a76fb9658cd26db9c224c0560905e6150b10efb Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Thu, 3 Sep 2020 01:23:20 +0200 Subject: [PATCH 65/88] DocBook: avoid using isspace in StartTag::writeTag. This is the cause of crashes (on both Windows and Linux). --- src/output_docbook.cpp | 12 +----------- src/xml.cpp | 29 ++++++++++++++++++++++++----- src/xml.h | 6 ++++++ 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index addf24a99d..ce7e641a2d 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -429,16 +429,6 @@ void makeBibliography( } -bool isNotOnlySpace(docstring const & str) -{ - for (auto const & c: str) { - if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') - return true; - } - return false; -} - - void makeParagraph( Text const & text, Buffer const & buf, @@ -531,7 +521,7 @@ void makeParagraph( ++nextpar; auto pars = par->simpleDocBookOnePar(buf, runparams, text.outerFont(distance(begin, par)), 0, nextpar == end, special_case); for (docstring const & parXML : pars) { - if (isNotOnlySpace(parXML)) { + if (xml::isNotOnlySpace(parXML)) { if (open_par) openParTag(xs, &*par, prevpar); diff --git a/src/xml.cpp b/src/xml.cpp index dd9790f2e8..8e936f817e 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -108,12 +108,9 @@ docstring StartTag::writeTag() const { docstring output = '<' + tag_; if (!attr_.empty()) { - docstring attributes = xml::escapeString(attr_, XMLStream::ESCAPE_NONE); - attributes.erase(attributes.begin(), std::find_if(attributes.begin(), attributes.end(), - [](int c) {return !std::isspace(c);})); - if (!attributes.empty()) { + docstring attributes = xml::trimLeft(xml::escapeString(attr_, XMLStream::ESCAPE_NONE)); + if (!attributes.empty()) output += ' ' + attributes; - } } output += ">"; return output; @@ -601,6 +598,28 @@ docstring xml::uniqueID(docstring const & label) } +bool xml::isNotOnlySpace(docstring const & str) +{ + for (auto const & c: str) { + if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') + return true; + } + return false; +} + + +docstring xml::trimLeft(docstring const & str) +{ + size_t i = 0; + for (auto const & c: str) { + if (c != ' ' && c != '\t' && c != '\n' && c != '\v' && c != '\f' && c != '\r') + return str.substr(i, docstring::npos); + i++; + } + return str; +} + + docstring xml::cleanID(docstring const & orig) { // The standard xml:id only allows letters, digits, '-' and '.' in a name. diff --git a/src/xml.h b/src/xml.h index 52eeb22f97..d5b42332ca 100644 --- a/src/xml.h +++ b/src/xml.h @@ -160,6 +160,12 @@ docstring cleanID(docstring const &orig); /// returns a unique numeric ID docstring uniqueID(docstring const & label); +/// determines whether a string only contains space characters +bool isNotOnlySpace(docstring const & str); + +/// trims the string to the left, i.e. remove any space-like character at the beginning of the string +docstring trimLeft(docstring const & str); + struct FontTag; struct EndFontTag; From a632a9ae3cc6e8be411b84d8bc25b54b4ae2f140 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skostysh@lyx.org> Date: Wed, 2 Sep 2020 22:48:23 -0400 Subject: [PATCH 66/88] DocBook: remove useless functions. --- src/output_docbook.cpp | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ce7e641a2d..1e804ee2ff 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -347,30 +347,6 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa } -void openLabelTag(XMLStream & xs, Layout const & lay) // Mostly for definition lists. -{ - openTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabelattr(), lay.docbookitemlabeltagtype()); -} - - -void closeLabelTag(XMLStream & xs, Layout const & lay) -{ - closeTag(xs, lay.docbookitemlabeltag(), lay.docbookitemlabeltagtype()); -} - - -void openItemTag(XMLStream & xs, Layout const & lay) -{ - openTag(xs, lay.docbookitemtag(), lay.docbookitemattr(), lay.docbookitemtagtype()); -} - - -void closeItemTag(XMLStream & xs, Layout const & lay) -{ - closeTag(xs, lay.docbookitemtag(), lay.docbookitemtagtype()); -} - - ParagraphList::const_iterator makeAny(Text const &, Buffer const &, XMLStream &, @@ -656,17 +632,17 @@ ParagraphList::const_iterator makeListEnvironment(Text const &text, if (style.labeltype != LABEL_NO_LABEL && style.docbookitemlabeltag() != "NONE") { if (style.labeltype == LABEL_MANUAL) { // Only variablelist gets here (or similar items defined as an extension in the layout). - openLabelTag(xs, style); + openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(), style.docbookitemlabeltagtype()); sep = 1 + par->firstWordDocBook(xs, runparams); - closeLabelTag(xs, style); + closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype()); } else { // Usual cases: maybe there is something specified at the layout level. Highly unlikely, though. docstring const lbl = par->params().labelString(); if (!lbl.empty()) { - openLabelTag(xs, style); + openTag(xs, style.docbookitemlabeltag(), style.docbookitemlabelattr(), style.docbookitemlabeltagtype()); xs << lbl; - closeLabelTag(xs, style); + closeTag(xs, style.docbookitemlabeltag(), style.docbookitemlabeltagtype()); } } } From faec7838222e5314ade3d89a3fadce731b93d759 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Fri, 11 Sep 2020 00:39:41 +0200 Subject: [PATCH 67/88] XML: bad fix for a crash that only happened in XHTML. As an error is output, I suppose that this behaviour is OK. --- src/xml.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xml.cpp b/src/xml.cpp index 8e936f817e..dda39a4f3f 100644 --- a/src/xml.cpp +++ b/src/xml.cpp @@ -477,7 +477,8 @@ XMLStream &XMLStream::operator<<(xml::EndTag const &etag) + "' when other tags were pending. Last pending tag is `" + to_utf8(pending_tags_.back()->writeTag()) + "'. Tag discarded."); - pending_tags_.erase(dit); + if (!pending_tags_.empty()) + pending_tags_.erase(dit); return *this; } } From 5f0720e9475daa2ce865fc641a4e97d94b4b36a1 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Fri, 11 Sep 2020 00:44:49 +0200 Subject: [PATCH 68/88] XHTML: fix generation of many useless </section>. --- src/output_xhtml.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 7d9a69bd6a..f8cd53e478 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -611,20 +611,26 @@ void xhtmlParagraphs(Text const & text, // Think about adding <section> and/or </section>s. if (style.category() == from_utf8("Sectioning")) { + int level = style.toclevel; + // Need to close a previous section if it has the same level or a higher one (close <section> if opening a - // <h2> after a <h2>, <h3>, <h4>, <h5>, or <h6>). More examples: + // <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) - // The level (h1, h2, etc.) corresponds to style.toclevel. - while (! headerLevels.empty() && style.toclevel <= headerLevels.top()) { + while (!headerLevels.empty() && level <= headerLevels.top()) { + // Output the tag only if it corresponds to a legit section. + int stackLevel = headerLevels.top(); + if (stackLevel != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title. + xs << xml::EndTag("section"); + xs << xml::CR(); + } headerLevels.pop(); - xs << xml::EndTag("section"); - xs << xml::CR(); } - // Open the new one. - headerLevels.push(style.toclevel); - if (style.toclevel > 1) { // <h1> is the document title. + // Open the new section: first push it onto the stack, then output it in XHTML. + headerLevels.push(level); + // Some sectioning-like elements should not be output (such as FrontMatter). + if (level != Layout::NOT_IN_TOC && level > 1) { // <h1> is the document title. xs << xml::StartTag("section"); xs << xml::CR(); } @@ -669,9 +675,11 @@ void xhtmlParagraphs(Text const & text, // If need be, close <section>s, but only at the end of the document (otherwise, dealt with at the beginning // of the loop). - while (! headerLevels.empty() && headerLevels.top() > 1) { + while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) { + docstring tag = from_utf8("</section>"); headerLevels.pop(); - xs << xml::EndTag("section") << xml::CR(); + xs << XMLStream::ESCAPE_NONE << tag; + xs << xml::CR(); } } From 9a48c8d22b0dd2ae1d0a78af3c2c0f4e3a65c26d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Fri, 11 Sep 2020 01:28:59 +0200 Subject: [PATCH 69/88] DocBook: fix handling of new lines and fonts. Only the font variable was restored to the right state, not fs. --- .../export/docbook/fonts_EmbeddedObjects.lyx | 288 ++++++++++++++++++ .../export/docbook/fonts_EmbeddedObjects.xml | 12 + src/Paragraph.cpp | 5 +- 3 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 autotests/export/docbook/fonts_EmbeddedObjects.lyx create mode 100644 autotests/export/docbook/fonts_EmbeddedObjects.xml diff --git a/autotests/export/docbook/fonts_EmbeddedObjects.lyx b/autotests/export/docbook/fonts_EmbeddedObjects.lyx new file mode 100644 index 0000000000..9ea1ff1313 --- /dev/null +++ b/autotests/export/docbook/fonts_EmbeddedObjects.lyx @@ -0,0 +1,288 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass scrbook +\begin_preamble +% that links to image floats jumps +% to the beginning of the float and +% not to its caption +\usepackage[figure]{hypcap} + +% the pages of the TOC are numbered roman +% and a PDF-bookmark for the TOC is added +\let\myTOC\tableofcontents +\renewcommand\tableofcontents{% + \frontmatter + \pdfbookmark[1]{\contentsname}{} + \myTOC + \mainmatter } + +% provides caption formatting +\usepackage[labelfont={bf,sf}]{caption}[2004/07/16] + +% provides commands to set caption +% beside tables/images +\newcommand{\TabBesBeg}[1][1.0]{% + \let\MyTable\table + \let\MyEndtable\endtable + \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}} + +\newcommand{\TabBesEnd}{% + \let\table\MyTable + \let\endtable\MyEndtable} + +\newcommand{\FigBesBeg}[1][1.0]{% + \let\MyFigure\figure + \let\MyEndfigure\endfigure + \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}} + +\newcommand{\FigBesEnd}{% + \let\figure\MyFigure + \let\endfigure\MyEndfigure} + +% enables calculation of values, +\usepackage{calc} + +% increase the bottom float placement fraction +\renewcommand{\bottomfraction}{0.5} + +% avoids that floats are placed before their +% corresponding section starts +\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection} + +% speed up the longtable calculation +\setcounter{LTchunksize}{100} + +% used for colored tables +\@ifundefined{textcolor} + {\usepackage{color}}{} +\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5} +\definecolor{lightgrey}{gray}{0.8} + +% check for package colortbl +% used for colored table cells +\newboolean{colortbl} +\IfFileExists{colortbl.sty} + {\usepackage{colortbl} + \setboolean{colortbl}{true}} + {\setboolean{colortbl}{false}} + +% used to have extra space in table cells +\@ifundefined{extrarowheight} + {\usepackage{array}}{} +\setlength{\extrarowheight}{2pt} + +% used for customized tables +% --- +\newcolumntype{M}[1] + {>{\centering\hspace{0pt}}m{#1}} + +\newcolumntype{S}[2] + {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}} + +\newcolumntype{K}[1] + {>{\columncolor{#1}\hspace{0pt}}c} + +\newcolumntype{V}{!{\vrule width 1.5pt}} + +\newcolumntype{W}{!{\color{green}\vline}} +% --- + +% insert additional vertical space of +% 1.5 mm between footnotes +\let\myFoot\footnote +\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}} + +% number algorithm floats within chapters +\numberwithin{algorithm}{chapter} + +% ------------------------------------ +% used to check for needed LaTeX packages +\usepackage{ifthen} + +% check for package arydshln +% used for tables with dashed lines +\newboolean{arydshln} +\IfFileExists{arydshln.sty} + {\usepackage{arydshln} + \setboolean{arydshln}{true}} + {\setboolean{arydshln}{false}} + +% check for package marginnote +% used for margin notes +\newboolean{marginnote} +\IfFileExists{marginnote.sty} + {\usepackage{marginnote} + \let\marginpar\marginnote + \setboolean{marginnote}{true}} + {\setboolean{marginnote}{false}} + +% check for package sidecap +% used for captions on the side +\newboolean{sidecap} +\IfFileExists{sidecap.sty} + {\usepackage{sidecap} + \setboolean{sidecap}{true}} + {\setboolean{sidecap}{false}} + +% check for picinpar +% used for surrounded fixed objects +\newboolean{picinpar} +\IfFileExists{picinpar.sty} + {\usepackage{picinpar} + \setboolean{picinpar}{true}} + {\setboolean{picinpar}{false}} + +% check for lettrine +\newboolean{lettrine} +\IfFileExists{lettrine.sty} + {\usepackage{lettrine} + \setboolean{lettrine}{true}} + {\setboolean{lettrine}{false}} + +% check for diagbox +\newboolean{diagbox} +\IfFileExists{diagbox.sty} + {\usepackage{diagbox} + \setboolean{diagbox}{true}} + {\setboolean{diagbox}{false}} +% Added by lyx2lyx +\setlength{\parskip}{\medskipamount} +\setlength{\parindent}{0pt} +\end_preamble +\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table +\use_default_options false +\begin_modules +initials +graphicboxes +varwidth +\end_modules +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "lmodern" "default" +\font_sans "lmss" "default" +\font_typewriter "lmtt" "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 true +\graphics default +\default_output_format pdf2 +\output_sync 0 +\bibtex_command default +\index_command makeindex +\paperfontsize 12 +\spacing single +\use_hyperref true +\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual" +\pdf_author "LyX Team, Uwe Stöhr" +\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes" +\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen true +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref false +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\notefontcolor #0000ff +\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 2 +\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 +\SpecialChar LyX +'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual +\end_layout + +\begin_layout Chapter +Floats +\end_layout + +\begin_layout Standard +can be created using these commands in the document preamble: +\end_layout + +\begin_layout Standard + +\series bold + +\backslash +usepackage[tableposition=top]{caption} +\series default + +\begin_inset Newline newline +\end_inset + + +\series bold + +\backslash +captionsetup[figure]{labelfont={tt}, textfont=it, indention=1cm,% +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/fonts_EmbeddedObjects.xml b/autotests/export/docbook/fonts_EmbeddedObjects.xml new file mode 100644 index 0000000000..7ce65a1a2b --- /dev/null +++ b/autotests/export/docbook/fonts_EmbeddedObjects.xml @@ -0,0 +1,12 @@ +<?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 --> +<book 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"> +<title>LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual + +Floats +can be created using these commands in the document preamble: +\usepackage[tableposition=top]{caption} +\captionsetup[figure]{labelfont={tt}, textfont=it, indention=1cm,% + + \ No newline at end of file diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index a409d20d3e..8da67e3508 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -3350,6 +3350,7 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, vector tagsToClose; std::vector generatedParagraphs; + DocBookFontState old_fs = fs; odocstringstream os; auto * xs = new XMLStream(os); // XMLStream has no copy constructor: to create a new object, the only solution // is to hold a pointer to the XMLStream (xs = XMLStream(os) is not allowed once the first object is built). @@ -3369,8 +3370,10 @@ std::vector Paragraph::simpleDocBookOnePar(Buffer const & buf, os = odocstringstream(); delete xs; xs = new XMLStream(os); - if (!ignore_fonts) + if (!ignore_fonts) { font_old = outerfont.fontInfo(); + fs = old_fs; + } } // Determine which tags should be opened or closed regarding fonts. From f28c193569a8b88cbebb318c1f40c9e8d8dfe7b5 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 11 Sep 2020 01:50:26 +0200 Subject: [PATCH 70/88] DocBook: remove now useless function in configure.py. --- lib/configure.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index 9f3c0325ee..35b9e51754 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1265,26 +1265,6 @@ def checkConverterEntries(): ''') -def checkDocBook(): - ''' Check docbook ''' - path, DOCBOOK = checkProg('SGML-tools 2.x (DocBook), db2x scripts or xsltproc', ['sgmltools', 'db2dvi', 'xsltproc'], - rc_entry = [ - r'''\converter docbook dvi "sgmltools -b dvi $$i" "" -\converter docbook html "sgmltools -b html $$i" "" -\converter docbook ps "sgmltools -b ps $$i" ""''', - r'''\converter docbook dvi "db2dvi $$i" "" -\converter docbook html "db2html $$i" ""''', - r'''\converter docbook dvi "" "" -\converter docbook html "" ""''', - r'''\converter docbook dvi "" "" -\converter docbook html "" ""''']) - # - if DOCBOOK: - return ('yes', 'true', '\\def\\hasdocbook{yes}') - else: - return ('no', 'false', '') - - def checkOtherEntries(): ''' entries other than Format and Converter ''' checkProg('ChkTeX', ['chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'], From 41a15f7b6d7844842d3670e564403133e85f26fb Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 11 Sep 2020 03:05:04 +0200 Subject: [PATCH 71/88] DocBook: in configure.py, DeclareDocBookClass doesn't need to be checked anymore. --- lib/configure.py | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index 35b9e51754..7d996be549 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -1311,7 +1311,7 @@ def _checkForClassExtension(x): return x.strip() def processLayoutFile(file): - ''' process layout file and get a line of result + """ process layout file and get a line of result Declare lines look like this: @@ -1336,38 +1336,36 @@ def processLayoutFile(file): "article" "article" "article" "false" "article.cls" "Articles" "scrbook" "scrbook" "book (koma-script)" "false" "scrbook.cls" "Books" "svjog" "svjour" "article (Springer - svjour/jog)" "false" "svjour.cls,svjog.clo" "" - ''' + """ classname = file.split(os.sep)[-1].split('.')[0] - # return ('LaTeX', '[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article} - p = re.compile('\s*#\s*\\\\Declare(LaTeX|DocBook)Class\s*(\[([^,]*)(,.*)*\])*\s*{(.*)}\s*$') + # return ('[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article} + p = re.compile('\s*#\s*\\\\DeclareLaTeXClass\s*(\[([^,]*)(,.*)*])*\s*{(.*)}\s*$') q = re.compile('\s*#\s*\\\\DeclareCategory{(.*)}\s*$') classdeclaration = "" categorydeclaration = '""' for line in open(file, 'r', encoding='utf8').readlines(): res = p.match(line) qres = q.match(line) - if res != None: - (classtype, optAll, opt, opt1, desc) = res.groups() - avai = {'LaTeX': 'false', 'DocBook': 'true'}[classtype] - if opt == None: + if res is not None: + (optAll, opt, opt1, desc) = res.groups() + if opt is None: opt = classname - prereq_latex = _checkForClassExtension(classname) + prereq = _checkForClassExtension(classname) else: prereq_list = optAll[1:-1].split(',') prereq_list = list(map(_checkForClassExtension, prereq_list)) - prereq_latex = ','.join(prereq_list) - prereq = {'LaTeX': prereq_latex, 'DocBook': ''}[classtype] + prereq = ','.join(prereq_list) classdeclaration = ('"%s" "%s" "%s" "%s" "%s"' - % (classname, opt, desc, avai, prereq)) + % (classname, opt, desc, 'false', prereq)) if categorydeclaration != '""': return classdeclaration + " " + categorydeclaration - if qres != None: - categorydeclaration = '"%s"' % (qres.groups()[0]) - if classdeclaration: - return classdeclaration + " " + categorydeclaration + if qres is not None: + categorydeclaration = '"%s"' % (qres.groups()[0]) + if classdeclaration: + return classdeclaration + " " + categorydeclaration if classdeclaration: return classdeclaration + " " + categorydeclaration - logger.warning("Layout file " + file + " has no \DeclareXXClass line. ") + logger.warning("Layout file " + file + " has no \\DeclareLaTeXClass line. ") return "" @@ -1434,7 +1432,7 @@ def checkLatexConfig(check_config): # Construct the list of classes to test for. # build the list of available layout files and convert it to commands # for chkconfig.ltx - declare = re.compile('\\s*#\\s*\\\\Declare(LaTeX|DocBook)Class\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$') + declare = re.compile('\\s*#\\s*\\\\DeclareLaTeXClass\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$') category = re.compile('\\s*#\\s*\\\\DeclareCategory{(.*)}\\s*$') empty = re.compile('\\s*$') testclasses = list() @@ -1455,10 +1453,10 @@ def checkLatexConfig(check_config): nodeclaration = True # A class, but no category declaration. Just break. break - if declare.match(line) != None: + if declare.match(line) is not None: decline = "\\TestDocClass{%s}{%s}" % (classname, line[1:].strip()) testclasses.append(decline) - elif category.match(line) != None: + elif category.match(line) is not None: catline = ("\\DeclareCategory{%s}{%s}" % (classname, category.match(line).groups()[0])) testclasses.append(catline) From d0a5ba4859702c78fb70ae30fe1f39818c98b102 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 11 Sep 2020 03:14:41 +0200 Subject: [PATCH 72/88] DocBook: handle other cases of subfigures. --- src/insets/InsetFloat.cpp | 44 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 981ba40427..d68001366b 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -492,19 +492,22 @@ int InsetFloat::plaintext(odocstringstream & os, OutputParams const & runparams, } -std::vector findSubfiguresInParagraph(const Paragraph &par) +std::vector findSubfiguresInParagraph(const Paragraph &par) { // Don't make the hypothesis that all subfigures are in the same paragraph. // Similarly, there may be several subfigures in the same paragraph (most likely case, based on the documentation). // Any box is considered as a subfigure, even though the most likely case is \minipage. - std::vector subfigures; + // Boxes are not required to make subfigures. The common root between InsetBox and InsetFLoat is InsetCollapsible. + std::vector subfigures; for (pos_type pos = 0; pos < par.size(); ++pos) { const Inset *inset = par.getInset(pos); if (!inset) continue; if (const auto box = dynamic_cast(inset)) subfigures.push_back(box); + else if (const auto fl = dynamic_cast(inset)) + subfigures.push_back(fl); } return subfigures; } @@ -564,7 +567,7 @@ const InsetCaption* findCaptionInParagraph(const Paragraph &par) void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption, - const InsetLabel * label, std::vector & subfigures) + const InsetLabel * label, std::vector & subfigures) { // Ensure there is no label output, it is supposed to be handled as xml:id. OutputParams rpNoLabel = runparams; @@ -592,20 +595,29 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins // Deal with each subfigure individually. This should also deal with their caption and their label. // This should be a recursive call to InsetFloat. - for (const InsetBox *subfigure: subfigures) { + // An item in subfigure should either be an InsetBox containing an InsetFloat or directly an InsetFloat. + for (const InsetCollapsible *subfigure: subfigures) { // If there is no InsetFloat in the paragraphs, output a warning. bool foundInsetFloat = false; - for (const auto & it : subfigure->paragraphs()) { - for (pos_type posIn = 0; posIn < it.size(); ++posIn) { - const Inset *inset = it.getInset(posIn); - if (inset && dynamic_cast(inset)) { - foundInsetFloat = true; - break; - } - } - if (foundInsetFloat) - break; + // The collapsible may already be a float (InsetFloat). + if (subfigure && dynamic_cast(subfigure)) + foundInsetFloat = true; + + // Subfigures are in boxes. + if (!foundInsetFloat) { + for (const auto &it : subfigure->paragraphs()) { + for (pos_type posIn = 0; posIn < it.size(); ++posIn) { + const Inset *inset = it.getInset(posIn); + if (inset && dynamic_cast(inset)) { + foundInsetFloat = true; + break; + } + } + + if (foundInsetFloat) + break; + } } if (!foundInsetFloat) @@ -673,11 +685,11 @@ void InsetFloat::docbook(XMLStream & xs, OutputParams const & runparams) const // The caption and the label for each subfigure is handled by recursive calls. const InsetCaption* caption = nullptr; const InsetLabel* label = nullptr; - std::vector subfigures; + std::vector subfigures; auto end = paragraphs().end(); for (auto it = paragraphs().begin(); it != end; ++it) { - std::vector foundSubfigures = findSubfiguresInParagraph(*it); + std::vector foundSubfigures = findSubfiguresInParagraph(*it); if (!foundSubfigures.empty()) { subfigures.reserve(subfigures.size() + foundSubfigures.size()); subfigures.insert(subfigures.end(), foundSubfigures.begin(), foundSubfigures.end()); From 8758000641e9014cd40581d309ded0e1cea44acf Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 11 Sep 2020 23:38:11 +0200 Subject: [PATCH 73/88] DocBook: ensure xml:id is not output too many times. This is mostly important for subfigures, but debugging this issue showed that InsetCaption could be slightly simplified and InsetLabel should be made a tad more robust. --- src/insets/InsetCaption.cpp | 3 +-- src/insets/InsetFloat.cpp | 2 +- src/insets/InsetLabel.cpp | 7 +++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/insets/InsetCaption.cpp b/src/insets/InsetCaption.cpp index 029162563a..8297c6fcde 100644 --- a/src/insets/InsetCaption.cpp +++ b/src/insets/InsetCaption.cpp @@ -367,8 +367,7 @@ void InsetCaption::getCaptionAsDocBook(XMLStream & xs, return; // Ignore full_label_, as the DocBook processor will deal with the numbering. - InsetText::XHTMLOptions const opts = - InsetText::WriteLabel | InsetText::WriteInnerTag; + InsetText::XHTMLOptions opts = InsetText::WriteInnerTag; InsetText::docbook(xs, runparams, opts); } diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index d68001366b..eaa24cb5bd 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -583,7 +583,7 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins xs << xml::StartTag("formalgroup", attr); xs << xml::CR(); - xs << xml::StartTag("title", attr); + xs << xml::StartTag("title"); // Don't take attr here, the ID should only go in one place, not two. if (caption) { caption->getCaptionAsDocBook(xs, rpNoLabel); } else { diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 2e80e26a83..5ba034456f 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -356,8 +356,11 @@ int InsetLabel::plaintext(odocstringstream & os, void InsetLabel::docbook(XMLStream & xs, OutputParams const & runparams) const { // Output an anchor only if it has not been processed before. - if (runparams.docbook_anchors_to_ignore.find(getParam("name")) == runparams.docbook_anchors_to_ignore.end()) { - docstring attr = from_utf8("xml:id=\"") + xml::cleanID(getParam("name")) + from_utf8("\""); + docstring id = getParam("name"); + docstring cleaned_id = xml::cleanID(id); + if (runparams.docbook_anchors_to_ignore.find(id) == runparams.docbook_anchors_to_ignore.end() && + runparams.docbook_anchors_to_ignore.find(cleaned_id) == runparams.docbook_anchors_to_ignore.end()) { + docstring attr = from_utf8("xml:id=\"") + cleaned_id + from_utf8("\""); xs << xml::CompTag("anchor", to_utf8(attr)); } } From 1b818c448d3a4e7f6fd4ea2685d775761de95767 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 12 Sep 2020 00:39:23 +0200 Subject: [PATCH 74/88] DocBook: work for more subfigure cases. EmbeddedObjects hid quite a few gems :). --- .../docbook/subfigures_EmbeddedObjects.lyx | 444 ++++++++++++++++++ .../docbook/subfigures_EmbeddedObjects.xml | 32 ++ .../subfigures_boxes_EmbeddedObjects.lyx | 420 +++++++++++++++++ .../subfigures_boxes_EmbeddedObjects.xml | 32 ++ src/insets/InsetFloat.cpp | 157 ++++++- 5 files changed, 1071 insertions(+), 14 deletions(-) create mode 100644 autotests/export/docbook/subfigures_EmbeddedObjects.lyx create mode 100644 autotests/export/docbook/subfigures_EmbeddedObjects.xml create mode 100644 autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx create mode 100644 autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml diff --git a/autotests/export/docbook/subfigures_EmbeddedObjects.lyx b/autotests/export/docbook/subfigures_EmbeddedObjects.lyx new file mode 100644 index 0000000000..0154d2119d --- /dev/null +++ b/autotests/export/docbook/subfigures_EmbeddedObjects.lyx @@ -0,0 +1,444 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass scrbook +\begin_preamble +% that links to image floats jumps +% to the beginning of the float and +% not to its caption +\usepackage[figure]{hypcap} + +% the pages of the TOC are numbered roman +% and a PDF-bookmark for the TOC is added +\let\myTOC\tableofcontents +\renewcommand\tableofcontents{% + \frontmatter + \pdfbookmark[1]{\contentsname}{} + \myTOC + \mainmatter } + +% provides caption formatting +\usepackage[labelfont={bf,sf}]{caption}[2004/07/16] + +% provides commands to set caption +% beside tables/images +\newcommand{\TabBesBeg}[1][1.0]{% + \let\MyTable\table + \let\MyEndtable\endtable + \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}} + +\newcommand{\TabBesEnd}{% + \let\table\MyTable + \let\endtable\MyEndtable} + +\newcommand{\FigBesBeg}[1][1.0]{% + \let\MyFigure\figure + \let\MyEndfigure\endfigure + \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}} + +\newcommand{\FigBesEnd}{% + \let\figure\MyFigure + \let\endfigure\MyEndfigure} + +% enables calculation of values, +\usepackage{calc} + +% increase the bottom float placement fraction +\renewcommand{\bottomfraction}{0.5} + +% avoids that floats are placed before their +% corresponding section starts +\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection} + +% speed up the longtable calculation +\setcounter{LTchunksize}{100} + +% used for colored tables +\@ifundefined{textcolor} + {\usepackage{color}}{} +\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5} +\definecolor{lightgrey}{gray}{0.8} + +% check for package colortbl +% used for colored table cells +\newboolean{colortbl} +\IfFileExists{colortbl.sty} + {\usepackage{colortbl} + \setboolean{colortbl}{true}} + {\setboolean{colortbl}{false}} + +% used to have extra space in table cells +\@ifundefined{extrarowheight} + {\usepackage{array}}{} +\setlength{\extrarowheight}{2pt} + +% used for customized tables +% --- +\newcolumntype{M}[1] + {>{\centering\hspace{0pt}}m{#1}} + +\newcolumntype{S}[2] + {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}} + +\newcolumntype{K}[1] + {>{\columncolor{#1}\hspace{0pt}}c} + +\newcolumntype{V}{!{\vrule width 1.5pt}} + +\newcolumntype{W}{!{\color{green}\vline}} +% --- + +% insert additional vertical space of +% 1.5 mm between footnotes +\let\myFoot\footnote +\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}} + +% number algorithm floats within chapters +\numberwithin{algorithm}{chapter} + +% ------------------------------------ +% used to check for needed LaTeX packages +\usepackage{ifthen} + +% check for package arydshln +% used for tables with dashed lines +\newboolean{arydshln} +\IfFileExists{arydshln.sty} + {\usepackage{arydshln} + \setboolean{arydshln}{true}} + {\setboolean{arydshln}{false}} + +% check for package marginnote +% used for margin notes +\newboolean{marginnote} +\IfFileExists{marginnote.sty} + {\usepackage{marginnote} + \let\marginpar\marginnote + \setboolean{marginnote}{true}} + {\setboolean{marginnote}{false}} + +% check for package sidecap +% used for captions on the side +\newboolean{sidecap} +\IfFileExists{sidecap.sty} + {\usepackage{sidecap} + \setboolean{sidecap}{true}} + {\setboolean{sidecap}{false}} + +% check for picinpar +% used for surrounded fixed objects +\newboolean{picinpar} +\IfFileExists{picinpar.sty} + {\usepackage{picinpar} + \setboolean{picinpar}{true}} + {\setboolean{picinpar}{false}} + +% check for lettrine +\newboolean{lettrine} +\IfFileExists{lettrine.sty} + {\usepackage{lettrine} + \setboolean{lettrine}{true}} + {\setboolean{lettrine}{false}} + +% check for diagbox +\newboolean{diagbox} +\IfFileExists{diagbox.sty} + {\usepackage{diagbox} + \setboolean{diagbox}{true}} + {\setboolean{diagbox}{false}} +% Added by lyx2lyx +\setlength{\parskip}{\medskipamount} +\setlength{\parindent}{0pt} +\end_preamble +\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table +\use_default_options false +\begin_modules +initials +graphicboxes +varwidth +\end_modules +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "lmodern" "default" +\font_sans "lmss" "default" +\font_typewriter "lmtt" "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 true +\graphics default +\default_output_format pdf2 +\output_sync 0 +\bibtex_command default +\index_command makeindex +\paperfontsize 12 +\spacing single +\use_hyperref true +\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual" +\pdf_author "LyX Team, Uwe Stöhr" +\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes" +\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen true +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref false +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\notefontcolor #0000ff +\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 2 +\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 +\SpecialChar LyX +'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual +\end_layout + +\begin_layout Chapter +Figures +\end_layout + +\begin_layout Section +Figure Floats +\end_layout + +\begin_layout Standard +Normally only one image is inserted to a figure float, but sometimes you + might want to use two images with separate subcaptions. + This can be done by inserting image floats into existing image floats. + Note that only the main caption of the float is added to the List of Figures. + Figure +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:Two-distorted-images" + +\end_inset + + is an example of a figure float with two images set side by side. + You can also set the images one below the other. + Figure +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:Pink-object" + +\end_inset + + and +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:A-star" + +\end_inset + + are the subfigures. +\end_layout + +\begin_layout Standard +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset space \hfill{} +\end_inset + + +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:Pink-object" + +\end_inset + +Pink object. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Graphics + filename ../../../lib/doc/clipart/3D-structure-distort.pdf + width 45col% + scaleBeforeRotation + groupId distorted + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset space \hfill{} +\end_inset + + +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:A-star" + +\end_inset + +A star. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Graphics + filename ../../../lib/doc/clipart/Star-structure.pdf + width 45col% + scaleBeforeRotation + groupId distorted + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset space \hfill{} +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:Two-distorted-images" + +\end_inset + +Two distorted images. + Both images are in the image settings group named +\begin_inset Quotes eld +\end_inset + +distorted +\begin_inset Quotes erd +\end_inset + +. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/subfigures_EmbeddedObjects.xml b/autotests/export/docbook/subfigures_EmbeddedObjects.xml new file mode 100644 index 0000000000..08fda0446d --- /dev/null +++ b/autotests/export/docbook/subfigures_EmbeddedObjects.xml @@ -0,0 +1,32 @@ + + + +LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual + +Figures +
+Figure Floats +Normally only one image is inserted to a figure float, but sometimes you might want to use two images with separate subcaptions. This can be done by inserting image floats into existing image floats. Note that only the main caption of the float is added to the List of Figures. Figure  is an example of a figure float with two images set side by side. You can also set the images one below the other. Figure  and are the subfigures. + +Two distorted images. Both images are in the image settings group named “distorted”. +
+Pink object. + + + + + +
+
+A star. + + + + + +
+
+
+
+
\ No newline at end of file diff --git a/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx new file mode 100644 index 0000000000..da41aa331d --- /dev/null +++ b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.lyx @@ -0,0 +1,420 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass scrbook +\begin_preamble +% that links to image floats jumps +% to the beginning of the float and +% not to its caption +\usepackage[figure]{hypcap} + +% the pages of the TOC are numbered roman +% and a PDF-bookmark for the TOC is added +\let\myTOC\tableofcontents +\renewcommand\tableofcontents{% + \frontmatter + \pdfbookmark[1]{\contentsname}{} + \myTOC + \mainmatter } + +% provides caption formatting +\usepackage[labelfont={bf,sf}]{caption}[2004/07/16] + +% provides commands to set caption +% beside tables/images +\newcommand{\TabBesBeg}[1][1.0]{% + \let\MyTable\table + \let\MyEndtable\endtable + \renewenvironment{table}[1]{\begin{SCtable}[#1]##1}{\end{SCtable}}} + +\newcommand{\TabBesEnd}{% + \let\table\MyTable + \let\endtable\MyEndtable} + +\newcommand{\FigBesBeg}[1][1.0]{% + \let\MyFigure\figure + \let\MyEndfigure\endfigure + \renewenvironment{figure}[1]{\begin{SCfigure}[#1]##1}{\end{SCfigure}}} + +\newcommand{\FigBesEnd}{% + \let\figure\MyFigure + \let\endfigure\MyEndfigure} + +% enables calculation of values, +\usepackage{calc} + +% increase the bottom float placement fraction +\renewcommand{\bottomfraction}{0.5} + +% avoids that floats are placed before their +% corresponding section starts +\let\mySection\section\renewcommand{\section}{\suppressfloats[t]\mySection} + +% speed up the longtable calculation +\setcounter{LTchunksize}{100} + +% used for colored tables +\@ifundefined{textcolor} + {\usepackage{color}}{} +\definecolor{darkgreen}{cmyk}{0.5, 0, 1, 0.5} +\definecolor{lightgrey}{gray}{0.8} + +% check for package colortbl +% used for colored table cells +\newboolean{colortbl} +\IfFileExists{colortbl.sty} + {\usepackage{colortbl} + \setboolean{colortbl}{true}} + {\setboolean{colortbl}{false}} + +% used to have extra space in table cells +\@ifundefined{extrarowheight} + {\usepackage{array}}{} +\setlength{\extrarowheight}{2pt} + +% used for customized tables +% --- +\newcolumntype{M}[1] + {>{\centering\hspace{0pt}}m{#1}} + +\newcolumntype{S}[2] + {>{\centering\hspace{0pt}}m{(#1+(2\tabcolsep+\arrayrulewidth)*(1-#2))/#2}} + +\newcolumntype{K}[1] + {>{\columncolor{#1}\hspace{0pt}}c} + +\newcolumntype{V}{!{\vrule width 1.5pt}} + +\newcolumntype{W}{!{\color{green}\vline}} +% --- + +% insert additional vertical space of +% 1.5 mm between footnotes +\let\myFoot\footnote +\renewcommand{\footnote}[1]{\myFoot{#1\vspace{1.5mm}}} + +% number algorithm floats within chapters +\numberwithin{algorithm}{chapter} + +% ------------------------------------ +% used to check for needed LaTeX packages +\usepackage{ifthen} + +% check for package arydshln +% used for tables with dashed lines +\newboolean{arydshln} +\IfFileExists{arydshln.sty} + {\usepackage{arydshln} + \setboolean{arydshln}{true}} + {\setboolean{arydshln}{false}} + +% check for package marginnote +% used for margin notes +\newboolean{marginnote} +\IfFileExists{marginnote.sty} + {\usepackage{marginnote} + \let\marginpar\marginnote + \setboolean{marginnote}{true}} + {\setboolean{marginnote}{false}} + +% check for package sidecap +% used for captions on the side +\newboolean{sidecap} +\IfFileExists{sidecap.sty} + {\usepackage{sidecap} + \setboolean{sidecap}{true}} + {\setboolean{sidecap}{false}} + +% check for picinpar +% used for surrounded fixed objects +\newboolean{picinpar} +\IfFileExists{picinpar.sty} + {\usepackage{picinpar} + \setboolean{picinpar}{true}} + {\setboolean{picinpar}{false}} + +% check for lettrine +\newboolean{lettrine} +\IfFileExists{lettrine.sty} + {\usepackage{lettrine} + \setboolean{lettrine}{true}} + {\setboolean{lettrine}{false}} + +% check for diagbox +\newboolean{diagbox} +\IfFileExists{diagbox.sty} + {\usepackage{diagbox} + \setboolean{diagbox}{true}} + {\setboolean{diagbox}{false}} +% Added by lyx2lyx +\setlength{\parskip}{\medskipamount} +\setlength{\parindent}{0pt} +\end_preamble +\options bibliography=totoc,index=totoc,BCOR7.5mm,titlepage,captions=tableheading,dvipsnames,table +\use_default_options false +\begin_modules +initials +graphicboxes +varwidth +\end_modules +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "lmodern" "default" +\font_sans "lmss" "default" +\font_typewriter "lmtt" "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 true +\graphics default +\default_output_format pdf2 +\output_sync 0 +\bibtex_command default +\index_command makeindex +\paperfontsize 12 +\spacing single +\use_hyperref true +\pdf_title "LyX's Figure, Table, Floats, Notes, and Boxes manual" +\pdf_author "LyX Team, Uwe Stöhr" +\pdf_subject "LyX-documentation about figures, tables, floats, notes, and boxes" +\pdf_keywords "LyX, Tables, Figures, Floats, Boxes, Notes" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen true +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref false +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false" +\papersize default +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\notefontcolor #0000ff +\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 2 +\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 +\SpecialChar LyX +'s detailed Figure, Table, Floats, Notes, Boxes and External Material manual +\end_layout + +\begin_layout Chapter +Floats +\end_layout + +\begin_layout Section +Floats Side by Side +\end_layout + +\begin_layout Standard +To place floats side by side, as in Figures +\begin_inset space ~ +\end_inset + + +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:Float-left" + +\end_inset + + and +\begin_inset CommandInset ref +LatexCommand ref +reference "fig:Float-right" + +\end_inset + +, only +\emph on +one +\emph default + float is used. + In it two minipage boxes are inserted. + +\end_layout + +\begin_layout Standard +\begin_inset Float figure +placement document +alignment document +wide false +sideways false +status open + +\begin_layout Plain Layout +\begin_inset Box Frameless +position "b" +hor_pos "c" +has_inner_box 1 +inner_pos "t" +use_parbox 0 +use_makebox 0 +width "45col%" +special "none" +height "1in" +height_special "totalheight" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Plain Layout +\align center +\begin_inset Graphics + filename ../../../lib/doc/clipart/2D-intensity-plot.pdf + width 100col% + scaleBeforeRotation + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:Float-left" + +\end_inset + +Float on the left side. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset space \hfill{} +\end_inset + + +\begin_inset Box Frameless +position "b" +hor_pos "c" +has_inner_box 1 +inner_pos "t" +use_parbox 0 +use_makebox 0 +width "45col%" +special "none" +height "1in" +height_special "totalheight" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Plain Layout +\align center +\begin_inset Graphics + filename ../../../lib/doc/clipart/Star-structure.pdf + width 100col% + scaleBeforeRotation + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Caption Standard + +\begin_layout Plain Layout +\begin_inset CommandInset label +LatexCommand label +name "fig:Float-right" + +\end_inset + +Float on the right side. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml new file mode 100644 index 0000000000..7f010cf47d --- /dev/null +++ b/autotests/export/docbook/subfigures_boxes_EmbeddedObjects.xml @@ -0,0 +1,32 @@ + + + +LyX's detailed Figure, Table, Floats, Notes, Boxes and External Material manual + +Floats +
+Floats Side by Side +To place floats side by side, as in Figures  and , only one float is used. In it two minipage boxes are inserted. + +No caption +
+Float on the left side. + + + + + +
+
+Float on the right side. + + + + + +
+
+
+
+
\ No newline at end of file diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index eaa24cb5bd..4e7db11901 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -566,6 +566,66 @@ const InsetCaption* findCaptionInParagraph(const Paragraph &par) } +/// Takes an unstructured subfigure container (typically, an InsetBox) and find the elements within: +/// actual content (image or table), maybe a caption, maybe a label. +std::tuple docbookParseHopelessSubfigure(const InsetText * subfigure) +{ + InsetCode type = NO_CODE; + const Inset * content = nullptr; + const InsetCaption * caption = nullptr; + const InsetLabel * label = nullptr; + + for (const auto & it : subfigure->paragraphs()) { + for (pos_type posIn = 0; posIn < it.size(); ++posIn) { + const Inset * inset = it.getInset(posIn); + if (inset) { + switch (inset->lyxCode()) { + case GRAPHICS_CODE: + case TABULAR_CODE: + if (!content) { + content = inset; + type = inset->lyxCode(); + } + break; + case CAPTION_CODE: + if (!caption) { + caption = dynamic_cast(inset); + + // A label often hides in a caption. Make a simplified version of the main loop. + if (!label) { + for (const auto &cit : caption->paragraphs()) { + for (pos_type cposIn = 0; cposIn < cit.size(); ++cposIn) { + const Inset *cinset = cit.getInset(posIn); + if (cinset && cinset->lyxCode() == LABEL_CODE) { + label = dynamic_cast(cinset); + break; + } + } + + if (label) + break; + } + } + } + break; + case LABEL_CODE: + if (!label) + label = dynamic_cast(inset); + break; + default: + break; + } + } + } + + if (content && caption && label) + break; + } + + return std::make_tuple(type, content, caption, label); +} + + void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const InsetCaption * caption, const InsetLabel * label, std::vector & subfigures) { @@ -595,22 +655,27 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins // Deal with each subfigure individually. This should also deal with their caption and their label. // This should be a recursive call to InsetFloat. - // An item in subfigure should either be an InsetBox containing an InsetFloat or directly an InsetFloat. - for (const InsetCollapsible *subfigure: subfigures) { - // If there is no InsetFloat in the paragraphs, output a warning. - bool foundInsetFloat = false; + // An item in subfigure should either be an InsetBox containing an InsetFloat, or an InsetBox directly containing + // an image or a table, or directly an InsetFloat. + for (const InsetCollapsible * subfigure: subfigures) { + if (subfigure == nullptr) + continue; // The collapsible may already be a float (InsetFloat). - if (subfigure && dynamic_cast(subfigure)) - foundInsetFloat = true; + if (dynamic_cast(subfigure)) { + subfigure->docbook(xs, runparams); + continue; + } - // Subfigures are in boxes. - if (!foundInsetFloat) { + // Subfigures are in boxes, then in InsetFloat. + { + bool foundInsetFloat = false; for (const auto &it : subfigure->paragraphs()) { for (pos_type posIn = 0; posIn < it.size(); ++posIn) { const Inset *inset = it.getInset(posIn); - if (inset && dynamic_cast(inset)) { + if (inset && inset->lyxCode() == FLOAT_CODE) { foundInsetFloat = true; + inset->docbook(xs, runparams); break; } } @@ -618,15 +683,79 @@ void docbookSubfigures(XMLStream & xs, OutputParams const & runparams, const Ins if (foundInsetFloat) break; } + if (foundInsetFloat) + continue; } - if (!foundInsetFloat) - xs << XMLStream::ESCAPE_NONE << "Error: no float found in the box. " - "To use subfigures in DocBook, elements must be wrapped in a float " - "inset and have a title/caption."; + // Subfigures are in boxes, then directly an image or a table. In that case, generate the whole content of the + // InsetBox, but not the box container. + // Impose some model on the subfigure: at most a caption, at most a label, exactly one figure or one table. + { + InsetCode stype = NO_CODE; + const Inset * scontent = nullptr; + const InsetCaption * scaption = nullptr; + const InsetLabel * slabel = nullptr; + + std::tie(stype, scontent, scaption, slabel) = docbookParseHopelessSubfigure(subfigure); + + // If there is something, generate it. This is very much like docbookNoSubfigures, but many things + // must be coded differently because there is no float. + // TODO: some code is identical to Floating, like Floating::docbookTag or Floating::docbookCaption. How to reuse that code? + if (scontent) { + // Floating::docbookCaption() + string docbook_caption = "caption"; // This is already correct for tables. + if (stype == GRAPHICS_CODE) + docbook_caption = "title"; + + // Floating::docbookTag() with hasTitle = true, as we are in formalgroup. + string stag = "float"; + if (stype == GRAPHICS_CODE) + stag = "figure"; + else if (stype == TABULAR_CODE) + stag = "table"; + + // Ensure there is no label output, it is supposed to be handled as xml:id. + if (slabel) + rpNoLabel.docbook_anchors_to_ignore.emplace(slabel->screenLabel()); + + // Ensure the float does not output its caption, as it is handled here (DocBook mandates a specific place for + // captions, they cannot appear at the end of the float, albeit LyX is happy with that). + OutputParams rpNoTitle = runparams; + rpNoTitle.docbook_in_float = true; + if (stype == TABULAR_CODE) + rpNoTitle.docbook_in_table = true; + + // Organisation: <contents without title/> </float>. + docstring sattr = docstring(); + if (slabel) + sattr += "xml:id=\"" + xml::cleanID(slabel->screenLabel()) + "\""; + // No layout way of adding attributes, unlike the normal code path. + + xs << xml::StartTag(stag, sattr); + xs << xml::CR(); + xs << xml::StartTag(docbook_caption); + if (scaption) + scaption->getCaptionAsDocBook(xs, rpNoLabel); + else // Mandatory in formalgroup. + xs << "No caption detected"; + xs << xml::EndTag(docbook_caption); + xs << xml::CR(); + scontent->docbook(xs, rpNoTitle); + xs << xml::EndTag(stag); + xs << xml::CR(); + + // This subfigure could be generated. + continue; + } + } + + // If there is no InsetFloat in the inset, output a warning. + xs << XMLStream::ESCAPE_NONE << "Error: no float found in the box. " + "To use subfigures in DocBook, elements must be wrapped in a float " + "inset and have a title/caption."; // TODO: could also output a table, that would ensure that the document is correct and *displays* correctly (but without the right semantics), instead of just an error. - // Finally, recurse. + // Recurse to generate as much content as possible (avoid any loss). subfigure->docbook(xs, runparams); } From dd8660c07e2864d7abfd8708504d06b032c3ed48 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Sat, 12 Sep 2020 01:04:43 +0200 Subject: [PATCH 75/88] layout2layout: use name instead of pseudonym. --- lib/scripts/layout2layout.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py index 7cf2332300..74119bb678 100644 --- a/lib/scripts/layout2layout.py +++ b/lib/scripts/layout2layout.py @@ -271,7 +271,7 @@ currentFormat = 84 # Incremented to format 81, 12 August 2019 by rikiheck # New tag GuiName for counters -# Incremented to format 82, 4 June 2017 by dourouc05 +# Incremented to format 82, 4 June 2017 by tcuvelier # - Add new tags for Layout: # DocBookTag, DocBookAttr, DocBookInInfo, # DocBookWrapperTag, DocBookWrapperAttr, @@ -281,7 +281,7 @@ currentFormat = 84 # - Removed tag Header from ClassOptionsClassOptions # - Removed tag Element for flex insets -# Incremented to format 83, 2 August 2020 by dourouc05 +# Incremented to format 83, 2 August 2020 by tcuvelier # New tags DocBookWrapperMergeWithPrevious and DocBookAbstract # Incremented to format 84, 17 August 2020 by tcuvelier From 3711a38b9c2c1d777ead142460f69284efa82597 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier <tcuvelier@lyx.org> Date: Sat, 12 Sep 2020 01:43:57 +0200 Subject: [PATCH 76/88] DocBook: fix a crash in bibliography paragraphs. --- autotests/export/docbook/SciPoster.lyx | 867 +++++++++++++++++++++++++ autotests/export/docbook/SciPoster.xml | 65 ++ src/output_docbook.cpp | 4 +- 3 files changed, 934 insertions(+), 2 deletions(-) create mode 100644 autotests/export/docbook/SciPoster.lyx create mode 100644 autotests/export/docbook/SciPoster.xml diff --git a/autotests/export/docbook/SciPoster.lyx b/autotests/export/docbook/SciPoster.lyx new file mode 100644 index 0000000000..1bd3b51f79 --- /dev/null +++ b/autotests/export/docbook/SciPoster.lyx @@ -0,0 +1,867 @@ +#LyX 2.3 created this file. For more info see http://www.lyx.org/ +\lyxformat 544 +\begin_document +\begin_header +\save_transient_properties true +\origin /systemlyxdir/templates/Posters/ +\textclass sciposter +\begin_preamble +%% Comment this out and adapt if you want a poster background +%\usepackage{wallpaper} +%\CenterWallPaper{1.1}{poster-background} + +% Set all margins to 1cm +\setmargins[1cm] + +% Set up column layout +\setlength\columnseprule{0pt} +\setlength\columnsep{4.5pc} + +% Color settings: +\usepackage{sectionbox} +% a.) background color +%\definecolor{mainCol}{RGB}{255,237,208} +% b.) text color (mainly subsection headers) +\definecolor{TextCol}{RGB}{128,0,0} +% c.) section header color +\definecolor{SectionCol}{RGB}{0,0,255} +% d.) color of section boxes +\definecolor{sectboxfillcol}{RGB}{255,220,168} +\definecolor{subsectboxfillcol}{RGB}{255,245,198} + +% Large section titles +\renewcommand{\sectionsize}{\Large} +\end_preamble +\options landscape,a0,largefonts,plainsections +\use_default_options false +\begin_modules +multicol +sectionbox +\end_modules +\maintain_unincluded_children false +\language english +\language_package default +\inputencoding utf8 +\fontencoding global +\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_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 false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\cite_engine natbib +\cite_engine_type numerical +\biblio_style plainnat +\use_bibtopic false +\use_indices false +\paperorientation portrait +\suppress_date false +\justification true +\use_refstyle 0 +\use_minted 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\secnumdepth 0 +\tocdepth -1 +\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 +\tracking_changes false +\output_changes false +\html_math_output 0 +\html_css_as_file 0 +\html_be_strict false +\end_header + +\begin_body + +\begin_layout Title +Poster Title +\end_layout + +\begin_layout Author +Author One and Author Two +\end_layout + +\begin_layout Institute +The University, Some address, Postal Code +\end_layout + +\begin_layout E-Mail +author1@somewhere and author2@elsewhere +\end_layout + +\begin_layout Conference +The Conference +\begin_inset Note Note +status open + +\begin_layout Plain Layout +appears in footer +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Note Note +status open + +\begin_layout Section* +Some advices +\end_layout + +\begin_layout Subsubsection* +Appearance +\end_layout + +\begin_layout Itemize +See +\family sans +Document\SpecialChar menuseparator +Settings\SpecialChar menuseparator +\SpecialChar LaTeX + Preamble +\family default + for some possibilities to adjust the appearance of your poster. + Also check +\family sans +Document\SpecialChar menuseparator +Settings\SpecialChar menuseparator +Document Class\SpecialChar menuseparator +Class Options +\family default + for some general settings. + Please refer to the +\family sans +sciposter +\family default + manual for possible values. +\end_layout + +\begin_layout Subsubsection* +Logo +\end_layout + +\begin_layout Itemize +You can use the +\family sans +LeftLogo +\family default + and +\family sans +RightLogo +\family default + style to insert graphic logos in the header of your poster. + The logos need to be given as file names (with our without extension) and + with full path, if the files are not in the TEXMF directory. +\end_layout + +\begin_layout Itemize +Note that the logos only appear if you do not specify a +\begin_inset Quotes eld +\end_inset + +Conference +\begin_inset Quotes erd +\end_inset + + (i. +\begin_inset space \thinspace{} +\end_inset + +e., no foot line). +\end_layout + +\begin_layout Subsubsection* +Columns and Boxes +\end_layout + +\begin_layout Itemize +The +\family sans +Columns +\family default + and +\family sans +(Section) Box +\family default + insets can be found at +\family sans +Insert\SpecialChar menuseparator +Custom Insets. +\end_layout + +\begin_layout Itemize +Instead of the Section Boxes, you can also use the differently looking Color + Boxes via the +\begin_inset Quotes eld +\end_inset + +Color Boxes +\begin_inset Quotes erd +\end_inset + + module. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Flex Multiple Columns +status open + +\begin_layout Plain Layout +\begin_inset Argument 1 +status open + +\begin_layout Plain Layout + +3 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Abstract +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\size small +\emph on +This is my special abstract This is my special abstract This is my special + abstract This is my special abstract This is my special abstract This is + my special abstract This is my special abstract This is my special abstract + This is my special abstract This is my special abstract. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Background +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +This is the background and our hypothesis. + This is the background and our hypothesis. + This is the background and our hypothesis. + This is the background and our hypothesis. + This is the background and our hypothesis. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\size small +\begin_inset Flex SectionBox +status open + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +label "One/Two(2010)" +key "key-1" +literal "true" + +\end_inset + +Author One & Author Two (2010): Our Great Book. + Somewhere. +\end_layout + +\begin_layout Bibliography +\begin_inset CommandInset bibitem +LatexCommand bibitem +label "Two/One(2011)" +key "key-2" +literal "true" + +\end_inset + +Author Two & Author One (2011): Our Even Greater Book. + Somewhere. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +columnbreak +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Findings +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SubsectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Some evidence +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +point one +\end_layout + +\begin_layout Itemize +point two +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SubsectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +More evidence +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +point three +\end_layout + +\begin_layout Itemize +point four +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SubsectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Other issues +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +Really have to fill in this +\end_layout + +\begin_layout Itemize +Really have to fill in this +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +columnbreak +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Experiment +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + This is the experiment. + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Results +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +result +\end_layout + +\begin_layout Itemize +result +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Conclusions +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Enumerate +first conclusion +\end_layout + +\begin_layout Enumerate +second conclusion +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Flex SectionBox +status open + +\begin_layout Plain Layout +\begin_inset Argument 2 +status collapsed + +\begin_layout Plain Layout +Available font size (and corresponding +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + + +\backslash +LaTeX +\backslash + +\end_layout + +\end_inset + + commands) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\paragraph_spacing single +\begin_inset Note Note +status open + +\begin_layout Plain Layout +The extra sizes ( +\begin_inset Quotes eld +\end_inset + +Giant +\begin_inset Quotes erd +\end_inset + + etc.) are available at +\family sans +Insert\SpecialChar menuseparator +Custom Insets +\family default +. + For small inline snippets, there are variants at +\family sans +Edit\SpecialChar menuseparator +Text Style. +\end_layout + +\begin_layout Plain Layout +Note that for some paper sizes and font settings, +\begin_inset Quotes eld +\end_inset + +More Giant +\begin_inset Quotes erd +\end_inset + + and +\begin_inset Quotes eld +\end_inset + +Most Giant +\begin_inset Quotes erd +\end_inset + + are equal. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout + +\size tiny +Tiny ( +\family typewriter + +\backslash +tiny +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size scriptsize +Smallest ( +\family typewriter + +\backslash +scriptsize +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size footnotesize +Smaller ( +\family typewriter + +\backslash +footnotesize +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size normal +Normal ( +\family typewriter +\size default + +\backslash +normalsize +\family default +\size normal +) +\end_layout + +\begin_layout Plain Layout + +\size large +Large ( +\family typewriter + +\backslash +large +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size larger +Larger ( +\family typewriter + +\backslash +Large +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size largest +Largest ( +\family typewriter + +\backslash +LARGE +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size huge +Huge ( +\family typewriter + +\backslash +huge +\family default +) +\end_layout + +\begin_layout Plain Layout + +\size giant +Huger ( +\family typewriter + +\backslash +Huge +\family default +) +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex Giant +status open + +\begin_layout Plain Layout +Giant ( +\family typewriter + +\backslash +veryHuge +\family default +) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex More Giant +status open + +\begin_layout Plain Layout +More Giant ( +\family typewriter + +\backslash +VeryHuge +\family default +) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Plain Layout +\begin_inset Flex Most Giant +status open + +\begin_layout Plain Layout +Most Giant ( +\family typewriter + +\backslash +VERYHuge +\family default +) +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/SciPoster.xml b/autotests/export/docbook/SciPoster.xml new file mode 100644 index 0000000000..abd919be1a --- /dev/null +++ b/autotests/export/docbook/SciPoster.xml @@ -0,0 +1,65 @@ +<?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>Poster Title + +Author One and Author Two + +The University, Some address, Postal Code + +author1@somewhere and author2@elsewhere + +The Conference + + +This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract This is my special abstract.This is the background and our hypothesis. This is the background and our hypothesis. This is the background and our hypothesis. This is the background and our hypothesis. This is the background and our hypothesis. +Author One & Author Two (2010): Our Great Book. Somewhere. +Author Two & Author One (2011): Our Even Greater Book. Somewhere. + + + + +point one + + +point two + + + + +point three + + +point four + + + + +Really have to fill in this + + +Really have to fill in this + + + +This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. This is the experiment. + +result + + +result + + + + +first conclusion + + +second conclusion + + + +Tiny (\tiny)Smallest (\scriptsize)Smaller (\footnotesize)Normal (\normalsize)Large (\large)Larger (\Large)Largest (\LARGE)Huge (\huge)Huger (\Huge)Giant (\veryHuge)More Giant (\VeryHuge)Most Giant (\VERYHuge) + \ No newline at end of file diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index 1e804ee2ff..ee829e5cef 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -362,8 +362,8 @@ void makeBibliography( ParagraphList::const_iterator const & par) { // If this is the first paragraph in a bibliography, open the bibliography tag. - auto pbegin_before = text.paragraphs().getParagraphBefore(par); - if (pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT) { + auto const * pbegin_before = text.paragraphs().getParagraphBefore(par); + if (pbegin_before == nullptr || (pbegin_before && pbegin_before->layout().latextype != LATEX_BIB_ENVIRONMENT)) { xs << xml::StartTag("bibliography"); xs << xml::CR(); } From 50f011e062646fbc7354ee4be938dd376769900d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 12 Sep 2020 01:52:58 +0200 Subject: [PATCH 77/88] DocBook: implement InsetBox titles. --- autotests/export/docbook/A0_Poster_Simple.lyx | 192 ++++++++++++++++++ autotests/export/docbook/A0_Poster_Simple.xml | 16 ++ src/insets/InsetBox.cpp | 17 +- src/output_docbook.cpp | 66 +++--- src/output_docbook.h | 24 ++- 5 files changed, 269 insertions(+), 46 deletions(-) create mode 100644 autotests/export/docbook/A0_Poster_Simple.lyx create mode 100644 autotests/export/docbook/A0_Poster_Simple.xml diff --git a/autotests/export/docbook/A0_Poster_Simple.lyx b/autotests/export/docbook/A0_Poster_Simple.lyx new file mode 100644 index 0000000000..998f210ca7 --- /dev/null +++ b/autotests/export/docbook/A0_Poster_Simple.lyx @@ -0,0 +1,192 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass a0poster +\begin_preamble +% Adjust padding in boxes +\setlength\fboxsep{12pt} +% Added by lyx2lyx +\setlength{\parskip}{\bigskipamount} +\setlength{\parindent}{0pt} +\end_preamble +\options a0,portrait +\use_default_options false +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "palatino" "default" +\font_sans "default" "default" +\font_typewriter "courier" "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 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\leftmargin 1cm +\topmargin 1cm +\rightmargin 1cm +\bottommargin 1cm +\secnumdepth 0 +\tocdepth 0 +\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 empty +\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 Standard +\align center +\begin_inset Box Shadowbox +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 1 +use_makebox 0 +width "98col%" +special "none" +height "5cm" +height_special "none" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Plain Layout +\noindent +\align center + +\series bold +\noun on +\begin_inset Flex Most Giant Snippet +status open + +\begin_layout Plain Layout +\noindent + +\series bold +\noun on +Poster Heading +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Box Boxed +position "t" +hor_pos "c" +has_inner_box 1 +inner_pos "t" +use_parbox 0 +use_makebox 0 +width "98col%" +special "none" +height "1in" +height_special "totalheight" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Section +Summary +\end_layout + +\begin_layout Itemize +For multiple columns, use the +\begin_inset Quotes eld +\end_inset + +Multiple Columns +\begin_inset Quotes erd +\end_inset + + module as documented in +\family sans +Help\SpecialChar menuseparator +Additional Features +\family default +. +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/docbook/A0_Poster_Simple.xml b/autotests/export/docbook/A0_Poster_Simple.xml new file mode 100644 index 0000000000..3594ffd446 --- /dev/null +++ b/autotests/export/docbook/A0_Poster_Simple.xml @@ -0,0 +1,16 @@ + + +
+ +Poster Heading + + +Summary + + +For multiple columns, use the “Multiple Columns” module as documented in Help⇒Additional Features. + + + +
\ No newline at end of file diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp index db76f53753..d714cf7853 100644 --- a/src/insets/InsetBox.cpp +++ b/src/insets/InsetBox.cpp @@ -26,6 +26,7 @@ #include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" +#include "output_docbook.h" #include "output_xhtml.h" #include "TexRow.h" #include "texstream.h" @@ -727,7 +728,21 @@ void InsetBox::docbook(XMLStream & xs, OutputParams const & runparams) const LYXERR0("Assertion failed: box layout " + getLayout().name() + " missing DocBookWrapperTag."); } - InsetText::docbook(xs, runparams); + // If the box starts with a sectioning item, use as box title. + auto current_par = paragraphs().begin(); + if (current_par->layout().category() == from_utf8("Sectioning")) { + // Only generate the first paragraph. + current_par = makeAny(text(), buffer(), xs, runparams, paragraphs().begin()); + } + + xs.startDivision(false); + // Don't call InsetText::docbook, as this would generate all paragraphs in the inset, not the ones we are + // interested in. The best solution would be to call docbookParagraphs with an updated OutputParams object to only + // generate paragraphs after the title, but it leads to strange crashes, as if text().paragraphs() then returns + // a smaller set of paragrphs. + while (current_par != paragraphs().end()) + current_par = makeAny(text(), buffer(), xs, runparams, current_par); + xs.endDivision(); if (!getLayout().docbookwrappertag().empty()) { if (!xs.isLastTagCR()) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index ee829e5cef..c8ddc1a0a2 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -16,6 +16,7 @@ #include "BufferParams.h" #include "Font.h" #include "InsetList.h" +#include "output_docbook.h" #include "Paragraph.h" #include "ParagraphList.h" #include "ParagraphParameters.h" @@ -347,13 +348,6 @@ void closeParTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpa } -ParagraphList::const_iterator makeAny(Text const &, - Buffer const &, - XMLStream &, - OutputParams const &, - ParagraphList::const_iterator); - - void makeBibliography( Text const & text, Buffer const & buf, @@ -714,35 +708,6 @@ void makeCommand( } -ParagraphList::const_iterator makeAny(Text const &text, - Buffer const &buf, - XMLStream &xs, - OutputParams const &runparams, - ParagraphList::const_iterator par) -{ - switch (par->layout().latextype) { - case LATEX_COMMAND: - makeCommand(text, buf, xs, runparams, par); - break; - case LATEX_ENVIRONMENT: - makeEnvironment(text, buf, xs, runparams, par); - break; - case LATEX_LIST_ENVIRONMENT: - case LATEX_ITEM_ENVIRONMENT: - // Only case when makeAny() might consume more than one paragraph. - return makeListEnvironment(text, buf, xs, runparams, par); - case LATEX_PARAGRAPH: - makeParagraph(text, buf, xs, runparams, par); - break; - case LATEX_BIB_ENVIRONMENT: - makeBibliography(text, buf, xs, runparams, par); - break; - } - ++par; - return par; -} - - bool isLayoutSectioning(Layout const & lay) { return lay.category() == from_utf8("Sectioning"); @@ -862,6 +827,35 @@ DocBookInfoTag getParagraphsWithInfo(ParagraphList const ¶graphs, } // end anonymous namespace +ParagraphList::const_iterator makeAny(Text const &text, + Buffer const &buf, + XMLStream &xs, + OutputParams const &runparams, + ParagraphList::const_iterator par) +{ + switch (par->layout().latextype) { + case LATEX_COMMAND: + makeCommand(text, buf, xs, runparams, par); + break; + case LATEX_ENVIRONMENT: + makeEnvironment(text, buf, xs, runparams, par); + break; + case LATEX_LIST_ENVIRONMENT: + case LATEX_ITEM_ENVIRONMENT: + // Only case when makeAny() might consume more than one paragraph. + return makeListEnvironment(text, buf, xs, runparams, par); + case LATEX_PARAGRAPH: + makeParagraph(text, buf, xs, runparams, par); + break; + case LATEX_BIB_ENVIRONMENT: + makeBibliography(text, buf, xs, runparams, par); + break; + } + ++par; + return par; +} + + xml::FontTag docbookStartFontTag(xml::FontTypes type) { return xml::FontTag(from_utf8(fontToDocBookTag(type)), from_utf8(fontToAttribute(type)), type); diff --git a/src/output_docbook.h b/src/output_docbook.h index 4dcc853df2..401018d6dc 100644 --- a/src/output_docbook.h +++ b/src/output_docbook.h @@ -16,6 +16,7 @@ #define OUTPUT_DOCBOOK_H #include "LayoutEnums.h" +#include "ParagraphList.h" #include "support/docstream.h" #include "support/strfwd.h" @@ -27,18 +28,23 @@ class Buffer; class OutputParams; class Text; -/// -std::string const fontToDocBookTag(xml::FontTypes type); -/// +/// generates an xml::StartTag for the given style xml::FontTag docbookStartFontTag(xml::FontTypes type); -/// +/// generates an xml::EndTag for the given style xml::EndFontTag docbookEndFontTag(xml::FontTypes type); -/// -void docbookParagraphs(Text const & text, - Buffer const & buf, - XMLStream & os, - OutputParams const & runparams); +/// output a series of paragraphs into the XMLStream +void docbookParagraphs(Text const &, + Buffer const &, + XMLStream &, + OutputParams const &); + +/// output a single paragraph into the XMLStream +ParagraphList::const_iterator makeAny(Text const &, + Buffer const &, + XMLStream &, + OutputParams const &, + ParagraphList::const_iterator); } // namespace lyx From 6c51cabd35b48eb2245330cda49b2be5c9a2c223 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 12 Sep 2020 03:21:08 +0200 Subject: [PATCH 78/88] DocBook: fix output in Layout::write. --- lib/layouts/aastex.layout | 2 +- lib/layouts/shapepar.module | 32 ++++++++++++++++---------------- lib/layouts/stdstarsections.inc | 10 +++++----- src/Layout.cpp | 4 ++-- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/layouts/aastex.layout b/lib/layouts/aastex.layout index 78089a45c9..37dbd07130 100644 --- a/lib/layouts/aastex.layout +++ b/lib/layouts/aastex.layout @@ -204,7 +204,7 @@ Style Altaffilation Color green EndFont DocBookTag affiliation - DocBookAttr role="alternate" + DocBookAttr role='alternate' DocBookWrapperTag author DocBookWrapperMergeWithPrevious true DocBookItemTag orgname diff --git a/lib/layouts/shapepar.module b/lib/layouts/shapepar.module index 6b38cdfbbf..2b2fbfe32e 100644 --- a/lib/layouts/shapepar.module +++ b/lib/layouts/shapepar.module @@ -36,50 +36,50 @@ Style "CD label" Align Block LabelType No_Label DocBookWrapperTag sidebar - DocBookWrapperAttr role="cd-label" + DocBookWrapperAttr role='cd-label' DocBookTag para End Style "Circle" CopyStyle "CD label" LatexName circlepar - DocBookWrapperAttr role="circle" + DocBookWrapperAttr role='circle' End Style "Diamond" CopyStyle "CD label" LatexName diamondpar - DocBookWrapperAttr role="diamond" + DocBookWrapperAttr role='diamond' End Style "Heart" CopyStyle "CD label" LatexName heartpar - DocBookWrapperAttr role="heart" + DocBookWrapperAttr role='heart' End Style "Hexagon" CopyStyle "CD label" LatexName hexagonpar - DocBookWrapperAttr role="hexagon" + DocBookWrapperAttr role='hexagon' End Style "Nut" CopyStyle "CD label" LatexName nutpar - DocBookWrapperAttr role="nut" + DocBookWrapperAttr role='nut' End Style "Square" CopyStyle "CD label" LatexName squarepar - DocBookWrapperAttr role="square" + DocBookWrapperAttr role='square' End Style "Star" CopyStyle "CD label" LatexName starpar - DocBookWrapperAttr role="star" + DocBookWrapperAttr role='star' End # now the shapes defined in the .def files @@ -87,49 +87,49 @@ End Style "Candle" CopyStyle "CD label" LatexName shapepar{\candle} - DocBookWrapperAttr role="candle" + DocBookWrapperAttr role='candle' End Style "Drop down" CopyStyle "CD label" LatexName droppar - DocBookWrapperAttr role="drop-down" + DocBookWrapperAttr role='drop-down' End Style "Drop up" CopyStyle "CD label" LatexName dropuppar - DocBookWrapperAttr role="drop-up" + DocBookWrapperAttr role='drop-up' End Style "TeX" CopyStyle "CD label" LatexName shapepar{\TeXshape} - DocBookWrapperAttr role="tex" + DocBookWrapperAttr role='tex' End Style "Triangle up" CopyStyle "CD label" LatexName triangleuppar - DocBookWrapperAttr role="triangle-up" + DocBookWrapperAttr role='triangle-up' End Style "Triangle down" CopyStyle "CD label" LatexName triangledownpar - DocBookWrapperAttr role="triangle-down" + DocBookWrapperAttr role='triangle-down' End Style "Triangle left" CopyStyle "CD label" LatexName triangleleftpar - DocBookWrapperAttr role="triangle-left" + DocBookWrapperAttr role='triangle-left' End Style "Triangle right" CopyStyle "CD label" LatexName trianglerightpar - DocBookWrapperAttr role="triangle-right" + DocBookWrapperAttr role='triangle-right' End # finally the low-level commands diff --git a/lib/layouts/stdstarsections.inc b/lib/layouts/stdstarsections.inc index 60354b1dd3..0159b07b52 100644 --- a/lib/layouts/stdstarsections.inc +++ b/lib/layouts/stdstarsections.inc @@ -49,7 +49,7 @@ Style Section* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="sect1" + DocBookAttr renderas='sect1' DocBookSectionTag NONE DocBookForceAbstractTag NONE End @@ -64,7 +64,7 @@ Style Subsection* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="sect2" + DocBookAttr renderas='sect2' DocBookSectionTag NONE DocBookForceAbstractTag NONE End @@ -79,7 +79,7 @@ Style Subsubsection* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="sect3" + DocBookAttr renderas='sect3' DocBookSectionTag NONE DocBookForceAbstractTag NONE End @@ -94,7 +94,7 @@ Style Paragraph* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="sect4" + DocBookAttr renderas='sect4' DocBookSectionTag NONE DocBookForceAbstractTag NONE End @@ -109,7 +109,7 @@ Style Subparagraph* LabelCounter "" ResetArgs 1 DocBookTag bridgehead - DocBookAttr renderas="sect5" + DocBookAttr renderas='sect5' DocBookSectionTag NONE DocBookForceAbstractTag NONE End diff --git a/src/Layout.cpp b/src/Layout.cpp index 102410d534..f5e6f77130 100644 --- a/src/Layout.cpp +++ b/src/Layout.cpp @@ -1643,7 +1643,7 @@ void Layout::write(ostream & os) const if(!docbooktag_.empty()) os << "\tDocBookTag " << docbooktag_ << '\n'; if(!docbookattr_.empty()) - os << "\tDocBookAttr " << docbookattr_ << '\n'; + os << "\tDocBookAttr \"" << docbookattr_ << "\"\n"; if(!docbooktagtype_.empty()) os << "\tDocBookTagType " << docbooktagtype_ << '\n'; if(!docbookininfo_.empty()) @@ -1669,7 +1669,7 @@ void Layout::write(ostream & os) const os << "\tDocBookItemWrapperAttr " << docbookitemwrapperattr_ << '\n'; if(!docbookitemwrappertagtype_.empty()) os << "\tDocBookItemWrapperTagType " << docbookitemwrappertagtype_ << '\n'; - os << "\tDocBookItemWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n'; + os << "\tDocBookWrapperMergeWithPrevious " << docbookwrappermergewithprevious_ << '\n'; if(!docbookitemlabeltag_.empty()) os << "\tDocBookItemLabelTag " << docbookitemlabeltag_ << '\n'; if(!docbookitemlabelattr_.empty()) From bfeb3b66b104f6262de8169e32c49413bfe1a79d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sun, 13 Sep 2020 01:50:11 +0200 Subject: [PATCH 79/88] DocBook: slight code simplification. --- src/output_docbook.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/output_docbook.cpp b/src/output_docbook.cpp index c8ddc1a0a2..0d0aa108d0 100644 --- a/src/output_docbook.cpp +++ b/src/output_docbook.cpp @@ -1087,8 +1087,7 @@ void docbookParagraphs(Text const &text, // Close all sections before the bibliography. // TODO: Only close all when the bibliography is at the end of the document? Or force to output the bibliography at the end of the document? Or don't care (as allowed by DocBook)? - auto insetsLength = distance(par->insetList().begin(), par->insetList().end()); - if (insetsLength > 0) { + if (!par->insetList().empty()) { Inset const *firstInset = par->getInset(0); if (firstInset && (firstInset->lyxCode() == BIBITEM_CODE || firstInset->lyxCode() == BIBTEX_CODE)) { while (!headerLevels.empty()) { From 92ad86daccfcdf9ae2ebfa084c38b2712d0cc8c3 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 03:18:32 +0200 Subject: [PATCH 80/88] XHTML: remove
support. --- src/output_xhtml.cpp | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index f8cd53e478..99d425e4bc 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -590,7 +590,6 @@ void xhtmlParagraphs(Text const & text, ParagraphList::const_iterator const pend = (epit == (int) paragraphs.size()) ? paragraphs.end() : paragraphs.iterator_at(epit); - std::stack headerLevels; while (bpit < epit) { ParagraphList::const_iterator par = paragraphs.iterator_at(bpit); @@ -609,33 +608,6 @@ void xhtmlParagraphs(Text const & text, ParagraphList::const_iterator const lastpar = par; ParagraphList::const_iterator send; - // Think about adding
and/or
s. - if (style.category() == from_utf8("Sectioning")) { - int level = style.toclevel; - - // Need to close a previous section if it has the same level or a higher one (close
if opening a - //

after a

,

,

,

or
). More examples: - // - current: h2; back: h1; do not close any
- // - current: h1; back: h2; close two
(first the

, then the

, so a new

can come) - while (!headerLevels.empty() && level <= headerLevels.top()) { - // Output the tag only if it corresponds to a legit section. - int stackLevel = headerLevels.top(); - if (stackLevel != Layout::NOT_IN_TOC && level > 1) { //

is the document title. - xs << xml::EndTag("section"); - xs << xml::CR(); - } - headerLevels.pop(); - } - - // Open the new section: first push it onto the stack, then output it in XHTML. - headerLevels.push(level); - // Some sectioning-like elements should not be output (such as FrontMatter). - if (level != Layout::NOT_IN_TOC && level > 1) { //

is the document title. - xs << xml::StartTag("section"); - xs << xml::CR(); - } - } - switch (style.latextype) { case LATEX_COMMAND: { // The files with which we are working never have more than @@ -672,15 +644,6 @@ void xhtmlParagraphs(Text const & text, } bpit += distance(lastpar, par); } - - // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning - // of the loop). - while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) { - docstring tag = from_utf8("
"); - headerLevels.pop(); - xs << XMLStream::ESCAPE_NONE << tag; - xs << xml::CR(); - } } From c8e2c17a5835f5c656fd6c26a84d793058dc4440 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 03:22:38 +0200 Subject: [PATCH 81/88] XHTML: remove DOCTYPE, as the document is then understood as HTML4/XHTML1, and not XHTML5. --- src/Buffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2ef5768771..0cf87defb7 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2217,7 +2217,7 @@ Buffer::ExportStatus Buffer::writeLyXHTMLSource(odocstream & os, if (output_preamble) { os << "\n" - << "\n" + << "\n" // FIXME Language should be set properly. << "\n" << "\n" From 15dbc2b9ab0765b950ebe57300178fa4ec59f3cd Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 03:37:46 +0200 Subject: [PATCH 82/88] Revert "XHTML: remove
support." This reverts commit 52216b73 --- src/output_xhtml.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 99d425e4bc..f8cd53e478 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -590,6 +590,7 @@ void xhtmlParagraphs(Text const & text, ParagraphList::const_iterator const pend = (epit == (int) paragraphs.size()) ? paragraphs.end() : paragraphs.iterator_at(epit); + std::stack headerLevels; while (bpit < epit) { ParagraphList::const_iterator par = paragraphs.iterator_at(bpit); @@ -608,6 +609,33 @@ void xhtmlParagraphs(Text const & text, ParagraphList::const_iterator const lastpar = par; ParagraphList::const_iterator send; + // Think about adding
and/or
s. + if (style.category() == from_utf8("Sectioning")) { + int level = style.toclevel; + + // Need to close a previous section if it has the same level or a higher one (close
if opening a + //

after a

,

,

,

or
). More examples: + // - current: h2; back: h1; do not close any
+ // - current: h1; back: h2; close two
(first the

, then the

, so a new

can come) + while (!headerLevels.empty() && level <= headerLevels.top()) { + // Output the tag only if it corresponds to a legit section. + int stackLevel = headerLevels.top(); + if (stackLevel != Layout::NOT_IN_TOC && level > 1) { //

is the document title. + xs << xml::EndTag("section"); + xs << xml::CR(); + } + headerLevels.pop(); + } + + // Open the new section: first push it onto the stack, then output it in XHTML. + headerLevels.push(level); + // Some sectioning-like elements should not be output (such as FrontMatter). + if (level != Layout::NOT_IN_TOC && level > 1) { //

is the document title. + xs << xml::StartTag("section"); + xs << xml::CR(); + } + } + switch (style.latextype) { case LATEX_COMMAND: { // The files with which we are working never have more than @@ -644,6 +672,15 @@ void xhtmlParagraphs(Text const & text, } bpit += distance(lastpar, par); } + + // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning + // of the loop). + while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) { + docstring tag = from_utf8("
"); + headerLevels.pop(); + xs << XMLStream::ESCAPE_NONE << tag; + xs << xml::CR(); + } } From e4065cc1b1394c61108735611e0ebf02b12e6bbe Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 04:02:51 +0200 Subject: [PATCH 83/88] Converters: slightly more pythonic code. --- lib/scripts/convertDefault.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/scripts/convertDefault.py b/lib/scripts/convertDefault.py index c9277131ac..5287e96375 100644 --- a/lib/scripts/convertDefault.py +++ b/lib/scripts/convertDefault.py @@ -25,7 +25,7 @@ re_version = re.compile(r'^Version:.*ImageMagick\s*(\d*)\.(\d*)\.(\d*).*$') command = 'magick' fout = os.popen('magick -version 2>&1') output = fout.readline() -if fout.close() != None: +if fout.close() is not None: # older versions # caution: windows has a convert.exe for converting file systems command = 'convert' @@ -39,7 +39,7 @@ version = re_version.match(output) im = False gm = False -if version != None: +if version is not None: major = int(version.group(1)) minor = int(version.group(2)) patch = int(version.group(3)) @@ -49,7 +49,7 @@ else: # Try GraphicsMagick re_version = re.compile(r'^GraphicsMagick.*http:..www.GraphicsMagick.org.*$') version = re_version.match(output) - if version != None: + if version is not None: gm = True # we need version to be a valid integer 3-tuple version = (1,0,0) @@ -72,10 +72,10 @@ if sys.argv[3] == 'ppm' and (im and version >= (6,3,5) or gm): # print (command, sys.argv[2], sys.argv[4], file= sys.stdout) if (im or gm) and os.system(r'%s %s "%s" %s "%s"' % (command, sopts, sys.argv[2], topts, sys.argv[3] + ':' + sys.argv[4])) != 0: - print (sys.argv[0], 'ERROR', file= sys.stderr) - print ('Execution of "%s" failed.' % command, file= sys.stderr) + print(sys.argv[0], 'ERROR', file= sys.stderr) + print('Execution of "%s" failed.' % command, file= sys.stderr) sys.exit(1) elif not im and not gm and sys.platform == 'darwin' and os.system(r'%s "%s" "%s"' % (command, sys.argv[2], sys.argv[4])) != 0: - print (sys.argv[0], 'ERROR', file= sys.stderr) - print ('Execution of "%s" failed.' % command, file= sys.stderr) + print(sys.argv[0], 'ERROR', file= sys.stderr) + print('Execution of "%s" failed.' % command, file=sys.stderr) sys.exit(1) From 1991d0ed24780cbb0064b7be7a733bc1ee9e241e Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 04:12:26 +0200 Subject: [PATCH 84/88] Converters: always set version to something. Otherwise, it's common to compare "None >= (6,2,6)", which makes no sense. Set it to (0,0,0) so that any comparison fails (without an error message). --- lib/scripts/convertDefault.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/scripts/convertDefault.py b/lib/scripts/convertDefault.py index 5287e96375..d04fa78799 100644 --- a/lib/scripts/convertDefault.py +++ b/lib/scripts/convertDefault.py @@ -53,6 +53,8 @@ else: gm = True # we need version to be a valid integer 3-tuple version = (1,0,0) + else: + version = (0,0,0) # IM >= 5.5.8 separates options for source and target files # See http://www.imagemagick.org/Usage/basics/#why From 0dfa24020919a436a5ee8937bb0bbc7c0863406d Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Wed, 16 Sep 2020 04:13:42 +0200 Subject: [PATCH 85/88] XHTML: restore sections. --- src/output_xhtml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index f8cd53e478..fe396f83d8 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -675,7 +675,7 @@ void xhtmlParagraphs(Text const & text, // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning // of the loop). - while (!headerLevels.empty() && headerLevels.top() > Layout::NOT_IN_TOC) { + while (!headerLevels.empty() && headerLevels.top() != Layout::NOT_IN_TOC && headerLevels.top() > 1) { docstring tag = from_utf8("
"); headerLevels.pop(); xs << XMLStream::ESCAPE_NONE << tag; From a85b4b88ed4e8e35ee8f6d976cc1a702a106c00f Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 19 Sep 2020 03:23:00 +0200 Subject: [PATCH 86/88] XHTML sections: only filter out things that are not Sectioning, not based on the level. --- autotests/export/xhtml/zh_CN_Tutorial.lyx | 974 ++++++++++++++++++++ autotests/export/xhtml/zh_CN_Tutorial.xhtml | 256 +++++ src/output_xhtml.cpp | 9 +- 3 files changed, 1236 insertions(+), 3 deletions(-) create mode 100644 autotests/export/xhtml/zh_CN_Tutorial.lyx create mode 100644 autotests/export/xhtml/zh_CN_Tutorial.xhtml diff --git a/autotests/export/xhtml/zh_CN_Tutorial.lyx b/autotests/export/xhtml/zh_CN_Tutorial.lyx new file mode 100644 index 0000000000..f5bbb69bf6 --- /dev/null +++ b/autotests/export/xhtml/zh_CN_Tutorial.lyx @@ -0,0 +1,974 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass book +\begin_preamble +% Chinese localization +\@ifpackageloaded{fontspec}% +{\usepackage{ctex}}% ctex with non-TeX fonts +{%\usepackage[UTF8]{ctex}% error with font setup (missing font?) +} +\end_preamble +\options cjk +\use_default_options true +\maintain_unincluded_children no +\language chinese-simplified +\language_package default +\inputencoding utf8-cjk +\fontencoding auto +\font_roman "lmodern" "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 +\font_cjk gbsn +\use_microtype false +\use_dash_ligatures false +\graphics default +\default_output_format default +\output_sync 0 +\bibtex_command default +\index_command default +\float_placement th +\float_alignment class +\paperfontsize 12 +\spacing onehalf +\use_hyperref true +\pdf_title "The LyX Tutorial" +\pdf_author "LyX Team" +\pdf_subject "LyX-documentation Tutorial" +\pdf_keywords "LyX, documentation" +\pdf_bookmarks true +\pdf_bookmarksnumbered true +\pdf_bookmarksopen true +\pdf_bookmarksopenlevel 1 +\pdf_breaklinks false +\pdf_pdfborder false +\pdf_colorlinks true +\pdf_backref section +\pdf_pdfusetitle false +\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue,pdfpagelayout=OneColumn, pdfnewwindow=true,pdfstartview=XYZ, plainpages=false" +\papersize a4 +\use_geometry false +\use_package amsmath 1 +\use_package amssymb 1 +\use_package cancel 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\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 2 +\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 +The \SpecialChar LyX + Tutorial +\end_layout + +\begin_layout Chapter +介绍 +\end_layout + +\begin_layout Section +欢迎来到 \SpecialChar LyX +! +\end_layout + +\begin_layout Standard +这个文档是为那些不知道 \SpecialChar LaTeX + 或知之甚少的人准备的。不必担心,使用 \SpecialChar LyX + 不必学习 \SpecialChar LaTeX +。\SpecialChar LyX + 的目标就是提供一个所见即所得的 \SpecialChar LaTeX + 应用。为了高效的使用 \SpecialChar LyX +,还是需要学习一些东西的 +。 +\end_layout + +\begin_layout Standard +你会发现在其它字处理软件中常用的排版方式在 \SpecialChar LyX + 中都不能使用了,比如:在“.”后边输入两个空格,在段间输入三个空行。你以前使用的软件允许手动调整间距、字体等东西,所 +以你不得不即录入又排版。\SpecialChar LyX +会做好排版的事情的,而你只需要转注于重要的东西:你正在写的内容。 +\end_layout + +\begin_layout Standard +继续读下去,了解更多 \SpecialChar LyX +。读完这篇教程,你会觉得物有所值的。 +\end_layout + +\begin_layout Section +本教程简介 +\end_layout + +\begin_layout Standard +在开始之前建议您先读一下 Introduction,那里解释了本文使用的注释方式。当你了解了各种字体的意义之后,我们先来说说本篇教程是干什么的。 +\end_layout + +\begin_layout Subsection +学习方式 +\end_layout + +\begin_layout Standard +本教程包含了例子和练习。学习中您应该试着输入我们让你输入的东西,完成所有练习,看看您是不是得到了正确的东西。为了方便,将本文档打印出来会是一个好选择。 +\end_layout + +\begin_layout Standard +如果对 \SpecialChar LaTeX + 比较熟悉的话,你将能够较快的阅读本教程,因为 \SpecialChar LyX + 的思想就是 \SpecialChar LaTeX + 思想的一种包装。\SpecialChar LyX + 自身也有很多特性是你想了解的。就算不想继续读下去,你也应该看看 + +\begin_inset CommandInset ref +LatexCommand ref +reference "sec:LaTeX-用户必读" + +\end_inset + +,它是专门写给熟练的 \SpecialChar LaTeX + 用户的。 +\end_layout + +\begin_layout Subsection +本教程没有的 +\end_layout + +\begin_layout Itemize +\SpecialChar LyX + 全部特性的详细解释。 +\end_layout + +\begin_deeper +\begin_layout Standard +需要的话,请阅读 the +\emph on +User's Guide。 +\end_layout + +\end_deeper +\begin_layout Itemize +\SpecialChar LaTeX + 的详细解释。 +\end_layout + +\begin_deeper +\begin_layout Standard +没必要这样做。要想知道用 \SpecialChar LaTeX + 在 \SpecialChar LyX + 中能做些什么,可以看看 the +\emph on +Embedded +\begin_inset space ~ +\end_inset + +Objects +\emph default + manual。 +\end_layout + +\end_deeper +\begin_layout Standard +现在是开始你的第一个文档的时候了。 +\end_layout + +\begin_layout Chapter +初识 \SpecialChar LyX + +\end_layout + +\begin_layout Section +第一个 \SpecialChar LyX + 文档 +\end_layout + +\begin_layout Standard +开始之前说几件事情,这会使本教程发挥更大的作用。 +\end_layout + +\begin_layout Standard +由于本教程不会提供所有信息,所以你需要找到其它的帮助文件。这很简单:启动 \SpecialChar LyX +,在帮助菜单中就有 the +\emph on +User's Guide。 +\shape italic +在写自己的文件时就可以读到它们了(它们本身就是很好的例子)。注意,当打开多个文件时,可以通过 View 菜单或文档标签进行切换。 +\end_layout + +\begin_layout Standard +我们假设你已经有了全功能的 \SpecialChar LyX + 和 \SpecialChar LaTeX +,包括 DVI、PDF 文件浏览器。一般来说,在各种操作系统上,在安装 \SpecialChar LyX + 的时候就已经做好了。 +\end_layout + +\begin_layout Standard +最后,我们提供了一个文件 +\family typewriter +example_raw.lyx, +\family default +给你练习使用。假想这个文件是由一个完全不知道 \SpecialChar LyX + 特性的人写的,在学习的过程中,我们会建议你修改这个文件的。example_raw.lyx 中也包含了修改的提示信息 +。为了对比,我们还提供了一份 \SpecialChar LyX + 高手写的同样内容的文档:example_lyxified.lyx。 +\end_layout + +\begin_layout Standard +示例文档存在于 \SpecialChar LyX + 安装路径的 examples 目录下。打开示例文档,另存到自己的目录下,修改后输出到 DVI 文件看效果。 +\end_layout + +\begin_layout Standard +另外,examples 目录中还有很多其它的示例文件,它们将向您展示 \SpecialChar LyX + 的强大功能。当你忘记了某个功能怎么使用的时候,也可以回来看看这些文档。 +\end_layout + +\begin_layout Subsection +录入、查看、输出 +\end_layout + +\begin_layout Itemize +使用菜单 +\family sans +File\SpecialChar menuseparator +New 打开新文件。 +\end_layout + +\begin_layout Itemize +输入一个句子: +\family typewriter +This is my first \SpecialChar LyX + document! +\end_layout + +\begin_layout Itemize +使用菜单 +\family sans +File\SpecialChar menuseparator +Save +\begin_inset space ~ +\end_inset + +As 保存文件。 +\end_layout + +\begin_layout Itemize +运行 \SpecialChar LaTeX + 生成 DVI 文件,使用菜单 +\family sans +Document\SpecialChar menuseparator +View +\family default + 或 工具栏按钮 +\begin_inset Info +type "icon" +arg "buffer-view" +\end_inset + +。 \SpecialChar LyX + 将打开 DVI-viewer 程序显示文档打印时的样子。 +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +保持 DVI-viewer在后台运行会节省时间。以后可以点击 +\family sans +Document\SpecialChar menuseparator +Update\SpecialChar menuseparator +DVI +\family default + 或工具栏按钮 +\begin_inset Info +type "icon" +arg "buffer-update" +\end_inset + +,等 \SpecialChar LyX + 运算完成后切换到 DVI-viewer即可。 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +使用菜单 +\family sans +File\SpecialChar menuseparator +Export +\family default + 将文档输出成希望的格式。 +\end_layout + +\begin_layout Standard +恭喜!你已经写出了第一个 \SpecialChar LyX + 文档。其余的细节,你会在其它手册中读到。 +\end_layout + +\begin_layout Subsection +简单操作 +\end_layout + +\begin_layout Standard +\SpecialChar LyX + 能够做到其它软件能做的绝大部分事情,如:自动换行、段落缩进……以下是几个简单操作的使用方法。 +\end_layout + +\begin_layout Description +撤消 \SpecialChar LyX + 有多级撤消功能,你可以使用 +\family sans +Edit\SpecialChar menuseparator +Undo +\family default + (或工具拦按钮 +\begin_inset Info +type "icon" +arg "undo" +\end_inset + +)来撤消本次编辑会话开始以来的所有操作。如果撤消过头了,可以选择 +\family sans +Edit\SpecialChar menuseparator +Redo +\family default + (或工具栏按钮 +\begin_inset Info +type "icon" +arg "redo" +\end_inset + +)恢复。 +\end_layout + +\begin_deeper +\begin_layout Standard +目前撤消操作支持100步,而且撤消也不是能够支持所有更改的,比如对文档布局的更改就不能被撤消,这的确是一个 bug。 +\end_layout + +\end_deeper +\begin_layout Description +剪切/粘贴/复制 使用 +\family sans +Edit\SpecialChar menuseparator +Cut +\family default + (工具栏按钮 +\begin_inset Info +type "icon" +arg "cut" +\end_inset + +), +\family sans +Edit\SpecialChar menuseparator +Copy +\family default + (工具栏按钮 +\begin_inset Info +type "icon" +arg "copy" +\end_inset + +),和 +\family sans +Edit\SpecialChar menuseparator +Paste +\family default + (工具栏按钮 +\begin_inset Info +type "icon" +arg "paste" +\end_inset + +) 来实现剪切、复制和粘贴操作。或者也可通过鼠标中键来粘贴选中的文本(包括其它程序中选定的文本)。 +\end_layout + +\begin_layout Description +查找/替换 点击 +\family sans +Edit\SpecialChar menuseparator +Find +\begin_inset space ~ +\end_inset + +& +\begin_inset space ~ +\end_inset + +Replace +\family default + (工具栏按钮 +\begin_inset Info +type "icon" +arg "dialog-show findreplace" +\end_inset + +) ,在出现的对话框中点击按钮“ +\family sans +Find +\begin_inset space ~ +\end_inset + +Next” +\family default + 进行搜索,点击按钮“ +\family sans +Replace”替换搜到的字词。 +\family default + +\begin_inset Foot +status open + +\begin_layout Plain Layout +完成后关闭窗口,如果觉得方便的话也可一直开着它。\SpecialChar LyX + 中的大部分窗口都可以这样。使用时注意焦点的切换即可。 +\end_layout + +\end_inset + + 你还可以指定区分大小写或全字匹配,当然也可以反向搜索文档。 +\end_layout + +\begin_layout Description +字符格式 用 +\family sans +Edit\SpecialChar menuseparator +Text +\begin_inset space ~ +\end_inset + +Style +\family default + 对话框中的 toggle buttons ,可以 +\shape italic +强调 +\shape default +(默认斜体)、加粗或设置为 +\noun on +无格式( +\noun default +字体一般较小,用于人名)。 +\end_layout + +\begin_layout Description +工具栏 菜单支边的工具栏提供了一些常用功能的按钮,例如:粘贴、打印。 +\end_layout + +\begin_layout Standard +当然,目前还没有输入足够多的内容以使所有这些功能可用。 +\end_layout + +\begin_layout Subsection +所见即所想:\SpecialChar LyX + 中的空白 +\end_layout + +\begin_layout Standard +对新用户来说,最难理解的是 \SpecialChar LyX + 处理空白的方式。敲多次回车只能得到一个空行;敲多次空格只能得到一个空格。在空白行上,连一个空格都无法得到。按下 Tab + 键也不会移动一个 Tab 位;实际上就没有 Tab 位!在页面上方也没有标尺可供设置 Tab 位和边距。 +\end_layout + +\begin_layout Standard +很多字处理软件建立在 WYSIWYG 理念之上,也就是:看到的就是得到的(所见即所得)。\SpecialChar LyX + 不同,它建立在 WYSIWYM (所想即所得)的理念之上。你想什么就输 +入什么,\SpecialChar LyX + 会处理排版的问题,这样保证了输出文件的美观。回车分段,空格断词,没理由在一行中输入好几次空格。Tab 根本就没有语法意义,所以 \SpecialChar LyX + 不支持它。使用 + \SpecialChar LyX +,你将花费更多的时间去考虑文档的 +\series bold +内容 +\series default +,而不是它的 +\series bold +格式 +\series default +。更多关于 WYSIWYM 的解释参见 +\emph on +Introduction。 +\end_layout + +\begin_layout Standard +\SpecialChar LyX + 的确也有不少精细调整文档格式的方法。毕竟 \SpecialChar LyX + 可能不会 100% 精确的按照你想的去排版。 +\emph on +User's Guide +\emph default + 包含了调整文档格式的详细方法,包括水平填充(HFills)和垂直距离(它们比空格、回车更加强大灵活);设置字体大小 、样式的方法;调整段落对齐方式的手段。你只 +需要专心写你的文档,在最后细调一下文档格式就好了。使用普通的字处理软件,你会在写文档的整个过程中都被格式排版所困扰。 +\begin_inset Foot +status open + +\begin_layout Plain Layout +译注:连 AbiWord 这样轻量级的字处理软件都有样式了,就不要说 MS Word、OOo 了。 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +环境 +\end_layout + +\begin_layout Standard +文档的不同部分有不同的作用,我们称这些部分为“环境”( +\emph on +environments +\emph default +)。标题告诉读者新的话题(子话题)将会开始。某些文档含有特殊的环境,比如:期刊会有摘要和题目;书信就没有摘要和题目,但它有地址。 +\end_layout + +\begin_layout Standard +环境是 \SpecialChar LyX + 所见即所得哲学的重要部分。一个环境需要具体的定义:字体大小、样式、缩进、行间距等等。这个问题非常重要,因为一个给定环境的具体定义会随着文档类型的变化而 +变化。比如:某期刊要求标题是黑体、18pt、居中,而另一个可能要求斜体、15pt、左对齐;不同的语言也有不同的缩进标准;参考文献的格式就变化更大了。\SpecialChar LyX + + 会把你从这些格式中间拯救出来。 +\end_layout + +\begin_layout Standard +你可以使用工具栏上的环境下拉菜单 +\begin_inset Graphics + filename ../../../lib/doc/clipart/ToolbarEnvBox.png + scale 50 + groupId In line + +\end_inset + +来选择环境,它也能告诉你当前的环境是什么,其中“Standard”是文本的默认环境。现在我们将在你的新文档中添加几个环境,来看看它们是怎么工作的吧。 +\end_layout + +\begin_layout Subsection +节( +\family sans +Section +\family default +)与子节(Subsection) +\end_layout + +\begin_layout Standard +在 \SpecialChar LyX + 文档的第一行输入“ +\family typewriter +Introduction +\family default +”,在环境下拉菜单中设为“节”( +\family sans +Section +\family default +) +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +设定环境不需要选择整行(段),光标停留其中即可。若想一次改变多行的环境,则需要选定之。 +\end_layout + +\end_inset + +, 确定你选择了“节”( +\family sans +Section +\family default +)而不是“节 +\family sans +* +\family default +”( +\family sans +Section* +\family default +)。\SpecialChar LyX + 将在前边加上“1”并把字体调大。现在敲回车,环境将从“节”( +\family sans +Section +\family default +)变回“标准”(Standard)。和多数环境类似,敲回车后环境将终止。输入文本: +\end_layout + +\begin_layout LyX-Code +This is an introduction to my first \SpecialChar LyX + document. +\end_layout + +\begin_layout Standard +再次回车,选择“节”( +\family sans +Section +\family default +)环境,\SpecialChar LyX + 将写上“2”并等待输入。现在输入“ +\family typewriter +More Stuff +\family default +”,\SpecialChar LyX + 会把它设置成节( +\family sans +Section +\family default +)标题的样式。 +\end_layout + +\begin_layout Standard +将光标定位到节 1 (Section +\begin_inset space ~ +\end_inset + +1)末尾,敲回车,再次设置为“节”( +\family sans +Section +\family default +),\SpecialChar LyX + 会写上“2”并等待输入。输入“ +\family typewriter +About This Document +\family default +”。刚才的节 2 (Section +\begin_inset space ~ +\end_inset + +2),“More Stuff”,现在已经被改成了节 3 (Section +\begin_inset space ~ +\end_inset + +3)。你只需要确定哪些文字是节( +\family sans +Section +\family default +)标题,\SpecialChar LyX + 会处理编号和排版格式的,这就是所见即所想(WYSIWYM)的风格。 +\end_layout + +\begin_layout Standard +敲回车,回到“标准”(Standard)环境,输入下边 5 行文字: +\end_layout + +\begin_layout LyX-Code +Sections and subsections are described below. +\end_layout + +\begin_layout LyX-Code +Section Description +\end_layout + +\begin_layout LyX-Code +Sections are bigger than subsections. +\end_layout + +\begin_layout LyX-Code +Subsection description +\end_layout + +\begin_layout LyX-Code +Subsections are smaller than sections. +\end_layout + +\begin_layout Standard +点击第二行,在环境下拉菜单中设为“子节”(Subsection)。\SpecialChar LyX + 将会在前边加上“2.1”,并把字体调整的比正文大,比节(Section)标题小。接着把第 + 4 行也设置成为“子节”(Subsection),\SpecialChar LyX + 将在它前边加上“2.2”。如果在节 2 (Section 2)前边加上了别的节,节 2 将会自动变为节 + 3(Section 3),后边的子节也会跟着变成“3.1”和“3.2”。 +\end_layout + +\begin_layout Standard +文档的层级结构还有次子节 ( Subsubsection )、段 ( Paragraph ) 和子段 ( Subparagraph ),这些就由读者自行把玩吧。 +段和子段的标题默认是不编号的,而且子段还有缩进,参阅 +\emph on +User's Guide +\emph default + 得到更多解释以及如何改变它们。章(Chapter)是文档层级结构中最高的一级,只能在某些特定的 \SpecialChar LyX + 文档类型中才能使用它(见 +\begin_inset CommandInset ref +LatexCommand ref +reference "sec:文档类" + +\end_inset + +)。 +\end_layout + +\begin_layout Standard +你可能还希望一些节和子节是不编号的,\SpecialChar LyX + 有专门的环境实现这个功能。当把节的标题环境改为“节* +\begin_inset Quotes erd +\end_inset + +(Section*)后,\SpecialChar LyX + 还将对它使用相同的字体,只是不再对它进行编号。相应的也有带“星”的子节和次子节环境。试着把一些节或子节的标题环境改为带星的,同时看看其 +它的编号怎么随之改变。 +\end_layout + +\begin_layout Standard +练习:修改 example_raw.lyx 中的节和子节标题。 +\end_layout + +\begin_layout Subsection +列表(Lists)和子列表(sublists) +\end_layout + +\begin_layout Standard +\SpecialChar LyX + 有好几种列表环境,在写提纲或者重新排序一个已有的列表时,这些列表环境会帮上大忙。不同的文档类型需要不同的列表环境: +\end_layout + +\begin_layout Itemize +幻灯片使用带圆点的条目环境( +\family sans +Itemize +\family default +)。 +\end_layout + +\begin_layout Itemize +大纲使用带编号的枚举环境( +\family sans +Enumerate +\family default +)。 +\end_layout + +\begin_layout Itemize +名词解释常用描述环境( +\family sans +Description +\family default +)。 +\end_layout + +\begin_layout Itemize +列表环境( +\family sans +List +\family default +)和描述环境( +\family sans +Description +\family default +)差不多,只是对齐方式稍有不同。 +\end_layout + +\begin_layout Standard +现在我们写一个 \SpecialChar LyX + 有关优点的列表。在文档中输入: +\end_layout + +\begin_layout Standard + +\family typewriter +\SpecialChar LyX + is better than other word processors because: +\end_layout + +\begin_layout Standard +然后敲回车,并在环境下拉列表中选择条目环境( +\family sans +Itemize +\family default +)。\SpecialChar LyX + 会在行首加上圆点。继续输入: +\end_layout + +\begin_layout LyX-Code +Typesetting is done for you. +\end_layout + +\begin_layout LyX-Code +Math is WYSIWYG +\end_layout + +\begin_layout LyX-Code +Lists are very easy to create! +\end_layout + +\begin_layout Standard +和标题不同,列表环境在敲回车时不会终止,\SpecialChar LyX + 会认为你将继续写下一个条目。所以上边的输入将会产生三个列表项。重新选择标准环境( +\family sans +Standard +\family default +)或使用快捷键 +\family sans +Alt+P +\begin_inset space ~ +\end_inset + +S +\family default + 才能退出列表环境。要在一个列表项中使用多个段落,可使用保护性中断( +\family sans +Protected +\begin_inset space ~ +\end_inset + +Break +\family default +),按下 Ctrl + 回车即可。 +\end_layout + +\begin_layout Standard +你已经得到了一个漂亮的条目列表,你是不是已经迫不及待的想运行 \SpecialChar LaTeX + 看看它们打印出来的样子了?可如果您想给它们加上编号呢?你只需要选定整个列表 +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +如果不连前边一段也一起选上的话,你是无法选上第一个条目前边的圆点的;类似的,你也无法选定章节编号。这是有意如此的,因为随着文档类型和文字位置的不同,这些圆点和编 +号也会发生变化。 +\end_layout + +\end_inset + +,然后选择枚举环境( +\family sans +Enumerate +\family default +)即可。如果你增删条目的话,\SpecialChar LyX + 会自动修改枚举编号的。 +\end_layout + +\begin_layout Standard +现在列表项还是处于被选定状态的,你可以再试试描述( +\family sans +Description +\family default +)和列表( +\family sans +List +\family default +)两种环境。这两种环境都是名词加定义的形式,描述环境前边的名词用黑体,列表环境的名词和后边的定义由“Tab” +\begin_inset Foot +status collapsed + +\begin_layout Plain Layout +这里的Tab是排版Tab(它会自适应到最长的名词长度),而不是定长的打字机Tab。 +\end_layout + +\end_inset + +分隔。前边的名词如果多于一个词的话,需要使用保护性空格( +\family sans +Protected +\begin_inset space ~ +\end_inset + +Blank +\family default +s)将它们分开。 +\end_layout + +\begin_layout Standard +练习:排版 +\family typewriter +example_raw.lyx +\family default + 中的列表。 +\end_layout + +\begin_layout Standard +这些列表环境还可以嵌套使用,提纲就是最常见的例子。带编号或圆点的列表在子列表中会有不同的表现形式。更多详情参见 +\emph on +User's Guide +\emph default + 。 +\end_layout + +\begin_layout Subsection +其它环境:诗、引用和更多 +\end_layout + +\begin_layout Standard +有两种引用环境:短一点的引用使用引用环境( +\family sans +Quote +\family default +);长一点的引用使用引文环境( +\family sans +Quotation +\family default +)。计算机代码使用代码环境( +\family sans +\SpecialChar LyX +-Code +\family default +),该环境使用 +\family typewriter +typewriter +\family default + 字体,而且这里是 \SpecialChar LyX + 中唯一允许使用多个空格的地方。你还可以使用诗环境( +\family sans +Verse +\family default +)来写诗:回车分节,Ctrl + 回车断行。对所有环境的完整描述参见 +\emph on + User's Guide +\emph default +。 +\end_layout + +\begin_layout Standard +练习:修改 +\family typewriter +example_raw.lyx +\family default + 中的引用、代码、诗环境。 +\end_layout + +\end_body +\end_document diff --git a/autotests/export/xhtml/zh_CN_Tutorial.xhtml b/autotests/export/xhtml/zh_CN_Tutorial.xhtml new file mode 100644 index 0000000000..5755eee0b6 --- /dev/null +++ b/autotests/export/xhtml/zh_CN_Tutorial.xhtml @@ -0,0 +1,256 @@ + + + + + + +The LyX Tutorial + + + +

The LyX Tutorial

+
+

第 1 章 介绍

+
+

欢迎来到 LyX!

+
这个文档是为那些不知道 LaTeX 或知之甚少的人准备的。不必担心,使用 LyX 不必学习 LaTeX。LyX 的目标就是提供一个所见即所得的 LaTeX 应用。为了高效的使用 LyX,还是需要学习一些东西的。
+ +
你会发现在其它字处理软件中常用的排版方式在 LyX 中都不能使用了,比如:在“.”后边输入两个空格,在段间输入三个空行。你以前使用的软件允许手动调整间距、字体等东西,所以你不得不即录入又排版。LyX会做好排版的事情的,而你只需要转注于重要的东西:你正在写的内容。
+ +
继续读下去,了解更多 LyX。读完这篇教程,你会觉得物有所值的。
+
+
+

本教程简介

+
在开始之前建议您先读一下 Introduction,那里解释了本文使用的注释方式。当你了解了各种字体的意义之后,我们先来说说本篇教程是干什么的。
+
+

1.2.1 学习方式

+
本教程包含了例子和练习。学习中您应该试着输入我们让你输入的东西,完成所有练习,看看您是不是得到了正确的东西。为了方便,将本文档打印出来会是一个好选择。
+ +
如果对 LaTeX 比较熟悉的话,你将能够较快的阅读本教程,因为 LyX 的思想就是 LaTeX 思想的一种包装。LyX 自身也有很多特性是你想了解的。就算不想继续读下去,你也应该看看 sec:LaTeX-用户必读,它是专门写给熟练的 LaTeX 用户的。
+
+
+

1.2.2 本教程没有的

+
    +
  • LyX 全部特性的详细解释。 +
    需要的话,请阅读 the User's Guide。
    +
  • LaTeX 的详细解释。 +
    没必要这样做。要想知道用 LaTeX 在 LyX 中能做些什么,可以看看 the Embedded Objects manual。
    +
+
现在是开始你的第一个文档的时候了。
+
+
+
+
+

第 2 章 初识 LyX

+
+

第一个 LyX 文档

+
开始之前说几件事情,这会使本教程发挥更大的作用。
+ +
由于本教程不会提供所有信息,所以你需要找到其它的帮助文件。这很简单:启动 LyX,在帮助菜单中就有 the User's Guide。在写自己的文件时就可以读到它们了(它们本身就是很好的例子)。注意,当打开多个文件时,可以通过 View 菜单或文档标签进行切换。
+ +
我们假设你已经有了全功能的 LyX 和 LaTeX,包括 DVI、PDF 文件浏览器。一般来说,在各种操作系统上,在安装 LyX 的时候就已经做好了。
+ +
最后,我们提供了一个文件 example_raw.lyx,给你练习使用。假想这个文件是由一个完全不知道 LyX 特性的人写的,在学习的过程中,我们会建议你修改这个文件的。example_raw.lyx 中也包含了修改的提示信息。为了对比,我们还提供了一份 LyX 高手写的同样内容的文档:example_lyxified.lyx。
+ +
示例文档存在于 LyX 安装路径的 examples 目录下。打开示例文档,另存到自己的目录下,修改后输出到 DVI 文件看效果。
+ +
另外,examples 目录中还有很多其它的示例文件,它们将向您展示 LyX 的强大功能。当你忘记了某个功能怎么使用的时候,也可以回来看看这些文档。
+
+

2.1.1 录入、查看、输出

+
    +
  • 使用菜单 File⇒New 打开新文件。
  • +
  • 输入一个句子: This is my first LyX document!
  • +
  • 使用菜单 File⇒Save As 保存文件。
  • +
  • 运行 LaTeX 生成 DVI 文件,使用菜单 Document⇒View 或 工具栏按钮 image: 。 LyX 将打开 DVI-viewer 程序显示文档打印时的样子。
    1
    保持 DVI-viewer在后台运行会节省时间。以后可以点击 Document⇒Update⇒DVI 或工具栏按钮 image: ,等 LyX 运算完成后切换到 DVI-viewer即可。
    +
  • +
  • 使用菜单 File⇒Export 将文档输出成希望的格式。
  • +
+
恭喜!你已经写出了第一个 LyX 文档。其余的细节,你会在其它手册中读到。
+
+
+

2.1.2 简单操作

+
LyX 能够做到其它软件能做的绝大部分事情,如:自动换行、段落缩进……以下是几个简单操作的使用方法。
+
+
撤消
+
LyX 有多级撤消功能,你可以使用 Edit⇒Undo (或工具拦按钮 image: )来撤消本次编辑会话开始以来的所有操作。如果撤消过头了,可以选择 Edit⇒Redo (或工具栏按钮 image: )恢复。 +
目前撤消操作支持100步,而且撤消也不是能够支持所有更改的,比如对文档布局的更改就不能被撤消,这的确是一个 bug。
+
剪切/粘贴/复制
+
使用 Edit⇒Cut (工具栏按钮 image: ), Edit⇒Copy (工具栏按钮 image: ),和 Edit⇒Paste (工具栏按钮 image: ) 来实现剪切、复制和粘贴操作。或者也可通过鼠标中键来粘贴选中的文本(包括其它程序中选定的文本)。
+
查找/替换
+
点击 Edit⇒Find & Replace (工具栏按钮 image: ) ,在出现的对话框中点击按钮“Find Next” 进行搜索,点击按钮“ Replace”替换搜到的字词。
2
完成后关闭窗口,如果觉得方便的话也可一直开着它。LyX 中的大部分窗口都可以这样。使用时注意焦点的切换即可。
+
你还可以指定区分大小写或全字匹配,当然也可以反向搜索文档。
+
字符格式
+
Edit⇒Text Style 对话框中的 toggle buttons ,可以强调(默认斜体)、加粗或设置为无格式(字体一般较小,用于人名)。
+
工具栏
+
菜单支边的工具栏提供了一些常用功能的按钮,例如:粘贴、打印。
+
+
当然,目前还没有输入足够多的内容以使所有这些功能可用。
+
+
+

2.1.3 所见即所想:LyX 中的空白

+
对新用户来说,最难理解的是 LyX 处理空白的方式。敲多次回车只能得到一个空行;敲多次空格只能得到一个空格。在空白行上,连一个空格都无法得到。按下 Tab 键也不会移动一个 Tab 位;实际上就没有 Tab 位!在页面上方也没有标尺可供设置 Tab 位和边距。
+ +
很多字处理软件建立在 WYSIWYG 理念之上,也就是:看到的就是得到的(所见即所得)。LyX 不同,它建立在 WYSIWYM (所想即所得)的理念之上。你想什么就输入什么,LyX 会处理排版的问题,这样保证了输出文件的美观。回车分段,空格断词,没理由在一行中输入好几次空格。Tab 根本就没有语法意义,所以 LyX 不支持它。使用 LyX,你将花费更多的时间去考虑文档的内容,而不是它的格式。更多关于 WYSIWYM 的解释参见 Introduction。
+ +
LyX 的确也有不少精细调整文档格式的方法。毕竟 LyX 可能不会 100% 精确的按照你想的去排版。User's Guide 包含了调整文档格式的详细方法,包括水平填充(HFills)和垂直距离(它们比空格、回车更加强大灵活);设置字体大小 、样式的方法;调整段落对齐方式的手段。你只需要专心写你的文档,在最后细调一下文档格式就好了。使用普通的字处理软件,你会在写文档的整个过程中都被格式排版所困扰。
3
译注:连 AbiWord 这样轻量级的字处理软件都有样式了,就不要说 MS Word、OOo 了。
+
+
+
+
+

环境

+
文档的不同部分有不同的作用,我们称这些部分为“环境”(environments)。标题告诉读者新的话题(子话题)将会开始。某些文档含有特殊的环境,比如:期刊会有摘要和题目;书信就没有摘要和题目,但它有地址。
+ +
环境是 LyX 所见即所得哲学的重要部分。一个环境需要具体的定义:字体大小、样式、缩进、行间距等等。这个问题非常重要,因为一个给定环境的具体定义会随着文档类型的变化而变化。比如:某期刊要求标题是黑体、18pt、居中,而另一个可能要求斜体、15pt、左对齐;不同的语言也有不同的缩进标准;参考文献的格式就变化更大了。LyX 会把你从这些格式中间拯救出来。
+ +
你可以使用工具栏上的环境下拉菜单image: 59dc5fa2c4be2dbbd812749fb08fd5394d0b655a4cf83a012745159aab4ec6af_ToolbarEnvBox_png.png来选择环境,它也能告诉你当前的环境是什么,其中“Standard”是文本的默认环境。现在我们将在你的新文档中添加几个环境,来看看它们是怎么工作的吧。
+
+

2.2.1 节(Section)与子节(Subsection)

+
在 LyX 文档的第一行输入“Introduction”,在环境下拉菜单中设为“节”(Section
4
设定环境不需要选择整行(段),光标停留其中即可。若想一次改变多行的环境,则需要选定之。
+
, 确定你选择了“节”(Section)而不是“节*”(Section*)。LyX 将在前边加上“1”并把字体调大。现在敲回车,环境将从“节”(Section)变回“标准”(Standard)。和多数环境类似,敲回车后环境将终止。输入文本:
+
+
This is an introduction to my first LyX document.
+
+
再次回车,选择“节”(Section)环境,LyX 将写上“2”并等待输入。现在输入“More Stuff”,LyX 会把它设置成节(Section)标题的样式。
+ +
将光标定位到节 1 (Section 1)末尾,敲回车,再次设置为“节”(Section),LyX 会写上“2”并等待输入。输入“About This Document”。刚才的节 2 (Section 2),“More Stuff”,现在已经被改成了节 3 (Section 3)。你只需要确定哪些文字是节(Section)标题,LyX 会处理编号和排版格式的,这就是所见即所想(WYSIWYM)的风格。
+ +
敲回车,回到“标准”(Standard)环境,输入下边 5 行文字:
+
+
Sections and subsections are described below.
+
Section Description
+
Sections are bigger than subsections.
+
Subsection description
+
Subsections are smaller than sections.
+
+
点击第二行,在环境下拉菜单中设为“子节”(Subsection)。LyX 将会在前边加上“2.1”,并把字体调整的比正文大,比节(Section)标题小。接着把第 4 行也设置成为“子节”(Subsection),LyX 将在它前边加上“2.2”。如果在节 2 (Section 2)前边加上了别的节,节 2 将会自动变为节 3(Section 3),后边的子节也会跟着变成“3.1”和“3.2”。
+ +
文档的层级结构还有次子节 ( Subsubsection )、段 ( Paragraph ) 和子段 ( Subparagraph ),这些就由读者自行把玩吧。段和子段的标题默认是不编号的,而且子段还有缩进,参阅 User's Guide 得到更多解释以及如何改变它们。章(Chapter)是文档层级结构中最高的一级,只能在某些特定的 LyX 文档类型中才能使用它(见 sec:文档类)。
+ +
你可能还希望一些节和子节是不编号的,LyX 有专门的环境实现这个功能。当把节的标题环境改为“节*”(Section*)后,LyX 还将对它使用相同的字体,只是不再对它进行编号。相应的也有带“星”的子节和次子节环境。试着把一些节或子节的标题环境改为带星的,同时看看其它的编号怎么随之改变。
+ +
练习:修改 example_raw.lyx 中的节和子节标题。
+
+
+

2.2.2 列表(Lists)和子列表(sublists)

+
LyX 有好几种列表环境,在写提纲或者重新排序一个已有的列表时,这些列表环境会帮上大忙。不同的文档类型需要不同的列表环境:
+
    +
  • 幻灯片使用带圆点的条目环境(Itemize)。
  • +
  • 大纲使用带编号的枚举环境(Enumerate)。
  • +
  • 名词解释常用描述环境(Description)。
  • +
  • 列表环境(List)和描述环境(Description)差不多,只是对齐方式稍有不同。
  • +
+
现在我们写一个 LyX 有关优点的列表。在文档中输入:
+ +
LyX is better than other word processors because:
+ +
然后敲回车,并在环境下拉列表中选择条目环境(Itemize)。LyX 会在行首加上圆点。继续输入:
+
+
Typesetting is done for you.
+
Math is WYSIWYG
+
Lists are very easy to create!
+
+
和标题不同,列表环境在敲回车时不会终止,LyX 会认为你将继续写下一个条目。所以上边的输入将会产生三个列表项。重新选择标准环境(Standard)或使用快捷键 Alt+P S 才能退出列表环境。要在一个列表项中使用多个段落,可使用保护性中断(Protected Break),按下 Ctrl + 回车即可。
+ +
你已经得到了一个漂亮的条目列表,你是不是已经迫不及待的想运行 LaTeX 看看它们打印出来的样子了?可如果您想给它们加上编号呢?你只需要选定整个列表
5
如果不连前边一段也一起选上的话,你是无法选上第一个条目前边的圆点的;类似的,你也无法选定章节编号。这是有意如此的,因为随着文档类型和文字位置的不同,这些圆点和编号也会发生变化。
+
,然后选择枚举环境(Enumerate)即可。如果你增删条目的话,LyX 会自动修改枚举编号的。
+ +
现在列表项还是处于被选定状态的,你可以再试试描述(Description)和列表(List)两种环境。这两种环境都是名词加定义的形式,描述环境前边的名词用黑体,列表环境的名词和后边的定义由“Tab”
6
这里的Tab是排版Tab(它会自适应到最长的名词长度),而不是定长的打字机Tab。
+
分隔。前边的名词如果多于一个词的话,需要使用保护性空格(Protected Blanks)将它们分开。
+ +
练习:排版 example_raw.lyx 中的列表。
+ +
这些列表环境还可以嵌套使用,提纲就是最常见的例子。带编号或圆点的列表在子列表中会有不同的表现形式。更多详情参见 User's Guide
+
+
+

2.2.3 其它环境:诗、引用和更多

+
有两种引用环境:短一点的引用使用引用环境(Quote);长一点的引用使用引文环境(Quotation)。计算机代码使用代码环境(LyX-Code),该环境使用typewriter 字体,而且这里是 LyX 中唯一允许使用多个空格的地方。你还可以使用诗环境(Verse)来写诗:回车分节,Ctrl + 回车断行。对所有环境的完整描述参见 User's Guide
+ +
练习:修改 example_raw.lyx 中的引用、代码、诗环境。
+
+
+
+ + diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index fe396f83d8..0174339340 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -35,6 +35,7 @@ #include "support/textutils.h" #include +#include // Uncomment to activate debugging code. // #define XHTML_DEBUG @@ -610,6 +611,8 @@ void xhtmlParagraphs(Text const & text, ParagraphList::const_iterator send; // Think about adding
and/or
s. + // Document title is not in Sectioning, but rather in FrontMatter, so that it does not need to be taken + // into account. if (style.category() == from_utf8("Sectioning")) { int level = style.toclevel; @@ -620,7 +623,7 @@ void xhtmlParagraphs(Text const & text, while (!headerLevels.empty() && level <= headerLevels.top()) { // Output the tag only if it corresponds to a legit section. int stackLevel = headerLevels.top(); - if (stackLevel != Layout::NOT_IN_TOC && level > 1) { //

is the document title. + if (stackLevel != Layout::NOT_IN_TOC) { xs << xml::EndTag("section"); xs << xml::CR(); } @@ -630,7 +633,7 @@ void xhtmlParagraphs(Text const & text, // Open the new section: first push it onto the stack, then output it in XHTML. headerLevels.push(level); // Some sectioning-like elements should not be output (such as FrontMatter). - if (level != Layout::NOT_IN_TOC && level > 1) { //

is the document title. + if (level != Layout::NOT_IN_TOC ) { xs << xml::StartTag("section"); xs << xml::CR(); } @@ -675,7 +678,7 @@ void xhtmlParagraphs(Text const & text, // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning // of the loop). - while (!headerLevels.empty() && headerLevels.top() != Layout::NOT_IN_TOC && headerLevels.top() > 1) { + while (!headerLevels.empty() && headerLevels.top() != Layout::NOT_IN_TOC) { docstring tag = from_utf8("
"); headerLevels.pop(); xs << XMLStream::ESCAPE_NONE << tag; From c83fd0eb069564710943ba308e484f937ac5bd4c Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 19 Sep 2020 04:26:06 +0200 Subject: [PATCH 87/88] XHTML sections: saner code to close the section. It only caused troubles in corner cases... --- autotests/export/xhtml/A0_Poster_Simple.lyx | 192 ++++++++++++++++++ autotests/export/xhtml/A0_Poster_Simple.xhtml | 59 ++++++ src/output_xhtml.cpp | 3 +- 3 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 autotests/export/xhtml/A0_Poster_Simple.lyx create mode 100644 autotests/export/xhtml/A0_Poster_Simple.xhtml diff --git a/autotests/export/xhtml/A0_Poster_Simple.lyx b/autotests/export/xhtml/A0_Poster_Simple.lyx new file mode 100644 index 0000000000..998f210ca7 --- /dev/null +++ b/autotests/export/xhtml/A0_Poster_Simple.lyx @@ -0,0 +1,192 @@ +#LyX 2.4 created this file. For more info see https://www.lyx.org/ +\lyxformat 598 +\begin_document +\begin_header +\save_transient_properties true +\origin unavailable +\textclass a0poster +\begin_preamble +% Adjust padding in boxes +\setlength\fboxsep{12pt} +% Added by lyx2lyx +\setlength{\parskip}{\bigskipamount} +\setlength{\parindent}{0pt} +\end_preamble +\options a0,portrait +\use_default_options false +\maintain_unincluded_children no +\language english +\language_package default +\inputencoding utf8 +\fontencoding auto +\font_roman "palatino" "default" +\font_sans "default" "default" +\font_typewriter "courier" "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 1 +\use_package esint 1 +\use_package mathdots 1 +\use_package mathtools 1 +\use_package mhchem 1 +\use_package stackrel 1 +\use_package stmaryrd 1 +\use_package undertilde 1 +\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 0 +\use_minted 0 +\use_lineno 0 +\index Index +\shortcut idx +\color #008000 +\end_index +\leftmargin 1cm +\topmargin 1cm +\rightmargin 1cm +\bottommargin 1cm +\secnumdepth 0 +\tocdepth 0 +\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 empty +\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 Standard +\align center +\begin_inset Box Shadowbox +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 1 +use_makebox 0 +width "98col%" +special "none" +height "5cm" +height_special "none" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Plain Layout +\noindent +\align center + +\series bold +\noun on +\begin_inset Flex Most Giant Snippet +status open + +\begin_layout Plain Layout +\noindent + +\series bold +\noun on +Poster Heading +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +\begin_inset Box Boxed +position "t" +hor_pos "c" +has_inner_box 1 +inner_pos "t" +use_parbox 0 +use_makebox 0 +width "98col%" +special "none" +height "1in" +height_special "totalheight" +thickness "0.4pt" +separation "3pt" +shadowsize "4pt" +framecolor "black" +backgroundcolor "none" +status open + +\begin_layout Section +Summary +\end_layout + +\begin_layout Itemize +For multiple columns, use the +\begin_inset Quotes eld +\end_inset + +Multiple Columns +\begin_inset Quotes erd +\end_inset + + module as documented in +\family sans +Help\SpecialChar menuseparator +Additional Features +\family default +. +\end_layout + +\end_inset + + +\end_layout + +\end_body +\end_document diff --git a/autotests/export/xhtml/A0_Poster_Simple.xhtml b/autotests/export/xhtml/A0_Poster_Simple.xhtml new file mode 100644 index 0000000000..032aa328e9 --- /dev/null +++ b/autotests/export/xhtml/A0_Poster_Simple.xhtml @@ -0,0 +1,59 @@ + + + + + + +LyX Document + + + +
Poster Heading
+
+ +
+

Summary

+
    +
  • For multiple columns, use the “Multiple Columns” module as documented in Help⇒Additional Features.
  • +
+
+
+ + diff --git a/src/output_xhtml.cpp b/src/output_xhtml.cpp index 0174339340..d428761b10 100644 --- a/src/output_xhtml.cpp +++ b/src/output_xhtml.cpp @@ -679,9 +679,8 @@ void xhtmlParagraphs(Text const & text, // If need be, close
s, but only at the end of the document (otherwise, dealt with at the beginning // of the loop). while (!headerLevels.empty() && headerLevels.top() != Layout::NOT_IN_TOC) { - docstring tag = from_utf8("
"); headerLevels.pop(); - xs << XMLStream::ESCAPE_NONE << tag; + xs << xml::EndTag("section"); xs << xml::CR(); } } From b5adcec28aac69e722e8b2bbf28ad2974010f853 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Sat, 19 Sep 2020 17:26:17 +0200 Subject: [PATCH 88/88] XHTML: fix for encodings in attributes (patch by Kornel) --- src/xml.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xml.h b/src/xml.h index d5b42332ca..857867ba90 100644 --- a/src/xml.h +++ b/src/xml.h @@ -184,7 +184,7 @@ struct StartTag /// explicit StartTag(std::string const & tag, std::string const & attr, bool keepempty = false) - : tag_(from_ascii(tag)), attr_(from_ascii(attr)), keepempty_(keepempty) {} + : tag_(from_ascii(tag)), attr_(from_utf8(attr)), keepempty_(keepempty) {} /// explicit StartTag(std::string const & tag, docstring const & attr, bool keepempty = false)