asciidoctor / asciidoctor-kroki

Asciidoctor.js extension to convert diagrams to images using Kroki!

Home Page:https://kroki.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Antora integration - Error "Opal is not defined"

AndreVirtimo opened this issue · comments

I have an existing Antora (3.0.1) Project and added this extension by:

npm i asciidoctor-kroki

and add the extension to my playbook:

antora:
  extensions:
    - require: '@antora/lunr-extension'
    - asciidoctor-kroki

When I run antora I get an error:

bpc-docs git:(support/3.5.x) ✗ antora --fetch antora-playbook-local.yml --stacktrace
ReferenceError: Opal is not defined
    at register (/Users/andre/Workspace/bpc-docs/node_modules/asciidoctor-kroki/src/asciidoctor-kroki.js:220:20)
    at /Users/andre/Workspace/bpc-docs/node_modules/@antora/site-generator/lib/generator-context.js:149:37
    at Array.forEach (<anonymous>)
    at GeneratorContext._registerExtensions (/Users/andre/Workspace/bpc-docs/node_modules/@antora/site-generator/lib/generator-context.js:142:18)
    at GeneratorContext._init (/Users/andre/Workspace/bpc-docs/node_modules/@antora/site-generator/lib/generator-context.js:131:10)
    at Function.start (/Users/andre/Workspace/bpc-docs/node_modules/@antora/site-generator/lib/generator-context.js:114:34)
    at generateSite (/Users/andre/Workspace/bpc-docs/node_modules/@antora/site-generator/lib/generate-site.js:10:51)
    at Command.<anonymous> (/usr/local/lib/node_modules/@antora/cli/lib/cli.js:76:20)
    at Command.listener [as _actionHandler] (/usr/local/lib/node_modules/@antora/cli/node_modules/commander/index.js:426:31)
    at Command._parseCommand (/usr/local/lib/node_modules/@antora/cli/node_modules/commander/index.js:1002:14)

@mojavelinux I believe the reason is that Asciidoctor.js is not yet loaded. I think we need to defer this call right? Is it bad to call LoggerManager.getLogger() every time the block or inline block macro is called?

The issue here is that you are trying to require an Asciidoctor extension as an Antora extension. These are not the same thing. The declaration in the playbook should be:

asciidoc:
  extensions:
  - asciidoctor-kroki

I'm considering updating Antora to detect the misplaced registration and warn about it.

I completely missed that 🙈
I was mislead by the error message. Thanks for your analysis Dan.

Thank you. I missed that because I already had an antora extension in place, so I added this one.

Now it's working:

antora:
  extensions:
    - require: '@antora/lunr-extension'
asciidoc:
  extensions:
    - asciidoctor-kroki