xsl-list
[Top] [All Lists]

[xsl] Highlight.js available as a XPath extension function

2020-07-02 16:21:36
Highlight JS is a well known javascript library that is able to highlight source code in a HTML page.

If you need to generate a static HTML that contains highlighted source code, and if you use Saxon 10 and Java 11 at least, you now have a XPath extension function that do this. It embeds highlight.js library, and so, rendering is the same as the one done in browser. But your page is generated and do not require JavaScript, and so can be used as source in multiple renderers, as FlyingSaucer[0] or forks.

highlightJS-saxon-extension is available in maven <https://repo1.maven.org/maven2/top/marchand/xml/saxon/extension/highlight/1.00.01/>[1], and source code is on github <https://github.com/cmarchand/highligtJS-saxon-extension>[2].

A XSL sample is available in unit tests : https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/xsl/top/marchand/xml/saxon/extension/highlight/formater.xsl[3] with data <https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/xml/top/marchand/xml/saxon/extension/highlight/source-code.xml>[4], and java samples <https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/java/top/marchand/xml/saxon/extension/highlight/HighlightExtensionTest.java#L60>[5] to configure Saxon are available.

Enjoy,
Christophe


[0] : https://github.com/flyingsaucerproject/flyingsaucer
[1] : https://repo1.maven.org/maven2/top/marchand/xml/saxon/extension/highlight/1.00.01/
[2] : https://github.com/cmarchand/highligtJS-saxon-extension/
[3] : https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/xsl/top/marchand/xml/saxon/extension/highlight/formater.xsl [4] : https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/xml/top/marchand/xml/saxon/extension/highlight/source-code.xml [5] : https://github.com/cmarchand/highligtJS-saxon-extension/blob/master/src/test/java/top/marchand/xml/saxon/extension/highlight/HighlightExtensionTest.java#L60
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>