From b8435f4213365cfdfb1d155c0407c9dc491564cf Mon Sep 17 00:00:00 2001 From: Jirka Kosek Date: Tue, 20 Jun 2006 22:26:59 +0000 Subject: [PATCH] Initial support of syntax highlighting of programlistings. --- xsl/fo/highlight.xsl | 57 ++++++++ xsl/fo/param.ent | 2 + xsl/fo/param.xweb | 4 + xsl/fo/verbatim.xsl | 7 +- xsl/highlighting/common.xsl | 62 +++++++++ xsl/highlighting/delphi-hl.xml | 158 ++++++++++++++++++++++ xsl/highlighting/ini-hl.xml | 27 ++++ xsl/highlighting/java-hl.xml | 82 +++++++++++ xsl/highlighting/m2-hl.xml | 70 ++++++++++ xsl/highlighting/myxml-hl.xml | 116 ++++++++++++++++ xsl/highlighting/php-hl.xml | 111 +++++++++++++++ xsl/highlighting/xslthl-config.xml | 19 +++ xsl/html/highlight.xsl | 55 ++++++++ xsl/html/param.ent | 2 + xsl/html/param.xweb | 4 + xsl/html/verbatim.xsl | 7 +- xsl/params/highlight.default.language.xml | 22 +++ xsl/params/highlight.source.xml | 48 +++++++ 18 files changed, 849 insertions(+), 4 deletions(-) create mode 100644 xsl/fo/highlight.xsl create mode 100644 xsl/highlighting/common.xsl create mode 100644 xsl/highlighting/delphi-hl.xml create mode 100644 xsl/highlighting/ini-hl.xml create mode 100644 xsl/highlighting/java-hl.xml create mode 100644 xsl/highlighting/m2-hl.xml create mode 100644 xsl/highlighting/myxml-hl.xml create mode 100644 xsl/highlighting/php-hl.xml create mode 100644 xsl/highlighting/xslthl-config.xml create mode 100644 xsl/html/highlight.xsl create mode 100644 xsl/params/highlight.default.language.xml create mode 100644 xsl/params/highlight.source.xml diff --git a/xsl/fo/highlight.xsl b/xsl/fo/highlight.xsl new file mode 100644 index 000000000..308436945 --- /dev/null +++ b/xsl/fo/highlight.xsl @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/fo/param.ent b/xsl/fo/param.ent index c003ea464..c97f85288 100644 --- a/xsl/fo/param.ent +++ b/xsl/fo/param.ent @@ -81,6 +81,8 @@ + + diff --git a/xsl/fo/param.xweb b/xsl/fo/param.xweb index 8248509b1..d49a60985 100644 --- a/xsl/fo/param.xweb +++ b/xsl/fo/param.xweb @@ -281,6 +281,8 @@ generate.section.toc.level; &superscript.properties; &subscript.properties; &pgwide.properties; +&highlight.source; +&highlight.default.language; Graphics @@ -661,6 +663,8 @@ around all these parameters. + + diff --git a/xsl/fo/verbatim.xsl b/xsl/fo/verbatim.xsl index 3449d94ad..d90f80b84 100644 --- a/xsl/fo/verbatim.xsl +++ b/xsl/fo/verbatim.xsl @@ -18,6 +18,9 @@ ******************************************************************** --> + + + @@ -33,12 +36,12 @@ and $linenumbering.extension != '0'"> - + - + diff --git a/xsl/highlighting/common.xsl b/xsl/highlighting/common.xsl new file mode 100644 index 000000000..552c7c373 --- /dev/null +++ b/xsl/highlighting/common.xsl @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/highlighting/delphi-hl.xml b/xsl/highlighting/delphi-hl.xml new file mode 100644 index 000000000..1f69aec14 --- /dev/null +++ b/xsl/highlighting/delphi-hl.xml @@ -0,0 +1,158 @@ + + + + + + { + } + + + + (* + *) + + + + // + + + + ' + + + + + + + and + else + inherited + packed + then + array + end + initialization + procedure + threadvar + as + except + inline + program + to + asm + exports + interface + property + try + begin + file + is + raise + type + case + final + label + record + unit + class + finalization + library + repeat + unsafe + const + finally + mod + resourcestring + until + constructor + for + nil + sealed + uses + destructor + function + not + set + var + dispinterface + goto + object + shl + while + div + if + of + shr + with + do + implementation + or + static + xor + downto + in + out + string + + + at + on + + + absolute + dynamic + local + platform + requires + abstract + export + message + private + resident + assembler + external + name + protected + safecall + automated + far + near + public + stdcall + cdecl + forward + nodefault + published + stored + contains + implements + overload + read + varargs + default + index + override + readonly + virtual + deprecated + inline + package + register + write + dispid + library + pascal + reintroduce + writeonly + + + + + \ No newline at end of file diff --git a/xsl/highlighting/ini-hl.xml b/xsl/highlighting/ini-hl.xml new file mode 100644 index 000000000..61afb5ef4 --- /dev/null +++ b/xsl/highlighting/ini-hl.xml @@ -0,0 +1,27 @@ + + + + + + (?m)(;.*)$ + + + + + (?m)^(\[.+\]\s*)$ + + + + + (?m)^(.+=) + + + + \ No newline at end of file diff --git a/xsl/highlighting/java-hl.xml b/xsl/highlighting/java-hl.xml new file mode 100644 index 000000000..a483c2fd8 --- /dev/null +++ b/xsl/highlighting/java-hl.xml @@ -0,0 +1,82 @@ + + + + + + /* + */ + + + + // + + + + " + \ + + + + ' + \ + + + + abstract + boolean + break + byte + case + catch + char + class + const + continue + default + do + double + else + extends + final + finally + float + for + goto + if + implements + import + instanceof + int + interface + long + native + new + package + private + protected + public + return + short + static + strictfp + super + switch + synchronized + this + throw + throws + transient + try + void + volatile + while + + + \ No newline at end of file diff --git a/xsl/highlighting/m2-hl.xml b/xsl/highlighting/m2-hl.xml new file mode 100644 index 000000000..67b1f282a --- /dev/null +++ b/xsl/highlighting/m2-hl.xml @@ -0,0 +1,70 @@ + + + + + + (* + *) + + + + " + + + + ' + + + + and + array + begin + by + case + const + definition + div + do + else + elsif + end + exit + export + for + from + if + implementation + import + in + loop + mod + module + not + of + or + pointer + procedure + qualified + record + repeat + return + set + then + to + type + until + var + while + with + + + + + \ No newline at end of file diff --git a/xsl/highlighting/myxml-hl.xml b/xsl/highlighting/myxml-hl.xml new file mode 100644 index 000000000..afa4be712 --- /dev/null +++ b/xsl/highlighting/myxml-hl.xml @@ -0,0 +1,116 @@ + + + + + + + + A + ABBR + ACRONYM + ADDRESS + APPLET + AREA + B + BASE + BASEFONT + BDO + BIG + BLOCKQUOTE + BODY + BR + BUTTON + CAPTION + CENTER + CITE + CODE + COL + COLGROUP + DD + DEL + DFN + DIR + DIV + DL + DT + EM + FIELDSET + FONT + FORM + FRAME + FRAMESET + H1 + H2 + H3 + H4 + H5 + H6 + HEAD + HR + HTML + I + IFRAME + IMG + INPUT + INS + ISINDEX + KBD + LABEL + LEGEND + LI + LINK + MAP + MENU + META + NOFRAMES + NOSCRIPT + OBJECT + OL + OPTGROUP + OPTION + P + PARAM + PRE + Q + S + SAMP + SCRIPT + SELECT + SMALL + SPAN + STRIKE + STRONG + STYLE + SUB + SUP + TABLE + TBODY + TD + TEXTAREA + TFOOT + TH + THEAD + TITLE + TR + TT + U + UL + VAR + XMP + + + + + xsl: + + + + \ No newline at end of file diff --git a/xsl/highlighting/php-hl.xml b/xsl/highlighting/php-hl.xml new file mode 100644 index 000000000..bfb85e4d3 --- /dev/null +++ b/xsl/highlighting/php-hl.xml @@ -0,0 +1,111 @@ + + + + + + /* + */ + + + + // + + + + # + + + + " + \ + + + + ' + \ + + + + <<< + + + + and + or + xor + __FILE__ + exception + __LINE__ + array + as + break + case + class + const + continue + declare + default + die + do + echo + else + elseif + empty + enddeclare + endfor + endforeach + endif + endswitch + endwhile + eval + exit + extends + for + foreach + function + global + if + include + include_once + isset + list + new + print + require + require_once + return + static + switch + unset + use + var + while + __FUNCTION__ + __CLASS__ + __METHOD__ + final + php_user_filter + interface + implements + extends + public + private + protected + abstract + clone + try + catch + throw + cfunction + old_function + + + + \ No newline at end of file diff --git a/xsl/highlighting/xslthl-config.xml b/xsl/highlighting/xslthl-config.xml new file mode 100644 index 000000000..f6db13246 --- /dev/null +++ b/xsl/highlighting/xslthl-config.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/xsl/html/highlight.xsl b/xsl/html/highlight.xsl new file mode 100644 index 000000000..b581ee553 --- /dev/null +++ b/xsl/html/highlight.xsl @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsl/html/param.ent b/xsl/html/param.ent index 60efcb220..9405283c0 100644 --- a/xsl/html/param.ent +++ b/xsl/html/param.ent @@ -67,6 +67,8 @@ + + diff --git a/xsl/html/param.xweb b/xsl/html/param.xweb index 782f39b6f..115b99ad8 100644 --- a/xsl/html/param.xweb +++ b/xsl/html/param.xweb @@ -284,6 +284,8 @@ stylesheet like this: &table.footnote.number.format; &footnote.number.symbols; &table.footnote.number.symbols; +&highlight.source; +&highlight.default.language; Annotations @@ -536,6 +538,8 @@ around all these parameters. + + diff --git a/xsl/html/verbatim.xsl b/xsl/html/verbatim.xsl index 63f25e0a5..bb1e0c77e 100644 --- a/xsl/html/verbatim.xsl +++ b/xsl/html/verbatim.xsl @@ -17,6 +17,9 @@ ******************************************************************** --> + + + @@ -46,7 +49,7 @@ and $use.extensions != '0' and $linenumbering.extension != '0'"> - +
 	
