Reasoning: We use https://github.com/asciidoctor/asciidoctor-fopub . It generates a nice PDF out-of-the-box, but it doesn’t highlight Pascal keywords. That’s because it uses xslthl for syntax highlighting, and it seems that this version of xslthl doesn’t include Pascal highlighter. I’m not sure is it a limitation of the old version of xslthl 2.1.0, or was it "cut down" when adjusting xslthl 2.1.0 to asciidoctor-fopub (as asciidoctor-fopub/build/fopub/docbook-xsl/xslthl-config.xml
says "Several of the lesser used languages have been removed.")
The latest version of xslthl (see https://sourceforge.net/projects/xslthl/) does include a highlighter for Pascal (called "delphi"…). But simply upgrading xslthl version in asciidoctor-fopub/build.gradle
doesn’t work, it seems no version later than 2.1.0 works (it seems no new version was uploaded to "Maven Repository"?).
So, we make a hack:)
-
Run
fopub
fromasciidoctor-fopub
at least once, to let it setup thebuild
subdirectory. E.g. make once a PDF here, bymake clean all
. -
Get
delphi-hl.xml
file from https://sourceforge.net/p/xslthl/code/HEAD/tree/trunk/xslthl/highlighters/delphi-hl.xml . Drop it inside…/asciidoctor-fopub/build/fopub/docbook-xsl/xslthl/
directory. Like this:cd ../asciidoctor-fopub/build/fopub/docbook-xsl/xslthl/ wget http://svn.code.sf.net/p/xslthl/code/trunk/xslthl/highlighters/delphi-hl.xml
-
Modify
…/asciidoctor-fopub/build/fopub/docbook-xsl/xslthl-config.xml
source code to add these lines:<highlighter id="pascal" file="./xslthl/delphi-hl.xml" /> <highlighter id="delphi" file="./xslthl/delphi-hl.xml" />
Add them near the end, aligned with the rest of
<highlighter…
lines.
Works like a charm:) Now [source,pascal]
inside xxx.adoc
results in nice highlighting in PDF!