Fix the <pre> block workaround in doxygen2boostbook.xsl

It turns out the '\code' blocks don't have this problem, so an easier
fix would be just to use them. But now I've implemented the workaround,
might as well leave it in, in case anyone wants to use <pre> blocks in
the future.
This commit is contained in:
Daniel James 2016-01-13 19:33:09 +00:00
parent 30911053b5
commit f1aef5c98e
3 changed files with 47 additions and 5 deletions

View File

@ -63,8 +63,22 @@ Embedded docbook list:</para><para>
<listitem><para>Second list item</para></listitem>
</itemizedlist>
Line 1<sbr/>
Line 2</para><para><programlisting language="c++">void foo() {}
</programlisting></para><para>
Line 2</para><para><programlisting language="c++">void foo() {}
void foo2() {}
</programlisting></para><para><programlisting language="c++">void bar() {}
void bar2() {}
</programlisting></para><para>Alternative way of writing code, has a complicated workaround because doxygen treats the empty line as a paragraph separator:</para><programlisting>
int bar();
int bar2();
</programlisting><para>Unfortunately the workaround will merge consecutive blocks, like this:</para><programlisting>
int foo();
int foo2();
</programlisting><para>
</para></description></struct><struct name="specialization_test"><template>
<template-type-parameter name="T"/>
</template></struct><struct-specialization name="specialization_test"><template>

View File

@ -153,8 +153,36 @@ namespace example
*
* \code
* void foo() {}
* void foo2() {}
* \endcode
*
* \code
* void bar() {}
*
* void bar2() {}
* \endcode
*
* Alternative way of writing code, has a complicated workaround
* because doxygen treats the empty line as a paragraph
* separator:
*
* <pre>
* int bar();
*
* int bar2();
* </pre>
*
* Unfortunately the workaround will merge consecutive blocks,
* like this:
*
* <pre>
* int foo();
* </pre>
*
* <pre>
* int foo2();
* </pre>
*
* \tparam TypeParameter A template parameter
* \tparam NonTypeParameter This is a non-type template parameter
* \tparam TypeParameterWithDefault This is a template parameter with a default argument

View File

@ -1726,11 +1726,11 @@
<!-- Adjacent para nodes' children.
Based on code at: http://stackoverflow.com/a/2092144 -->
<xsl:variable name="program_paragraphs" select="following-sibling::para[preformatted][count(preformatted)=count(*)]" />
<xsl:variable name="following-siblings" select="following-sibling::*" />
<xsl:for-each select="following-sibling::para[preformatted][count(preformatted)=count(*)]">
<xsl:variable name="index" select="position()"/>
<xsl:if test="generate-id(.)=generate-id($program_paragraphs[$index])">
<xsl:text>&#xa;</xsl:text>
<xsl:if test="generate-id(.)=generate-id($following-siblings[$index])">
<xsl:text>&#xa;&#xa;</xsl:text>
<xsl:apply-templates mode="passthrough" select="./preformatted/node()"/>
</xsl:if>
</xsl:for-each>