Menu

#129 Fails to produce PDF output when using scale.by.width - produces broken lstlisting/lstcode options

v1.0 (example)
open
nobody
None
5
2022-03-20
2021-10-18
No

(I'm just forwarding a bug report from Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=993678)

While building a PDF we stumbled upon an issue. Some of our XML files contain
screen elements with non UTF-8 characters. When we enable scaling for listing
elements:

<xsl:param name="literal.extensions">scale.by.width</xsl:param>

dblatex fails. The produced .tex files then contain line such as:

\begin{lstcode}[escapeinside={<:}{:>}][scale=false,firstnumber=1,escapeinside={<t>}{</t>},moredelim={**[is][\bfseries]{<b>}{</b>}},moredelim={**[is][\itshape]{<i>}{</i>}},]

and those lead to a failure. The problem seems to be code in

/usr/lib/python3/dist-packages/dbtexmf/dblatex/rawverb.py

which fails to detect existing options (added via
/usr/share/xml/docbook/stylesheet/dblatex/xsl/verbatim.xsl already). Thus
dblatex adds another set of options. The same happens without using
scale.by.width, but the resulting lstlisting elements just produce a warning,
that the second set of options gets dropped.

There are several issues I was able to locate. In parse_begin()

if line[0] == b"[":

doesn't seem to work (here they check for existing options). And after fixing
that, the next issue is that

e = line.find(b"]")+1

will fail to produce the desired result because

[scale=false,firstnumber=1,escapeinside={<t>}{</t>},moredelim={**[is][\bfseries]{<b>}{</b>}},moredelim={**[is][\itshape]{<i>}{</i>}},]

contains several closing brackets and we need to find the matching one. Maybe
one could search for ',]'? Not sure if this will break dblatex in other ways.

Next issue then is:

Error: utf_8_encode() argument 2 must be str or None, not bytes

The problem here seems to be in
/usr/lib/python3/dist-packages/dbtexmf/dblatex/rawparse.py and a change in
Python 3 related to string handling.

This problem is a show stopper for us at the moment. Any help is greatly
appreciated.

Attached is a simple testcase. Use it via:

dblatex -d -D -b xetex -p config.xsl test.xml

2 Attachments

Discussion

  • Guillon

    Guillon - 2021-10-27

    Hi,
    Thanks for the bug report that has a good analysis. Please find attached a patch that works for me. Tell me if it's ok for you.

     
  • Raphael Hertzog

    Raphael Hertzog - 2022-03-20

    The patch seems to work in Debian 11 bullseye but we have remaining errors while trying to build the debian handbook in Debian Unstable. Not sure if it's related or if it's something entirely different.

    cf feedback received in https://salsa.debian.org/hertzog/debian-handbook/-/issues/49#note_302033

     

Log in to post a comment.

MongoDB Logo MongoDB