@mirrordown/remd-unwrap-images 0.1.2 → 0.1.4

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 CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
 
4
4
 
5
+
6
+
7
+ ## 0.1.4
8
+ <sub>2026-10-28</sub>
9
+
10
+ - *(patch)*
11
+ Sätteri ports of the hast plugins: `@mirrordown/sat-squeeze-paragraphs`, `sat-unwrap-images`, `sat-sectionize`, `sat-lightbox` and `sat-autolink-headings`, all included in `@mirrordown/preset-satteri` (whose stylesheet now also imports the lightbox and autolink-headings styles). Their output is identical to the markdown-it and rehype plugins'. `sat-autolink-headings` takes the same options as `remd-autolink-headings`, including the hast-node ones (`content`, `group`, `properties`, `headingProperties`, `test`).
12
+
13
+ The rules these engines must compute identically move into `@mirrordown/core` (`isEmptyParagraph`, `isImageParagraph`, `sectionize`, `headingRank`, and the lightbox's marker, ids and markup), which the rehype plugins now use too; their output is unchanged, and squeeze-paragraphs and unwrap-images drop `hast-util-whitespace`.
14
+
15
+ ## 0.1.3
16
+ <sub>2026-06-28</sub>
17
+
18
+ - *(patch)*
19
+ 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.
20
+
5
21
  ## 0.1.2
6
22
  <sub>2026-06-28</sub>
7
23
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mirrordown/remd-unwrap-images
2
2
 
3
- > Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified and markdown-it ecosystems.
3
+ > Part of [Mirrordown](https://github.com/mirrordown/mirrordown) — a suite of markdown syntax extensions for the unified, markdown-it and Sätteri ecosystems.
4
4
 
5
5
  A remark/rehype (unified) plugin for the `unwrap-images` syntax extension.
6
6
 
@@ -9,31 +9,29 @@ A remark/rehype (unified) plugin for the `unwrap-images` syntax extension.
9
9
  The `unwrap-images` plugin removes the `<p>` wrapper that Markdown adds around standalone images, allowing images to render as direct block-level elements. Images inside links are also unwrapped.
10
10
 
11
11
  **Before:**
12
-
13
12
  ```html
14
- <p><img src="photo.jpg" alt="A photo" /></p>
13
+ <p><img src="photo.jpg" alt="A photo"></p>
15
14
  ```
16
15
 
17
16
  **After:**
18
-
19
17
  ```html
20
- <img src="photo.jpg" alt="A photo" />
18
+ <img src="photo.jpg" alt="A photo">
21
19
  ```
22
20
 
23
21
  ## Syntax
24
22
 
25
23
  Any image that stands alone on a paragraph — with no other text or inline content — is unwrapped:
26
24
 
27
- ```markdown
25
+ ````markdown
28
26
  ![An example image](https://picsum.photos/400/200)
29
27
 
30
28
  Images mixed with text are **not** unwrapped:
31
29
 
32
30
  Here is an inline image: ![icon](https://picsum.photos/16/16) within a sentence.
33
- ```
31
+ ````
34
32
 
35
- [!NOTE]
36
- This is a rehype plugin (`rehype-*`), not a remark plugin. Add it **after** `remarkRehype` in your pipeline.
33
+ > [!NOTE]
34
+ > This is a rehype plugin (`rehype-*`), not a remark plugin. Add it **after** `remarkRehype` in your pipeline.
37
35
 
38
36
  ## Install
39
37
 
@@ -66,22 +64,8 @@ import { rehypeUnwrapImages } from "@mirrordown/remd-unwrap-images";
66
64
 
67
65
  export default defineConfig({
68
66
  markdown: {
69
- rehypePlugins: [rehypeUnwrapImages]
70
- }
71
- });
72
- ```
73
-
74
- ### VitePress
75
-
76
- ```ts
77
- // .vitepress/config.ts
78
- import { defineConfig } from "vitepress";
79
- import { rehypeUnwrapImages } from "@mirrordown/remd-unwrap-images";
80
-
81
- export default defineConfig({
82
- markdown: {
83
- rehypePlugins: [rehypeUnwrapImages]
84
- }
67
+ rehypePlugins: [rehypeUnwrapImages],
68
+ },
85
69
  });
86
70
  ```
87
71
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,5 @@
1
1
  import { Root } from "hast";
2
2
  import { Plugin } from "unified";
3
-
4
- //#region src/index.d.ts
5
- declare const rehypeUnwrapImages: Plugin<[], Root>;
6
- //#endregion
7
- export { rehypeUnwrapImages };
3
+ /** rehype plugin that unwraps block-level images out of their paragraph. The rule is shared with the Sätteri plugin through `@mirrordown/core`. */
4
+ export declare const rehypeUnwrapImages: Plugin<[], Root>;
8
5
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;cAsCa,kBAAA,EAAoB,MAAA,KAAW,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;qBAMa,oBAAoB,WAAW"}
package/dist/index.mjs CHANGED
@@ -1,37 +1,15 @@
1
1
  import { SKIP, visit } from "unist-util-visit";
2
- import { whitespace } from "hast-util-whitespace";
3
- //#region src/index.ts
4
- const UNKNOWN = 1;
5
- const HAS_IMAGE = 2;
6
- const HAS_OTHER = 3;
7
- const applicable = (node, inLink) => {
8
- let result = UNKNOWN;
9
- for (const child of node.children) {
10
- if (child.type === "text" && whitespace(child.value)) continue;
11
- if (child.type !== "element") return HAS_OTHER;
12
- if (child.tagName === "img") {
13
- result = HAS_IMAGE;
14
- continue;
15
- }
16
- if (!inLink && (child.tagName === "a" || child.tagName === "button")) {
17
- const inner = applicable(child, true);
18
- if (inner === HAS_OTHER) return HAS_OTHER;
19
- if (inner === HAS_IMAGE) result = HAS_IMAGE;
20
- continue;
21
- }
22
- return HAS_OTHER;
23
- }
24
- return result;
25
- };
2
+ import { isImageParagraph } from "@mirrordown/core";
3
+ // src/index.ts
4
+ /** rehype plugin that unwraps block-level images out of their paragraph. The rule is shared with the Sätteri plugin through `@mirrordown/core`. */
26
5
  const rehypeUnwrapImages = () => (tree) => {
27
6
  visit(tree, "element", (node, index, parent) => {
28
- if (node.tagName === "p" && parent && typeof index === "number" && applicable(node, false) === HAS_IMAGE) {
7
+ if (parent && typeof index === "number" && isImageParagraph(node)) {
29
8
  parent.children.splice(index, 1, ...node.children);
30
9
  return [SKIP, index];
31
10
  }
32
11
  });
33
12
  };
34
- //#endregion
35
13
  export { rehypeUnwrapImages };
36
14
 
37
15
  //# sourceMappingURL=index.mjs.map
@@ -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;;AAGT,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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { SKIP, visit } from \"unist-util-visit\";\nimport { isImageParagraph } from \"@mirrordown/core\";\nimport type { Root } from \"hast\";\nimport type { Plugin } from \"unified\";\n\n/** rehype plugin that unwraps block-level images out of their paragraph. The rule is shared with the Sätteri plugin through `@mirrordown/core`. */\nexport const rehypeUnwrapImages: Plugin<[], Root> = () => (tree) => {\n visit(tree, \"element\", (node, index, parent) => {\n if (parent && typeof index === \"number\" && isImageParagraph(node)) {\n parent.children.splice(index, 1, ...node.children);\n return [SKIP, index];\n }\n return;\n });\n};\n"],"mappings":";;;;AAMA,MAAa,4BAA8C,SAAS;CAClE,MAAM,MAAM,YAAY,MAAM,OAAO,WAAW;EAC9C,IAAI,UAAU,OAAO,UAAU,YAAY,iBAAiB,IAAI,GAAG;GACjE,OAAO,SAAS,OAAO,OAAO,GAAG,GAAG,KAAK,QAAQ;GACjD,OAAO,CAAC,MAAM,KAAK;EACrB;CAEF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@mirrordown/remd-unwrap-images",
3
- "version": "0.1.2",
3
+ "description": "A remark plugin for unwrapping block-level images out of their surrounding paragraph.",
4
+ "version": "0.1.4",
4
5
  "license": "MIT",
5
6
  "author": "Drake Costa <drake@saeris.io> (https://saeris.gg)",
6
7
  "repository": {
@@ -19,7 +20,7 @@
19
20
  }
20
21
  },
21
22
  "dependencies": {
22
- "hast-util-whitespace": "^3.0.0",
23
+ "@mirrordown/core": "^0.1.0",
23
24
  "unist-util-visit": "^5.1.0"
24
25
  },
25
26
  "devDependencies": {
@@ -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
- "yarn pack -o package.tgz",
40
- "npm publish package.tgz --access public",
41
- "npx jsr publish --allow-dirty --allow-slow-types"
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
  }