Bug 718717 - enabling line numbering disables code highlighting
Summary: enabling line numbering disables code highlighting
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Publican
Classification: Community
Component: publican
Version: 2.5
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: 4.2
Assignee: Jeff Fearn 🐞
QA Contact: Martin Lopes
URL:
Whiteboard:
Depends On:
Blocks: 1133733
TreeView+ depends on / blocked
 
Reported: 2011-07-04 11:57 UTC by Jeff Fearn 🐞
Modified: 2014-09-01 03:40 UTC (History)
4 users (show)

Fixed In Version: 4.2.0
Doc Type: Bug Fix
Doc Text:
Clone Of: 653432
: 1133733 (view as bug list)
Environment:
Last Closed: 2014-09-01 03:40:26 UTC
Embargoed:


Attachments (Terms of Use)

Description Jeff Fearn 🐞 2011-07-04 11:57:32 UTC
+++ 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 jfearn 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.

Comment 1 Jeff Fearn 🐞 2011-07-04 12:00:48 UTC
I've cloned this bug to separate the line numbering and sql escaping (653432) from the line numbering + highlighting not working (this bug).

Comment 3 HSS Product Manager 2013-07-18 23:57:31 UTC
HSS-QE has reviewed and declined this request. QE for this bug will be handled by IED.

Comment 4 Jeff Fearn 🐞 2013-07-19 06:28:51 UTC
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.

Comment 5 Jeff Fearn 🐞 2014-07-25 01:08:37 UTC
I've got this working for DocBook 5.

To ssh://git.fedorahosted.org/git/publican.git
   7a118a9..f84ff5c  devel -> devel

Comment 18 Martin Lopes 2014-08-26 04:16:27 UTC
Verified. Confirmed that syntax highlighting works using the common-db5 brand. Raised BZ#1133733 for the RH brand.

Comment 19 Jeff Fearn 🐞 2014-09-01 03:40:26 UTC
A fix for this shipped in Publican 4.2.0.


Note You need to log in before you can comment on or make changes to this bug.