Bug 718717 - enabling line numbering disables code highlighting
enabling line numbering disables code highlighting
Status: CLOSED CURRENTRELEASE
Product: Publican
Classification: Community
Component: publican (Show other bugs)
2.5
Unspecified Unspecified
low Severity medium
: 4.2
: ---
Assigned To: Jeff Fearn
Martin Lopes
:
Depends On:
Blocks: 1133733
  Show dependency treegraph
 
Reported: 2011-07-04 07:57 EDT by Jeff Fearn
Modified: 2014-08-31 23:40 EDT (History)
4 users (show)

See Also:
Fixed In Version: 4.2.0
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 653432
: 1133733 (view as bug list)
Environment:
Last Closed: 2014-08-31 23:40:26 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Jeff Fearn 2011-07-04 07:57:32 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 jfearn@redhat.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.
Comment 1 Jeff Fearn 2011-07-04 08:00:48 EDT
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 19:57:31 EDT
HSS-QE has reviewed and declined this request. QE for this bug will be handled by IED.
Comment 4 Jeff Fearn 2013-07-19 02:28:51 EDT
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-24 21:08:37 EDT
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 00:16:27 EDT
Verified. Confirmed that syntax highlighting works using the common-db5 brand. Raised BZ#1133733 for the RH brand.
Comment 19 Jeff Fearn 2014-08-31 23:40:26 EDT
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.