@mirrordown/remd-unwrap-images 0.1.2 → 0.1.3
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/CHANGELOG.md +7 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
## 0.1.3
|
|
7
|
+
<sub>2026-06-28</sub>
|
|
8
|
+
|
|
9
|
+
- *(patch)*
|
|
10
|
+
Improve JSR package scores: add package descriptions, document all exported symbols (JSDoc), add READMEs for the inline-svg packages, clear slow-type errors on the exported hast handlers, and trim internal regex constants from the public API.
|
|
11
|
+
|
|
5
12
|
## 0.1.2
|
|
6
13
|
<sub>2026-06-28</sub>
|
|
7
14
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { Root } from "hast";
|
|
|
2
2
|
import { Plugin } from "unified";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
|
+
/** rehype plugin that unwraps block-level images out of their paragraph. */
|
|
5
6
|
declare const rehypeUnwrapImages: Plugin<[], Root>;
|
|
6
7
|
//#endregion
|
|
7
8
|
export { rehypeUnwrapImages };
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;cAuCa,kBAAA,EAAoB,MAAA,KAAW,IAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -23,6 +23,7 @@ const applicable = (node, inLink) => {
|
|
|
23
23
|
}
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
|
+
/** rehype plugin that unwraps block-level images out of their paragraph. */
|
|
26
27
|
const rehypeUnwrapImages = () => (tree) => {
|
|
27
28
|
visit(tree, "element", (node, index, parent) => {
|
|
28
29
|
if (node.tagName === "p" && parent && typeof index === "number" && applicable(node, false) === HAS_IMAGE) {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { SKIP, visit } from \"unist-util-visit\";\nimport { whitespace } from \"hast-util-whitespace\";\nimport type { Element, Root } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nconst UNKNOWN = 1 as const;\nconst HAS_IMAGE = 2 as const;\nconst HAS_OTHER = 3 as const;\ntype ApplicableResult = typeof UNKNOWN | typeof HAS_IMAGE | typeof HAS_OTHER;\n\n// Returns HAS_IMAGE if node's children are only images/whitespace (possibly\n// wrapped in a link), UNKNOWN if empty/whitespace-only, HAS_OTHER otherwise.\nconst applicable = (node: Element, inLink: boolean): ApplicableResult => {\n let result: ApplicableResult = UNKNOWN;\n\n for (const child of node.children) {\n if (child.type === \"text\" && whitespace(child.value)) continue;\n\n if (child.type !== \"element\") return HAS_OTHER;\n\n if (child.tagName === \"img\") {\n result = HAS_IMAGE;\n continue;\n }\n\n if (!inLink && (child.tagName === \"a\" || child.tagName === \"button\")) {\n const inner = applicable(child, true);\n if (inner === HAS_OTHER) return HAS_OTHER;\n if (inner === HAS_IMAGE) result = HAS_IMAGE;\n continue;\n }\n\n return HAS_OTHER;\n }\n\n return result;\n};\n\nexport const rehypeUnwrapImages: Plugin<[], Root> = () => (tree) => {\n visit(tree, \"element\", (node, index, parent) => {\n if (\n node.tagName === \"p\" &&\n parent &&\n typeof index === \"number\" &&\n applicable(node, false) === HAS_IMAGE\n ) {\n parent.children.splice(index, 1, ...node.children);\n return [SKIP, index];\n }\n return;\n });\n};\n"],"mappings":";;;AAKA,MAAM,UAAU;AAChB,MAAM,YAAY;AAClB,MAAM,YAAY;AAKlB,MAAM,cAAc,MAAe,WAAsC;CACvE,IAAI,SAA2B;AAE/B,MAAK,MAAM,SAAS,KAAK,UAAU;AACjC,MAAI,MAAM,SAAS,UAAU,WAAW,MAAM,MAAM,CAAE;AAEtD,MAAI,MAAM,SAAS,UAAW,QAAO;AAErC,MAAI,MAAM,YAAY,OAAO;AAC3B,YAAS;AACT;;AAGF,MAAI,CAAC,WAAW,MAAM,YAAY,OAAO,MAAM,YAAY,WAAW;GACpE,MAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,OAAI,UAAU,UAAW,QAAO;AAChC,OAAI,UAAU,UAAW,UAAS;AAClC;;AAGF,SAAO;;AAGT,QAAO
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { SKIP, visit } from \"unist-util-visit\";\nimport { whitespace } from \"hast-util-whitespace\";\nimport type { Element, Root } from \"hast\";\nimport type { Plugin } from \"unified\";\n\nconst UNKNOWN = 1 as const;\nconst HAS_IMAGE = 2 as const;\nconst HAS_OTHER = 3 as const;\ntype ApplicableResult = typeof UNKNOWN | typeof HAS_IMAGE | typeof HAS_OTHER;\n\n// Returns HAS_IMAGE if node's children are only images/whitespace (possibly\n// wrapped in a link), UNKNOWN if empty/whitespace-only, HAS_OTHER otherwise.\nconst applicable = (node: Element, inLink: boolean): ApplicableResult => {\n let result: ApplicableResult = UNKNOWN;\n\n for (const child of node.children) {\n if (child.type === \"text\" && whitespace(child.value)) continue;\n\n if (child.type !== \"element\") return HAS_OTHER;\n\n if (child.tagName === \"img\") {\n result = HAS_IMAGE;\n continue;\n }\n\n if (!inLink && (child.tagName === \"a\" || child.tagName === \"button\")) {\n const inner = applicable(child, true);\n if (inner === HAS_OTHER) return HAS_OTHER;\n if (inner === HAS_IMAGE) result = HAS_IMAGE;\n continue;\n }\n\n return HAS_OTHER;\n }\n\n return result;\n};\n\n/** rehype plugin that unwraps block-level images out of their paragraph. */\nexport const rehypeUnwrapImages: Plugin<[], Root> = () => (tree) => {\n visit(tree, \"element\", (node, index, parent) => {\n if (\n node.tagName === \"p\" &&\n parent &&\n typeof index === \"number\" &&\n applicable(node, false) === HAS_IMAGE\n ) {\n parent.children.splice(index, 1, ...node.children);\n return [SKIP, index];\n }\n return;\n });\n};\n"],"mappings":";;;AAKA,MAAM,UAAU;AAChB,MAAM,YAAY;AAClB,MAAM,YAAY;AAKlB,MAAM,cAAc,MAAe,WAAsC;CACvE,IAAI,SAA2B;AAE/B,MAAK,MAAM,SAAS,KAAK,UAAU;AACjC,MAAI,MAAM,SAAS,UAAU,WAAW,MAAM,MAAM,CAAE;AAEtD,MAAI,MAAM,SAAS,UAAW,QAAO;AAErC,MAAI,MAAM,YAAY,OAAO;AAC3B,YAAS;AACT;;AAGF,MAAI,CAAC,WAAW,MAAM,YAAY,OAAO,MAAM,YAAY,WAAW;GACpE,MAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,OAAI,UAAU,UAAW,QAAO;AAChC,OAAI,UAAU,UAAW,UAAS;AAClC;;AAGF,SAAO;;AAGT,QAAO;;;AAIT,MAAa,4BAA8C,SAAS;AAClE,OAAM,MAAM,YAAY,MAAM,OAAO,WAAW;AAC9C,MACE,KAAK,YAAY,OACjB,UACA,OAAO,UAAU,YACjB,WAAW,MAAM,MAAM,KAAK,WAC5B;AACA,UAAO,SAAS,OAAO,OAAO,GAAG,GAAG,KAAK,SAAS;AAClD,UAAO,CAAC,MAAM,MAAM;;GAGtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mirrordown/remd-unwrap-images",
|
|
3
|
-
"
|
|
3
|
+
"description": "A remark plugin for unwrapping block-level images out of their surrounding paragraph.",
|
|
4
|
+
"version": "0.1.3",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
|
|
6
7
|
"repository": {
|
|
@@ -33,12 +34,11 @@
|
|
|
33
34
|
"node": ">=24.0.0"
|
|
34
35
|
},
|
|
35
36
|
"bumpy": {
|
|
36
|
-
"buildCommand": "vp pack",
|
|
37
37
|
"publishCommand": [
|
|
38
38
|
"node ../../scripts/sync-jsr-version.mjs",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
39
|
+
"node ../../scripts/npm-publish.mjs",
|
|
40
|
+
"node ../../scripts/jsr-resolve-deps.mjs",
|
|
41
|
+
"node ../../scripts/jsr-publish.mjs"
|
|
42
42
|
]
|
|
43
43
|
}
|
|
44
44
|
}
|