Revert "DocBook: use DocBookWrapperMergeWithPrevious in the code."

This reverts commit 62c9f4332d.
This commit is contained in:
Thibaut Cuvelier 2020-08-03 22:56:25 +02:00
parent c2be69187c
commit 4c01ab9ecf
3 changed files with 48 additions and 132 deletions

View File

@ -4,27 +4,23 @@
<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"> <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> <info>
<title>Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples</title> <title>Collapsed Cores in Globular Clusters, Gauge-Boson Couplings, and AASTeX Examples</title>
<author><personname>S. Djorgovski and Ivan R. King</personname> <author><personname>S. Djorgovski and Ivan R. King</personname></author>
<affiliation><orgname>Astronomy Department, University of California, Berkeley, CA 94720</orgname></affiliation> <author><affiliation><orgname>Astronomy Department, University of California, Berkeley, CA 94720</orgname></affiliation></author>
<affiliation role="alternate"><orgname>Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation.</orgname></affiliation> <author><affiliation role="alternate"><orgname>Visiting Astronomer Cerro Tololo Inter-American Observatory.CTIO is operated by AURA Inc. under contract to the National Science Foundation.</orgname></affiliation></author>
<affiliation role="alternate"><orgname>Society of Fellows, Harvard University.</orgname></affiliation> <author><affiliation role="alternate"><orgname>Society of Fellows, Harvard University.</orgname></affiliation></author>
<affiliation role="alternate"><orgname>present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138</orgname></affiliation></author> <author><affiliation role="alternate"><orgname>present address: Center for Astrophysics60 Garden Street, Cambridge, MA 02138</orgname></affiliation></author>
<author><personname>C. D. Biemesderfer</personname> <author><personname>C. D. Biemesderfer</personname></author>
<affiliation><orgname>National Optical Astronomy Observatories, Tucson, AZ 85719</orgname></affiliation> <author><affiliation><orgname>National Optical Astronomy Observatories, Tucson, AZ 85719</orgname></affiliation></author>
<affiliation role="alternate"><orgname>Visiting Programmer, Space Telescope Science Institute</orgname></affiliation> <author><affiliation role="alternate"><orgname>Visiting Programmer, Space Telescope Science Institute</orgname></affiliation></author>
<affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation> <author><affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation></author>
<email>aastex-help@aas.org</email></author> <author><email>aastex-help@aas.org</email></author>
<author><personname>R. J. Hanisch</personname> <author><personname>R. J. Hanisch</personname></author>
<affiliation><orgname>Space Telescope Science Institute, Baltimore, MD 21218</orgname></affiliation> <author><affiliation><orgname>Space Telescope Science Institute, Baltimore, MD 21218</orgname></affiliation></author>
<affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation></author> <author><affiliation role="alternate"><orgname>Patron, Alonso's Bar and Grill</orgname></affiliation></author>
<abstract><para> <abstract><para>
<para>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. </para> <para>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. </para>
<!-- Output Error: Tried to close `Keywords' when tag was not open. Tag discarded. --> </para></abstract>
</info>
<!-- Output Error: Closing tag `info' when other tags are open, namely: -->
<!-- Output Error: para -->
</para><!-- Output Error: abstract -->
</abstract></info>
<section> <section>
<title>Introduction</title> <title>Introduction</title>
<para>A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades <biblioref endterm="hen61" />, <biblioref endterm="lyn68" />, <biblioref endterm="spi85" />, but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 <biblioref endterm="kin75" />, <biblioref endterm="new78" /> seemed a unique anomaly. Then <biblioref endterm="aur82" /> suggested a central peak in NGC 6397, and a limited photographic survey of ours <biblioref endterm="djo84" /> found three more cases, including NGC 6624, whose sharp center had often been remarked on <biblioref endterm="can78" />. </para> <para>A focal problem today in the dynamics of globular clusters is core collapse. It has been predicted by theory for decades <biblioref endterm="hen61" />, <biblioref endterm="lyn68" />, <biblioref endterm="spi85" />, but observation has been less alert to the phenomenon. For many years the central brightness peak in M15 <biblioref endterm="kin75" />, <biblioref endterm="new78" /> seemed a unique anomaly. Then <biblioref endterm="aur82" /> suggested a central peak in NGC 6397, and a limited photographic survey of ours <biblioref endterm="djo84" /> found three more cases, including NGC 6624, whose sharp center had often been remarked on <biblioref endterm="can78" />. </para>
@ -692,8 +688,7 @@ v(p,\lambda)_{\pm} &amp; = &amp; \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
</m:mtable> </m:mtable>
</m:math> </m:math>
</informalequation> </informalequation>
<!-- Output Error: Tried to close `title' when tag was not open. Tag discarded. --> </MathLetters>
</section> </section>
</section> </section>
<section> <section>
@ -969,9 +964,8 @@ v(p,\lambda)_{\pm} &amp; = &amp; \pm\lambda(E\mp\lambda|{\textbf{p}}|)^{1/2}\chi
</m:mrow> </m:mrow>
</m:math> </m:math>
</inlineequation> of the electronically submitted abstracts for AAS meetings are error-free. </para> </inlineequation> of the electronically submitted abstracts for AAS meetings are error-free. </para>
<acknowledgement><para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex">http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para> <acknowledgement><para>We are grateful to V. Barger, T. Han, and R. J. N. Phillips for doing the math in section&#xA0;<xref linkend="bozomath" />. More information on the AASTeX macros package are available at <link xlink:href="http://www.aas.org/publications/aastex">http://www.aas.org/publications/aastex</link> or the <link xlink:href="ftp://www.aas.org/pubs/AAS ftp site">AAS ftp site</link>.</para></acknowledgement>
<application>IRAF, AIPS, Astropy, ...</application><!-- Output Error: Tried to close `para' when tag was not open. Tag discarded. --> <para><application>IRAF, AIPS, Astropy, ...</application></para>
<Appendix></Appendix> <Appendix></Appendix>
<bibliography> <bibliography>
<bibliomixed xml:id='aur82'>Aurière, M. 1982, <!-- \aap -->, 109, 301 </bibliomixed> <bibliomixed xml:id='aur82'>Aurière, M. 1982, <!-- \aap -->, 109, 301 </bibliomixed>

