asciidoctor.js icon indicating copy to clipboard operation
asciidoctor.js copied to clipboard

Make the SyntaxHighlighterBase.$format method easily accessible to syntax highlighters

Open djencks opened this issue 4 years ago • 0 comments

Currently a javascript syntax highlighter format method has to do this to call the 'superclass method':

const toHash = function (object) {
  return object && !object.$$is_hash ? Opal.hash2(Object.keys(object), object) : object
}
return Opal.send(this, Opal.find_super_dispatcher(this, 'format', this.$format), [node, lang, toHash(opts)])

It would be considerably more convenient, and avoid the need to import Opal, if this could be hidden in the superclass/adapter so one could write:

this.super.format(node, lang, opts)

https://gitlab.com/djencks/asciidoctor-highlight.js-build-time could provide a test case.

djencks avatar Feb 28 '21 22:02 djencks