Menu

#1388 HTML/FO: Empty first/last line in `<programlisting>` produces inconsistent result

output: all formats
open
nobody
None
5
2016-09-14
2016-09-14
No

A week ago, I made a small mistake by inserting a blank line at the beginning of my book's <programlisting> element, and noticed an inconsistency in how DocBook XSL deal with blank first and last lines of <programlisting>:

DocBook XML:

<programlisting><![CDATA[

This is the first non-empty line.
This is the second non-empty line.
This is the last non-empty line.

]]></programlisting>

Expected rendering result is there should be two blank lines at the start and the end of program listing.

But the actual generated results are different:

  • In HTML output, one empty line is trimmed from the beginning and the end of output (leaving only one blank line in each place).
  • In PDF output, empty first lines are correctly preserved, but one empty last line is trimmed from the output. (Two blank lines is shown at the start of program listing, but only one blank line is shown at the end of program listing)

I'm not sure how these cases should be handled according to DocBook specification, but the result should be consistent between first and last empty lines, and consistent across output modules. (Anyway, DocBook: The Definitive Guide said all newlines are significant)

Test DocBook article files which exhibit this problem, together with rendered HTML output, PDF output, and XSL-FO intermediate are attached as emptylines.zip. There are two variant of test files provided: double empty lines (the one described above), and single empty line; both are affected by the same problem.

DocBook XML DTD: 4.2
DocBook XSL: 1.79.1
XSLT Processor: XSLTproc 1.1.28
XSL-FO Processor: Apache FOP 2.1
Runtime: Cygwin 1.7.28 32-bit
System: Microsoft Windows XP Professional SP3

1 Attachments

Discussion

MongoDB Logo MongoDB