This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] Syntax highlighting, HTML, PDF, XSLT, extensibility


On Mon, 13 Sep 2004 02:11 pm, cali wrote:
> I was writing something in DocBook XML, and realised that my code listings
> look pretty boring and somewhat hard to read, and how they would look much
> better if the keywords and so on were highlighted like they are in my
> editor.
>
> I can think of a number of ways to do this:
>
> 1) Manually extend Docbook with loads of new tags like keyword and so on,
> this seems over the top, tedious, and non-extensible.
> 2) Markup the programlisting with manually with <code role=keyword"></code>
> or something, and put in the XSLT how to render a keyword and so on.
> 3) Mark a programlisting with a tag like sourcelanguage="c", then have some
> kind of modular post processor do the HTML syntax highlighting based on
> language.
> 4) Same as 2 but have another program automatically do the markup from a
> source file.
>
> The way I see it, no manual work should be necessary. The processing could
> be done either before translation, automatically marking up into XML, or
> during translation at the XSLT stage, but some kind of modular program
> shoud be used that can have different syntax files plugged in. I can see
> that this might be trickier when PDF output and other outputs also have to
> be considered.
>
> Has anyone else been thinking about this? I don't know enough about XML or
> DocBook to know whether or not this kind of thing is easily done.
>
> I would like to use DocBook here, but I am thinking that it is probably
> going to be much easier just to write this directly into HTML since I don't
> really need a PDF version, although this would be nice. It might also be
> easier just to rewrite the same document in LaTeX if I want a PDF version
> since probably there already exists programs to automatically convert a
> source file to a syntax highlighted latex environment.
>
> I found a program that converts source to syntax highlighted html:
>
> http://ostermiller.org/syntax/tohtml.html
>

Good syntax highlighters:

1. a2ps (supports PostScript and HTML)

2. vim (there's a command line invocation that allows to generate HTML, don't 
know about LaTeX, but it should be doable by forking the 2html.vim code.)

3. There are a couple of syntax highlighting modules for this in Perl's CPAN.

4. Look in Freshmeat.

Regards,

	Shlomi Fish

> but I haven't yet found one for latex, the plugging in of already existing
> programs seems to me like the outwardly most easy method? What would be
> mega-cool of course, would be if popular colour schemes and syntax
> highlighting formats of popular editors such as vim and emacs were
> supported, now that would be awesome.
>
> Any thoughts?
>
> cal

-- 

---------------------------------------------------------------------
Shlomi Fish      shlomif@iglu.org.il
Homepage:        http://shlomif.il.eu.org/

Knuth is not God! It took him two days to build the Roman Empire.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]