Hi!
I'be been fiddling with my local copies of BoostBook and QuickBook and
noticed that BoostBook's xsl stylesheets do not properly preserve
whitespace within <programlisting>.
I'm attaching a simple test case (which I describe below) reproducing
the problem and a possible patch for docbook.xsl. I haven't looked it
through, but I believe another possibility would be to fix this in
boostbook.dtd.
Any chance this can be fixed?
Whitespace is preserved in "simple" program listings, like so:
<programlisting>
int function()
{
return value;
}
</programlisting>
, which generates the obvious thing. However, in the presence of
additional markup, for instance, adding syntax-highlighting to the
example above:
<programlisting>
<phrase role="keyword">int</phrase> <phrase
role="identifier">function</phrase><phrase
role="special">(</phrase><phrase role="special">)</phrase>
<phrase role="special">{</phrase>
<phrase role="keyword">return</phrase> <phrase
role="identifier">value</phrase><phrase role="special">;</phrase>
return value;
<phrase role="special">}</phrase>
</programlisting>
when processed with BoostBook stylesheets will result in the generation
of the equivalent of,
intfunction(){returnvalue;}
I'm attaching a test case containing the above example. Additionally the
same source can be processed directly with DocBook stylesheets to
generate what (I believe) would be the correct output.
Regards,
João
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
<!-- <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> -->
<chapter>
<title>BoostBook test</title>
<section>
<title>BoostBook test</title>
<bridgehead>Simple <programlisting></bridgehead>
<programlisting>
int function()
{
return value;
}
</programlisting>
<bridgehead><programlisting> with additional markup</bridgehead>
<programlisting>
<phrase role="keyword">int</phrase> <phrase role="identifier">function</phrase><phrase role="special">(</phrase><phrase role="special">)</phrase>
<phrase role="special">{</phrase>
<phrase role="keyword">return</phrase> <phrase role="identifier">value</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
</section>
</chapter>
Index: docbook.xsl
===================================================================
RCS file: /cvsroot/boost/boost/tools/boostbook/xsl/docbook.xsl,v
retrieving revision 1.13
diff -u -r1.13 docbook.xsl
--- docbook.xsl 11 Jan 2005 03:47:37 -0000 1.13
+++ docbook.xsl 17 Sep 2005 03:57:42 -0000
@@ -17,6 +17,10 @@
output. If this list is empty, all libraries will be included. -->
<xsl:param name="boost.include.libraries" select="''"/>
+ <!-- A space-separated list of elements from the input file in which
+ whitespace should be preserved -->
+ <xsl:preserve-space elements="programlisting"/>
+
<xsl:template match="library-reference">
<xsl:choose>
<xsl:when test="ancestor::library-reference">