Highlight JS Extension Function

A Saxon extension function that convert source code to an hilighted html view of this source code. It uses highlight.js behind the scene. https://highlightjs.org/ It requires Java 11 at least. It requires Saxon 10 at least.

Лицензия

Лицензия

Категории

Категории

Axon Библиотеки уровня приложения Distributed Applications
Группа

Группа

top.marchand.xml.saxon.extension
Идентификатор

Идентификатор

highlight
Последняя версия

Последняя версия

1.01.00
Дата

Дата

Тип

Тип

jar
Описание

Описание

Highlight JS Extension Function
A Saxon extension function that convert source code to an hilighted html view of this source code. It uses highlight.js behind the scene. https://highlightjs.org/ It requires Java 11 at least. It requires Saxon 10 at least.
Ссылка на сайт

Ссылка на сайт

https://github.com/cmarchand/highligtJS-saxon-extension
Система контроля версий

Система контроля версий

https://github.com/cmarchand/highligtJS-saxon-extension

Скачать highlight

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/top.marchand.xml.saxon.extension/highlight/ -->
<dependency>
    <groupId>top.marchand.xml.saxon.extension</groupId>
    <artifactId>highlight</artifactId>
    <version>1.01.00</version>
</dependency>
// https://jarcasting.com/artifacts/top.marchand.xml.saxon.extension/highlight/
implementation 'top.marchand.xml.saxon.extension:highlight:1.01.00'
// https://jarcasting.com/artifacts/top.marchand.xml.saxon.extension/highlight/
implementation ("top.marchand.xml.saxon.extension:highlight:1.01.00")
'top.marchand.xml.saxon.extension:highlight:jar:1.01.00'
<dependency org="top.marchand.xml.saxon.extension" name="highlight" rev="1.01.00">
  <artifact name="highlight" type="jar" />
</dependency>
@Grapes(
@Grab(group='top.marchand.xml.saxon.extension', module='highlight', version='1.01.00')
)
libraryDependencies += "top.marchand.xml.saxon.extension" % "highlight" % "1.01.00"
[top.marchand.xml.saxon.extension/highlight "1.01.00"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.graalvm.sdk : graal-sdk jar 20.1.0

runtime (1)

Идентификатор библиотеки Тип Версия
org.graalvm.js : js jar 20.1.0

test (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter jar 5.6.2

Модули Проекта

Данный проект не имеет модулей.

HighLight JS Saxon extension

This library is a Saxon XPath extension function that transform source code to highlighted HTML, as highlight.js does, but without any JavaScript embeded in HTML.

To use this library, declare it as dependency :

  <dependency>
    <groupId>top.marchand.xml.saxon.extension</groupId>
    <artifactId>highlight</artifactId>
    <version>1.00.01</version>
  </dependency>

Then, declare this extension when creating Processor :

  Configuration configuration = Configuration.newConfiguration();
  Processor proc = new Processor(configuration);
  proc.registerExtensionFunction(
      new top.marchand.xml.saxon.extension.highlight.HighlightExtension());

Function's namespace is top:marchand:xml:extfunctions. You may use any prefix, but chm is commonly adopted.

Then in XPath, function is available :

  chm:highlight(language as xs:string, sourceCode as xs:string)
  chm:highlight(
      language as xs:string,
      sourceCode as xs:string,
      config as map(xs:string,xs:string)
  )

First form, with two parameters, generates an item()* sequence of span elements and text(), in http://www.w3.org/1999/xhtml namespace. If you need a different namespace, use the second form with a map as third argument. The only supported map-entry is 'result-ns', and its value is the required target namespace.

  chm:highlight('xml','<test>value</test>')

Produces

  <span xmlns="http://www.w3.org/1999/xhtml" class="hljs-tag">&lt;<span class="hljs-name">test</span>&gt;</span>value<span xmlns="http://www.w3.org/1999/xhtml" class="hljs-tag">&lt;/<span class="hljs-name">test</span>&gt;</span>
  chm:highlight('xml','<test>value</test>',map{'result-ns':''})

Produces

  <span class="hljs-tag">&lt;<span class="hljs-name">test</span>&gt;</span>value<span class="hljs-tag">&lt;/<span class="hljs-name">test</span>&gt;</span>

Версии библиотеки

Версия
1.01.00
1.00.01