Skip to content

fix: extension_registry in converter options gets ignored - #30

Merged
saneef merged 3 commits into
mainfrom
fix/deprecate-configure-extension-registry
Jul 1, 2026
Merged

saneef merged 3 commits into
mainfrom
fix/deprecate-configure-extension-registry

Conversation

@saneef

@saneef saneef commented Jul 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

@saneef
saneef force-pushed the fix/deprecate-configure-extension-registry branch from 37335ea to 61a5895 Compare July 1, 2026 11:15
@saneef
saneef force-pushed the fix/deprecate-configure-extension-registry branch from b620728 to de46f94 Compare July 1, 2026 11:21
@saneef saneef changed the title fix: extension_registry converted option is ignored fix: extension_registry in converter options gets ignored Jul 1, 2026
@saneef
saneef merged commit 0fb631f into main Jul 1, 2026
6 checks passed
@saneef
saneef deleted the fix/deprecate-configure-extension-registry branch July 1, 2026 11:22
@tbroyer

tbroyer commented Jul 1, 2026

Copy link
Copy Markdown

Providing an extension_registry means that the extensions are now executed twice (I suppose once from load() and another from convert()) with different options.

When coupled with asciidoctor-kroki, this means that diagrams are downloaded once next to the adoc file, then next to the HTML file.

Reusing a similar repro script as in #14:

mkdir eslint-plugin-asciidoc-pull30-repro
cd !$
npm init -y --init-type=module
npm add -D @11ty/eleventy eleventy-plugin-asciidoc @asciidoctor/core asciidoctor-kroki@1.0.0-beta.1
cat >.eleventy.js <<EOF
import eleventyAsciidoc from "eleventy-plugin-asciidoc";
import asciidoctorKroki from "asciidoctor-kroki";
import { Extensions } from "@asciidoctor/core";

function configure_extension_registry(registry) {
  asciidoctorKroki.register(registry);
}

const extension_registry = Extensions.create();
configure_extension_registry(extension_registry);

export default async function (eleventyConfig) {
  eleventyConfig.addPlugin(eleventyAsciidoc, {
    safe: "unsafe",
//    configure_extension_registry,
    extension_registry,
    attributes: {
      "kroki-fetch-diagram": true,
    },
  });
  eleventyConfig.addPassthroughCopy("foo/*/*");
};
EOF
mkdir -p foo/bar
cat >foo/bar.adoc <<EOF
image:baz.png[]

[mermaid]
....
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
....
EOF
# Dummy "image" file
touch foo/bar/baz.png
# track changes with Git to make it easier to reset to that state
git init
cat >.gitignore <<EOF
/node_modules/
/_site/
EOF
git add .
git commit -m "Initial state"

Now run rm -rf _site/ foo/diag-* && npx eleventy and check where the diag-*.svg files have been emitted (e.g. ls **/diag-*)

You can uncomment configure_extension_registry and comment out extension_registry to see the difference.

Putting some console.log() into node_modules/asciidoctor-kroki/src/fetch.js I saw it was called once without outdir and once with an outdir configured to _site/foo/bar. Adding a console.log() just after the load() shows the first call is from load() and the second from convert() (or at least, once before and once after that log)

Now maybe this is a bug in Asciidoctor.js that shouldn't call the extensions from load(), I'll let you judge 🤷

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants