OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [docbook-apps] Syntax highlighting

On 12/07/2013 01:38 AM, davep wrote:
> On 06/12/13 21:53, Norman Walsh wrote:
>> Hello world,
>> A fair bit of effort in the DocBook stylesheets goes into parsing,
>> decomposing, annotating, and recomposing program listings for the
>> purpose of adding line numbers to them. There's also a bunch of work
>> that goes into syntax highlighting them.
>> Occasionally, this takes a *long* time.
>> It appears that modern systems do this in the JavaScript layer on the
>> client. They also use tables to render line numbers.

We use the popular syntax highlighter:

But we had to adapt it to support callouts and markup inside the code
sample. Without our modifications, the js highlighter would end up
displaying the html markup from the inline markup and the callouts as if
it were part of the code sample. Here's an example of our version:


On the downside, it adds weight to the page.

>> I'm tempted to move in this direction. Comments?
> No problem with line numbers. I guess it's the outcome we want
> rather than how it is done?
>   Would that work with insertions too? E.g. lines with (6) etc
> which are referred to in commentary?

One caveat about using tables for line numbers. It generally makes it
impossible to cut and paste the code sample without getting all the line
numbers. One thing I like about the syntax highlighter above is that
when you click on the code sample, the callouts go away and are not copied.

Of course for pdf/print output, copy/paste is less of a concern.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]