feat(markdown): add configurable loader for external markdown#3902
Open
dschmidt wants to merge 1 commit into
Open
feat(markdown): add configurable loader for external markdown#3902dschmidt wants to merge 1 commit into
dschmidt wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an optional
markdown.loaderconfig that overrides the default XHR fetch fordata-markdownreferences. Useful for authenticated storage, virtual references, or custom resolution relative to the surrounding document.The default XHR path is preserved unchanged, including the
status === 0fallback forfile://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
undefinedinstead of the failing reference: theurlargument inresolve(xhr, url)/reject(xhr, url)was silently dropped, since Promise callbacks only receive the first resolution value.