Open ggrossetie opened 3 years ago
Currently, Asciidoctor.js does not provide an API to extend a class. As a result, we need to use Opal low-level API to do so.
We could introduce a third argument on the SyntaxHighlighter.register function:
SyntaxHighlighter.register
class CustomHighlightJsAdapter { docinfo (location) { // ... } } asciidoctor.SyntaxHighlighter.register( // names ['highlight.js', 'highlightjs'], // syntax highligther CustomHighlightJsAdapter, // extends asciidoctor.SyntaxHighlighter.for('highlight.js') )
Or introduce a generic function:
class CustomHighlightJsAdapter { docinfo (location) { // ... } } asciidoctor.klass.extend(CustomHighlightJsAdapter, asciidoctor.SyntaxHighlighter.for('highlight.js')) asciidoctor.SyntaxHighlighter.register(['highlight.js', 'highlightjs'], CustomHighlightJsAdapter)
The asciidoctor.klass.extend would also be useful when we register a converter using an instance.
asciidoctor.klass.extend
Currently, Asciidoctor.js does not provide an API to extend a class. As a result, we need to use Opal low-level API to do so.
We could introduce a third argument on the
SyntaxHighlighter.register
function:Or introduce a generic function: