Fix parsing image assets from a Markdown line along with other markup (#7742)
Every regex that tries to match a substring with .* or .+ is guaranteed to be wrong. In this case, it was giving incorrect matches straddling multiple quoted attributes: <img __ASTRO_IMAGE_="../assets/image.png"> and <a href="link">link</a> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Fixes #7741. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
379981efdc
commit
e528526289
2 changed files with 6 additions and 1 deletions
5
.changeset/five-phones-notice.md
Normal file
5
.changeset/five-phones-notice.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix parsing image assets from a Markdown line along with other markup.
|
|
@ -147,7 +147,7 @@ export default function markdown({ settings, logging }: AstroPluginOptions): Plu
|
|||
|
||||
function updateImageReferences(html) {
|
||||
return html.replaceAll(
|
||||
/__ASTRO_IMAGE_=\"(.+)\"/gm,
|
||||
/__ASTRO_IMAGE_="([^"]+)"/gm,
|
||||
(full, imagePath) => spreadAttributes({src: images[imagePath].src, ...images[imagePath].attributes})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue