Red Hat Bugzilla – Bug 718717
enabling line numbering disables code highlighting
Last modified: 2014-08-31 23:40:26 EDT
+++ This bug was initially created as a clone of Bug #653432 +++
This applies to publican 2.3:
if the linenumbering="numbered" attribute is being set, various problems occur:
* syntax highlighting (via language attribute) no longer works
* line numbering starts a 0 (startinglinenumber not honoured anyway)
* if the content contains < and & (either via CDATA or numeric entities),
they are literally interpreted as XML, causing parsing errors
The problems can be traced down to the numberLines function in Builder.pm:
* the node list converted to a string. I guess that syntax highlighting
happens before, so all generated markup is lost due to this conversion
* the $count variable is initialized to zero, the line number generation
uses $count++, causing the 0
* the augmented content is then converted back to a document fragment by simply
parsing the content with an XML parser. As special characters (<, &)
are not escaped, they are interpreted as XML
--- Additional comment from email@example.com on 2011-03-13 07:11:40 EDT ---
Hi Klaus, I've committed fixes to startinglinenumber and the use of <, >, etc.
The code highlight fix will take a bit longer, the modified tree isn't being passed to the function so I'll need to track down why it's getting stale data passed in from XSLT.
I've cloned this bug to separate the line numbering and sql escaping (653432) from the line numbering + highlighting not working (this bug).
HSS-QE has reviewed and declined this request. QE for this bug will be handled by IED.
Well I spent most of the day on this and although I can point to the XSL where this is triggered I am no closer to solving it.
In the upstream verbatim.xsl in template match="programlisting|screen|synopsis" when using line numbers the apply-highlighting template is called and the results stored in a variable. It is that storing in the variable that seems to be the problem.
If you just call the highlighting template, works fine, but if you try and store the result in a variable it uses the original node and not the transformed one.
Of course without storing the result in a variable you can't pass on the modified content to the line numbering routine.
I've got this working for DocBook 5.
7a118a9..f84ff5c devel -> devel
Verified. Confirmed that syntax highlighting works using the common-db5 brand. Raised BZ#1133733 for the RH brand.
A fix for this shipped in Publican 4.2.0.