View File

@ -175,11 +175,10 @@ Style Affiliation
Family Roman Family Roman
Size Normal Size Normal
EndFont EndFont
DocBookTag affiliation DocBookTag affiliation
DocBookWrapperTag author DocBookWrapperTag author
DocBookWrapperMergeWithPrevious true DocBookItemTag orgname
DocBookItemTag orgname DocBookInInfo always
DocBookInInfo always
End End
@ -202,12 +201,11 @@ Style Altaffilation
LabelFont LabelFont
Color green Color green
EndFont EndFont
DocBookTag affiliation DocBookTag affiliation
DocBookAttr role="alternate" DocBookAttr role="alternate"
DocBookWrapperTag author DocBookItemTag orgname
DocBookWrapperMergeWithPrevious true DocBookWrapperTag author
DocBookItemTag orgname DocBookInInfo always
DocBookInInfo always
End End
@ -227,10 +225,9 @@ Style Email
Size Normal Size Normal
Shape Italic Shape Italic
EndFont EndFont
DocBookTag email DocBookTag email
DocBookWrapperTag author DocBookWrapperTag author
DocBookWrapperMergeWithPrevious true DocBookInInfo always
DocBookInInfo always
End End

View File

@ -189,34 +189,11 @@ namespace {
// convenience functions // convenience functions
void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar) void openParTag(XMLStream & xs, Paragraph const & par)
{ {
Layout const & lay = par->layout(); Layout const & lay = par.layout();
if (par == prevpar) if (lay.docbookwrappertag() != "NONE")
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 <author> tag (different
// layout, same wrapper tag).
bool openWrapper = false;
if (prevpar == nullptr) {
openWrapper = lay.docbookwrappertag() != "NONE";
} else {
Layout const & prevlay = prevpar->layout();
if (prevlay.docbookwrappertag() == "NONE") {
openWrapper = lay.docbookwrappertag() != "NONE";
} else {
openWrapper = prevlay.docbookwrappertag() == lay.docbookwrappertag()
&& !lay.docbookwrappermergewithprevious();
}
}
// Main logic.
if (openWrapper)
xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr()); xs << xml::StartTag(lay.docbookwrappertag(), lay.docbookwrapperattr());
string tag = lay.docbooktag(); string tag = lay.docbooktag();
@ -230,28 +207,10 @@ void openParTag(XMLStream & xs, const Paragraph * par, const Paragraph * prevpar
} }
void closeTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar) void closeTag(XMLStream & xs, Paragraph const & par)
{ {
Layout const & lay = par->layout(); Layout const & lay = par.layout();
if (par == nextpar)
nextpar = nullptr;
// See comment in openParTag.
bool closeWrapper = false;
if (nextpar == nullptr) {
closeWrapper = lay.docbookwrappertag() != "NONE";
} else {
Layout const & nextlay = nextpar->layout();
if (nextlay.docbookwrappertag() == "NONE") {
closeWrapper = lay.docbookwrappertag() != "NONE";
} else {
closeWrapper = nextlay.docbookwrappertag() == lay.docbookwrappertag()
&& !nextlay.docbookwrappermergewithprevious();
}
}
// Main logic.
if (lay.docbookitemtag() != "NONE") if (lay.docbookitemtag() != "NONE")
xs << xml::EndTag(lay.docbookitemtag()); xs << xml::EndTag(lay.docbookitemtag());
@ -260,7 +219,7 @@ void closeTag(XMLStream & xs, Paragraph const * par, Paragraph const * nextpar)
tag = "para"; tag = "para";
xs << xml::EndTag(tag); xs << xml::EndTag(tag);
if (closeWrapper) if (lay.docbookwrappertag() != "NONE")
xs << xml::EndTag(lay.docbookwrappertag()); xs << xml::EndTag(lay.docbookwrappertag());
} }
@ -440,12 +399,9 @@ ParagraphList::const_iterator makeParagraphs(
ParagraphList::const_iterator const & pbegin, ParagraphList::const_iterator const & pbegin,
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
{ {
auto const begin = text.paragraphs().begin(); ParagraphList::const_iterator const begin = text.paragraphs().begin();
auto const end = text.paragraphs().end();
ParagraphList::const_iterator par = pbegin; ParagraphList::const_iterator par = pbegin;
ParagraphList::const_iterator prevpar = pbegin; for (; par != pend; ++par) {
for (; par != pend; prevpar = par, ++par) {
// We want to open the paragraph tag if: // We want to open the paragraph tag if:
// (i) the current layout permits multiple paragraphs // (i) the current layout permits multiple paragraphs
// (ii) we are either not already inside a paragraph (HTMLIsBlock) OR // (ii) we are either not already inside a paragraph (HTMLIsBlock) OR
@ -461,7 +417,7 @@ ParagraphList::const_iterator makeParagraphs(
// because of branches, e.g., a branch that contains an entire new section. // 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 <div>...</div>. // We do not really want to wrap that whole thing in a <div>...</div>.
bool special_case = false; bool special_case = false;
Inset const *specinset = par->size() == 1 ? par->getInset(0) : nullptr; Inset const *specinset = par->size() == 1 ? par->getInset(0) : 0;
if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter? if (specinset && !specinset->getLayout().htmlisblock()) { // TODO: Convert htmlisblock to a DocBook parameter?
Layout const &style = par->layout(); Layout const &style = par->layout();
FontInfo const first_font = style.labeltype == LABEL_MANUAL ? FontInfo const first_font = style.labeltype == LABEL_MANUAL ?
@ -510,7 +466,7 @@ ParagraphList::const_iterator makeParagraphs(
// or we're not in the last paragraph, anyway. // or we're not in the last paragraph, anyway.
// (ii) We didn't open it and docbook_in_par is true, // (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. // but we are in the first par, and there is a next par.
auto nextpar = par; ParagraphList::const_iterator nextpar = par;
++nextpar; ++nextpar;
bool const close_par = bool const close_par =
((open_par && (!runparams.docbook_in_par || nextpar != pend)) ((open_par && (!runparams.docbook_in_par || nextpar != pend))
@ -528,12 +484,12 @@ ParagraphList::const_iterator makeParagraphs(
if (!cleaned.empty()) { if (!cleaned.empty()) {
if (open_par) if (open_par)
openParTag(xs, &*par, &*prevpar); openParTag(xs, *par);
xs << XMLStream::ESCAPE_NONE << os2.str(); xs << XMLStream::ESCAPE_NONE << os2.str();
if (close_par) { if (close_par) {
closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr); closeTag(xs, *par);
xs << xml::CR(); xs << xml::CR();
} }
} }
@ -558,24 +514,11 @@ ParagraphList::const_iterator makeEnvironment(
ParagraphList::const_iterator const & pend) ParagraphList::const_iterator const & pend)
{ {
auto const begin = text.paragraphs().begin(); auto const begin = text.paragraphs().begin();
auto const end = text.paragraphs().end();
ParagraphList::const_iterator par = pbegin; ParagraphList::const_iterator par = pbegin;
depth_type const origdepth = pbegin->params().depth(); 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 // open tag for this environment
openParTag(xs, &*par, &*prevpar); openParTag(xs, *par);
xs << xml::CR(); xs << xml::CR();
// we will on occasion need to remember a layout from before. // we will on occasion need to remember a layout from before.
@ -729,9 +672,7 @@ ParagraphList::const_iterator makeEnvironment(
xs << xml::CR(); xs << xml::CR();
} }
} }
auto nextpar = par; closeTag(xs, *par);
++nextpar;
closeTag(xs, &*par, (nextpar != end) ? &*nextpar : nullptr);
xs << xml::CR(); xs << xml::CR();
return pend; return pend;
} }
@ -745,30 +686,14 @@ void makeCommand(
ParagraphList::const_iterator const & pbegin) ParagraphList::const_iterator const & pbegin)
{ {
// No need for labels, as they are handled by DocBook tags. // No need for labels, as they are handled by DocBook tags.
openParTag(xs, *pbegin);
auto const begin = text.paragraphs().begin(); 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, pbegin->simpleDocBookOnePar(buf, xs, runparams,
text.outerFont(distance(begin, pbegin))); text.outerFont(distance(begin, pbegin)));
closeTag(xs, &*pbegin, (nextpar != end) ? &*nextpar : nullptr); closeTag(xs, *pbegin);
xs << xml::CR(); xs << xml::CR();
} }