asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
617 stars 172 forks source link

highlight.js version 9 used by AsciiDoctorJ needs update as it is out of support #1258

Closed dhendriks closed 5 months ago

dhendriks commented 5 months ago

When I use AsciiDoctorJ, and set source-highlighter to highlight.js, I get the following in the generated HTML:

...
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/styles/github.min.css"> <!--
...
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
  <script>
if (!hljs.initHighlighting.called) {
  hljs.initHighlighting.called = true
  ;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) { hljs.highlightBlock(el) })
}
</script>
...

Version 9 of highlight.js is end-of-life and end-of-support (see https://github.com/highlightjs/highlight.js/issues/2877).

And, the website at https://highlightjs.org/ only has documentation for the current version (version 11). I tried to add a new language to the version 9 one, but it doesn't work. It seems APIs have changed.

I then tried using the highlightjsdir option of AsciiDoctorJ to add CSS/JS of highlight.js version 11. That works for the linked CSS/JS files, but the last inline script part is still the same. The highlightBlock function that is used is deprecated. My browser indicates:

Deprecated as of 10.7.0. highlightBlock will be removed entirely in v12.0      highlight.min.js:108
Deprecated as of 10.7.0. Please use highlightElement now.                      highlight.min.js:108

Since it is only deprecated, it does function correctly, it seems. Still, I think it would be good to upgrade the highlight.js version used by AsciiDoctorJ, such that there are no deprecation warnings, and it is not necessary to include an own version of highlight.js just to get one that is supported.

abelsromero commented 5 months ago

It's tracked upstream https://github.com/asciidoctor/asciidoctor/issues/3976

dhendriks commented 5 months ago

It's tracked upstream asciidoctor/asciidoctor#3976

Thanks. I added a comment there.