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

Subject: Re: [xsl] Highlight.js available as a XPath extension function
From: "Christophe Marchand cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Jul 2020 05:59:56 -0000
Until Java8, JDK had a JS evaluator embeded. Since Java9, it's an optional module - just like JaxB, and you can choose between various implementations. I use GraalJS[1] for this.

In extension function, GraalJS is started only once, and reused at each call, but it's still quite heavy...

Christophe

[1] : https://github.com/graalvm/graaljs

Le 03/07/2020 C 00:41, Martin Honnen martin.honnen@xxxxxx a C)critB :
On 02.07.2020 23:21, Christophe Marchand cmarchand@xxxxxxxxxx wrote:
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,

Sounds great.


I have not been following the integration of Javascript in the Java
versions so I am not quite sure how it works; does any Java 11 JRE or
JDK (i.e. Oracle or OpenJDK) support that Javascript evaluation you seem
to be doing in
https://github.com/cmarchand/highligtJS-saxon-extension/blob/9b8d90cc762e0cbceed78435e42047f7f4e5d257/src/main/java/top/marchand/xml/saxon/extension/highlight/HighlightExtension.java#L64?

Current Thread