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]

Re: color coding


/ Arjan Huijzer <ahuijze@bit-ic.nl> was heard to say:
| Thanks for the advice. I especially like the code2html application. I would
| like to extend my DocBook "framework" to include it. What I would like to
| accomplish is this: if a <programlisting> element has the attribute "role"
| set, apply syntax highlighting in that language e.g. <programlisting
| role="html">.

That may be impractical. You really need to pre-process the code
listing to add markup for the syntax highlighting. (Trying to get XSLT
to do syntax highlighting by semantic analysis of the code listing is
probably more trouble than its worth.)

| How can i do this? Any help is greatly appreciated!

When I wanted to have syntax highlighted XML in a document I was
writing, I wrote prettyprint.pl (attached) that reads an XML document
and produces marked-up DocBook.

Then I added a little CSS to my HTML file:

tt.sgmltag-starttag    { color: #4080B0; }
tt.sgmltag-endtag      { color: #4080B0; }
tt.sgmltag-emptytag    { color: #4080B0; }
tt.sgmltag-sgmlcomment { color: #B02020; }
tt.sgmltag-xmlpi       { color: #0000F8; }
tt.sgmltag-genentity   { color: #686868; }
pre.programlisting     { background-color: #F0DCB0; }

Result: syntax highlighted XML.

Maybe something similar would work for your application.

prettyprint.pl



                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com>      | My dog is worried about the
http://www.oasis-open.org/docbook/ | economy because Alpo is up to 99
Chair, DocBook Technical Committee | cents a can. That's almost $7.00
                                   | in dog money.--Joe Weinstein

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