@@ -56,7 +59,7 @@
     
     
       
-	
+	
       
diff --git a/xsl/params/highlight.default.language.xml b/xsl/params/highlight.default.language.xml new file mode 100644 index 000000000..3e5cfe73d --- /dev/null +++ b/xsl/params/highlight.default.language.xml @@ -0,0 +1,22 @@ + + +highlight.default.language +string + + +highlight.default.language +Default language of programlisting + + + + + + + + +Description + +This language is used when there is no language attribute on programlisting. + + + diff --git a/xsl/params/highlight.source.xml b/xsl/params/highlight.source.xml new file mode 100644 index 000000000..edcd79882 --- /dev/null +++ b/xsl/params/highlight.source.xml @@ -0,0 +1,48 @@ + + +highlight.source +boolean + + +highlight.source +Should be content of programlisting +syntactically highlighted? + + + + + + + + +Description + +When this parameter is non-zero, the stylesheets will try to do +syntax highlighting in content of programlisting element. + +In order to use this extension, you must add +xslthl.jar into your Java classpath. You can +download this software from . + +Configuration of syntax highlighting is stored insise +highlighting/xslthl-config.xml file. Java +property xslthl.config must be pointing to this +file using URL. + +This extension is known to work with Saxon 6.5.x. When using +syntax highlighting, do not forget to modify your classpath and point +to configuration file using property. Modified Saxon command looks +like: + +java -cp c:\batch\;…;c:\cesta\k\xslthl.jar -Dxslthl.config=file:///c:/docbook-xsl/highlighting/xslthl-config.xml … com.icl.saxon.StyleSheet … + +You can specify language of each programlisting using language attribute. You can also specify +language to be expected for programlistings without language attribute. In this case, you can +use parameter highlighting.default.language to +set default language. + + + -- 2.40.0