@astrojs/markdown-remark 6.3.9 → 6.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rehype-images.js +20 -4
- package/package.json +4 -4
package/dist/rehype-images.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit";
|
|
2
|
+
const HAST_PRESERVED_PROPERTIES = [
|
|
3
|
+
// HAST: className -> HTML: class
|
|
4
|
+
"className",
|
|
5
|
+
// HAST: htmlFor -> HTML: for
|
|
6
|
+
"htmlFor"
|
|
7
|
+
];
|
|
2
8
|
function rehypeImages() {
|
|
3
9
|
return function(tree, file) {
|
|
4
10
|
if (!file.data.astro?.localImagePaths?.length && !file.data.astro?.remoteImagePaths?.length) {
|
|
@@ -9,11 +15,11 @@ function rehypeImages() {
|
|
|
9
15
|
if (node.tagName !== "img") return;
|
|
10
16
|
if (typeof node.properties?.src !== "string") return;
|
|
11
17
|
const src = decodeURI(node.properties.src);
|
|
12
|
-
let
|
|
18
|
+
let imageProperties;
|
|
13
19
|
if (file.data.astro?.localImagePaths?.includes(src)) {
|
|
14
|
-
|
|
20
|
+
imageProperties = { ...node.properties, src };
|
|
15
21
|
} else if (file.data.astro?.remoteImagePaths?.includes(src)) {
|
|
16
|
-
|
|
22
|
+
imageProperties = {
|
|
17
23
|
// By default, markdown images won't have width and height set. However, just in case another user plugin does set these, we should respect them.
|
|
18
24
|
inferSize: "width" in node.properties && "height" in node.properties ? void 0 : true,
|
|
19
25
|
...node.properties,
|
|
@@ -22,9 +28,19 @@ function rehypeImages() {
|
|
|
22
28
|
} else {
|
|
23
29
|
return;
|
|
24
30
|
}
|
|
31
|
+
const hastProperties = {};
|
|
32
|
+
for (const key of HAST_PRESERVED_PROPERTIES) {
|
|
33
|
+
if (key in imageProperties) {
|
|
34
|
+
hastProperties[key] = imageProperties[key];
|
|
35
|
+
delete imageProperties[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
25
38
|
const index = imageOccurrenceMap.get(node.properties.src) || 0;
|
|
26
39
|
imageOccurrenceMap.set(node.properties.src, index + 1);
|
|
27
|
-
node.properties = {
|
|
40
|
+
node.properties = {
|
|
41
|
+
...hastProperties,
|
|
42
|
+
__ASTRO_IMAGE_: JSON.stringify({ ...imageProperties, index })
|
|
43
|
+
};
|
|
28
44
|
});
|
|
29
45
|
};
|
|
30
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"hast-util-from-html": "^2.0.3",
|
|
30
30
|
"hast-util-to-text": "^4.0.2",
|
|
31
31
|
"import-meta-resolve": "^4.2.0",
|
|
32
|
-
"js-yaml": "^4.1.
|
|
32
|
+
"js-yaml": "^4.1.1",
|
|
33
33
|
"mdast-util-definitions": "^6.0.0",
|
|
34
34
|
"rehype-raw": "^7.0.0",
|
|
35
35
|
"rehype-stringify": "^10.0.1",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"remark-parse": "^11.0.0",
|
|
38
38
|
"remark-rehype": "^11.1.2",
|
|
39
39
|
"remark-smartypants": "^3.0.2",
|
|
40
|
-
"shiki": "^3.
|
|
41
|
-
"smol-toml": "^1.
|
|
40
|
+
"shiki": "^3.19.0",
|
|
41
|
+
"smol-toml": "^1.5.2",
|
|
42
42
|
"unified": "^11.0.5",
|
|
43
43
|
"unist-util-remove-position": "^5.0.0",
|
|
44
44
|
"unist-util-visit": "^5.0.0",
|