Lisp syntax highlighting
Fri Jun 5 16:17:33 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Lisp syntax highlighting
diff -rN -u old-doc/Makefile new-doc/Makefile
--- old-doc/Makefile 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/Makefile 2014-10-30 06:55:10.000000000 +0100
@@ -1,22 +1,36 @@
#
# Dependancies:
-# xmllint xsltproc docbook
+# - xmllint
+# - saxon
+# - docbook
+# - xslthl
#
+# Debian: download the xslthl jar into the doc/ directory; install the remaining dependancies with apt.
+#
+
+SAXON_JAR := /usr/share/java/saxon.jar
+XSLTHL_JAR := $(firstword $(wildcard xslthl*.jar))
+CLASSPATH := "$(SAXON_JAR):$(XSLTHL_JAR)"
+SAXON := java -classpath $(CLASSPATH) \
+ -Dxslthl.config="file://$(realpath xslthl-config.xml)" \
+ com.icl.saxon.StyleSheet
all: manual.html index.html
DEPENDANCIES := *.xml *.xsl ../qt.examples/src/*.lisp ../kde.examples/src/*.lisp *.dtd
-manual.html: $(DEPENDANCIES)
- xmllint --xinclude --postvalid manual.xml > /dev/null
- xsltproc --xinclude -o $@ manual.xsl manual.xml
-
-index.html: $(DEPENDANCIES)
-# xsltproc --xinclude --stringparam base.dir "manual/" chunk.xsl manual.xml
- xsltproc --xinclude chunk.xsl manual.xml
+# validate & process xincludes
+manual.tmp: $(DEPENDANCIES)
+ xmllint --xinclude --postvalid manual.xml > manual.tmp
+
+
+manual.html: manual.tmp
+ $(SAXON) -o manual.html manual.tmp manual.xsl
+
-
+index.html: manual.tmp
+ $(SAXON) manual.tmp chunk.xsl
.PHONY: clean
clean:
- rm -f -- *.html
+ rm -f -- *.html *.tmp
diff -rN -u old-doc/chunk.xsl new-doc/chunk.xsl
--- old-doc/chunk.xsl 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/chunk.xsl 2014-10-30 06:55:11.000000000 +0100
@@ -5,6 +5,9 @@
<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/chunk.xsl"/>
<xsl:import href="link-apidoc.xsl"/>
+<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/highlight.xsl"/>
+<xsl:param name="highlight.source" select="1"/>
+
<!--
<xsl:param name="admon.graphics" select="1"/>
!-->
diff -rN -u old-doc/kde.xml new-doc/kde.xml
--- old-doc/kde.xml 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/kde.xml 2014-10-30 06:55:11.000000000 +0100
@@ -12,11 +12,11 @@
<section><title>Examples</title>
<para>
The examples can be run with:
-<programlisting>
+<programlisting language="lisp">
(mb:load <package>:kde.examples</package>)
</programlisting>
And then running the function of the example; e.g.:
-<programlisting>
+<programlisting language="lisp">
(<methodname>kde.examples:mandelbrot</methodname>)
</programlisting>
</para>
diff -rN -u old-doc/lisp-hl.xml new-doc/lisp-hl.xml
--- old-doc/lisp-hl.xml 1970-01-01 01:00:00.000000000 +0100
+++ new-doc/lisp-hl.xml 2014-10-30 06:55:11.000000000 +0100
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Common Lisp highlighter for xslthl -->
+<highlighters>
+ <highlighter type="keywords">
+ <keyword>defun</keyword>
+ <keyword>defgeneric</keyword>
+ <keyword>defmethod</keyword>
+ <keyword>lambda</keyword>
+
+ <keyword>if</keyword>
+ <keyword>when</keyword>
+ <keyword>unless</keyword>
+
+ <keyword>let</keyword>
+ <keyword>let*</keyword>
+
+ <keyword>defvar</keyword>
+ <keyword>defparameter</keyword>
+ <keyword>defpackage</keyword>
+
+ <keyword>defclass</keyword>
+ <keyword>defstruct</keyword>
+
+ <keyword>declare</keyword>
+ <keyword>declaim</keyword>
+ <keyword>proclaim</keyword>
+ <ignoreCase />
+ </highlighter>
+ <highlighter type="word">
+ <word>in-package</word>
+ <style>keyword</style>
+ </highlighter>
+
+ <!-- comments -->
+ <highlighter type="multiline-comment">
+ <start>#|</start>
+ <end>|#</end>
+ <style>comment</style>
+ </highlighter>
+ <highlighter type="oneline-comment">
+ ;
+ </highlighter>
+
+ <!-- string -->
+ <highlighter type="string">
+ <string>"</string>
+ <spanNewLines/>
+ </highlighter>
+
+ <!-- keyword package -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=[ \(])(:[^\s\)]+)</pattern>
+ <style>attribute</style>
+ </highlighter>
+
+ <!-- defined symbols -->
+ <!-- defclass -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defclass\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defun -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defun\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defgeneric -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defgeneric\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defmethod -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defmethod\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defvar -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defvar\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defparameter -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defparameter\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+ <!-- defstruct -->
+ <highlighter type="regex">
+ <pattern>(?&lt;=defstruct\s)(\S+)</pattern>
+ <style>directive</style>
+ </highlighter>
+
+ <!-- numbers
+ TODO does not work? -->
+ <highlighter type="number">
+ <point>.</point>
+ <exponent>d</exponent> <!-- double-float -->
+ <exponent>e</exponent> <!-- float -->
+ <exponent>f</exponent> <!-- single-float -->
+ <exponent>l</exponent> <!-- long-float -->
+ <exponent>s</exponent> <!-- short-float -->
+ <ignoreCase />
+ </highlighter>
+ <!-- numbers -->
+ <highlighter type="hexnumber">
+ <prefix>#x</prefix>
+ <ignoreCase />
+ </highlighter>
+</highlighters>
diff -rN -u old-doc/manual.xsl new-doc/manual.xsl
--- old-doc/manual.xsl 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/manual.xsl 2014-10-30 06:55:11.000000000 +0100
@@ -5,4 +5,7 @@
<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/docbook.xsl"/>
<xsl:import href="link-apidoc.xsl"/>
+<xsl:import href="/usr/share/xml/docbook/stylesheet/nwalsh/xhtml/highlight.xsl"/>
+<xsl:param name="highlight.source" select="1"/>
+
</xsl:stylesheet>
diff -rN -u old-doc/qt.xml new-doc/qt.xml
--- old-doc/qt.xml 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/qt.xml 2014-10-30 06:55:11.000000000 +0100
@@ -73,7 +73,7 @@
or a C++ slot a return from <methodname>qt:get-slot</methodname>.
</para>
<example><title>Quit</title>
-<programlisting>
+<programlisting language="lisp">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../qt.examples/src/hello-world-quit.lisp" parse="text" />
</programlisting>
</example>
@@ -97,7 +97,7 @@
The name of the property can be either a string in C++ style or a symbol in Lisp style.
</para>
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(let ((object (make-instance '<classname>qt:object</classname>)))
(setf (<methodname>qt:property</methodname> object 'object-name) "Foo")
(assert (string= "Foo" (<methodname>qt:property</methodname> object "objectName"))))
@@ -128,7 +128,7 @@
</mediaobject>
</screenshot>
-<programlisting language="po">
+<programlisting language="lisp">
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="../qt.examples/src/i18n-hello-world.lisp" parse="text" />
</programlisting>
@@ -154,7 +154,7 @@
<section><title>Examples</title>
<para>
You can run the examples with:
-<programlisting>
+<programlisting language="lisp">
(mb:load <package>:qt.examples</package>)
(<methodname>qt.examples:launcher</methodname>)
</programlisting>
diff -rN -u old-doc/smoke.xml new-doc/smoke.xml
--- old-doc/smoke.xml 2014-10-30 06:55:10.000000000 +0100
+++ new-doc/smoke.xml 2014-10-30 06:55:10.000000000 +0100
@@ -22,13 +22,13 @@
C++ classes have a corresponding CLOS class. The can be used like any CLOS class; E.g:
to make a <code>QObject</code> instance:
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(make-instance '<classname>qt:object</classname>)
</programlisting>
</informalexample>
Supply arguments as list to the <code>:args</code> keyword:
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(let ((parent (make-instance '<classname>qt:object</classname>)))
(make-instance '<classname>qt:object</classname> :args (list parent)))
</programlisting>
@@ -37,7 +37,7 @@
<para>
To extend a C++ class you have to use <classname>cxx:class</classname> as metaclass:
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(defclass my-object (<classname>qt:object</classname>)
()
(:metaclass <classname>cxx:class</classname>))
@@ -53,20 +53,20 @@
<para>
The C++ method call: <code>myInstance->frob(1);</code> is in Lisp:
<informalexample>
-<programlisting>(frob my-instance 1)</programlisting>
+<programlisting language="lisp">(frob my-instance 1)</programlisting>
</informalexample>
</para>
<section><title>Overload Resolution</title>
<para>
C++ style overload resolution with conversion sequences is supported. For example this:
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(<genericfunction>cxx:set-pen</genericfunction> (make-instance '<classname>qt:painter</classname>) (make-instance '<classname>qt:color</classname> :args '("green")))
</programlisting>
</informalexample>
is equivalent to:
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(<genericfunction>cxx:set-pen</genericfunction> (make-instance '<classname>qt:painter</classname>) "green")
</programlisting>
</informalexample>
@@ -81,13 +81,13 @@
<para>
Instead of calling a setter method that takes no additional arguments,
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(<genericfunction>cxx:set-object-name</genericfunction> (make-instance '<classname>qt:object</classname>) "foo")
</programlisting>
</informalexample>
you can use its <code>setf</code>able getter.
<informalexample>
-<programlisting>
+<programlisting language="lisp">
(setf (<genericfunction>cxx:object-name</genericfunction> (make-instance '<classname>qt:object</classname>)) "foo")
</programlisting>
</informalexample>
@@ -101,7 +101,7 @@
and <code>(call-next-method)</code> are supported.
</para>
<informalexample>
-<programlisting>(defclass the-object-does-nothing (<classname>qt:object</classname>)
+<programlisting language="lisp">(defclass the-object-does-nothing (<classname>qt:object</classname>)
()
(:metaclass <classname>cxx:class</classname>))
@@ -174,16 +174,16 @@
The static C++ method <code>QByteArray::number(int n, int base=10)</code>
can be called by:
<informalexample>
-<programlisting>(<methodname>qt:byte-array.number</methodname> 37)</programlisting>
+<programlisting language="lisp">(<methodname>qt:byte-array.number</methodname> 37)</programlisting>
</informalexample>
which is equivalent to the C++ code <code>QByteArray::number(37);</code>.
Or with:
<informalexample>
-<programlisting>(<genericfunction>cxx:number</genericfunction> (find-class '<classname>qt:byte-array</classname>) 37)</programlisting>
+<programlisting language="lisp">(<genericfunction>cxx:number</genericfunction> (find-class '<classname>qt:byte-array</classname>) 37)</programlisting>
</informalexample>
or:
<informalexample>
-<programlisting>(<genericfunction>cxx:number</genericfunction> (make-instance '<classname>qt:byte-array</classname>) 37)</programlisting>
+<programlisting language="lisp">(<genericfunction>cxx:number</genericfunction> (make-instance '<classname>qt:byte-array</classname>) 37)</programlisting>
</informalexample>
</para>
</section>
@@ -210,7 +210,7 @@
<para>
An instance may depend on an other one.
It is a bad idea to do something like this:
-<programlisting>
+<programlisting language="lisp">
(defvar *meta* (<genericfunction>cxx:meta-object</genericfunction> (make-instance 'qt:object)))
</programlisting>
<code>*meta*</code> references a <classname>qt:meta-class</classname>
diff -rN -u old-doc/xslthl-config.xml new-doc/xslthl-config.xml
--- old-doc/xslthl-config.xml 1970-01-01 01:00:00.000000000 +0100
+++ new-doc/xslthl-config.xml 2014-10-30 06:55:10.000000000 +0100
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xslthl-config>
+ <highlighter id="lisp" file="lisp-hl.xml" />
+ <namespace prefix="xslthl" uri="http://xslthl.sf.net" />
+</xslthl-config>