Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an API to extend a built-in converter or syntax highlighter #1418

Open
ggrossetie opened this issue Sep 11, 2021 · 1 comment
Open

Comments

@ggrossetie
Copy link
Member

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:

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)
@ggrossetie
Copy link
Member Author

The asciidoctor.klass.extend would also be useful when we register a converter using an instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant