feat(markdown): Add support for imageReference
paths when collecting images
#8475
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.
Usually images in Markdown are authored like so:
Yet they can also use an
imageReference
with adefinition
:Both syntaxes work fine when it comes to rendering HTML, but images referenced in the second form are not collected in
remarkCollectImages()
as that only catchesimage
nodes, but notimageReference
nodes.Changes
This PR adds a unit test for the former, and support and a unit test for the latter.
Did not measure, but the impact on performance should be minimal. Also see the note with the relevant code.
Testing
This PR contains a test for existing functionality to assert image collection, and adds a test for the new functionality.
Docs
/cc @withastro/maintainers-docs for feedback!
Since I had all my images in the yet unsupported syntax, it I didn't see why my images weren't rendered at all. Also because the docs on images do not include an example with an image in the same directory as the Markdown file (yet I did have warnings in the console).
Accepting this PR will make all the problems go away ✨