Skip to content

feat(markdown): add configurable loader for external markdown#3902

Open
dschmidt wants to merge 1 commit into
hakimel:masterfrom
dschmidt:feat/markdown-loader-option
Open

feat(markdown): add configurable loader for external markdown#3902
dschmidt wants to merge 1 commit into
hakimel:masterfrom
dschmidt:feat/markdown-loader-option

Conversation

@dschmidt
Copy link
Copy Markdown

@dschmidt dschmidt commented May 20, 2026

Adds an optional markdown.loader config that overrides the default XHR fetch for data-markdown references. Useful for authenticated storage, virtual references, or custom resolution relative to the surrounding document.

The default XHR path is preserved unchanged, including the status === 0 fallback for file:// sources. Tests cover the override (deck 7) and synchronous loader throws rendering as alert sections (deck 8).

Also fixes a latent bug where the error alert showed undefined instead of the failing reference: the url argument in resolve(xhr, url) / reject(xhr, url) was silently dropped, since Promise callbacks only receive the first resolution value.

Adds an optional `markdown.loader` config function that overrides the
default XHR-based fetch for `data-markdown` references. The loader
receives the raw attribute value and the section element, returning
content as a string or Promise<string>.

The existing XHR path is preserved as defaultMarkdownLoader, including
the status===0 fallback for file:// and non-HTTP sources. The
loadExternalMarkdown contract is simplified to resolve with a string
and reject with an Error.

Tests cover the override path and synchronous loader throws rendering
as an alert section.
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.

1 participant