@readme/markdown 13.7.2 → 13.7.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.
@@ -8,8 +8,8 @@
8
8
  * @returns The concatenated text content
9
9
  */
10
10
  export declare const extractText: (node: {
11
+ alt?: unknown;
11
12
  children?: unknown[];
12
13
  type?: string;
13
14
  value?: unknown;
14
- alt?: unknown;
15
15
  }) => string;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * String-level preprocessor that converts self-closing non-void HTML tags
3
+ * into explicitly closed tags.
4
+ *
5
+ * Problem: `rehype-raw` (via parse5) follows the HTML spec where the `/` in
6
+ * `<i />` is ignored for non-void elements. This causes `<i />` to be parsed
7
+ * as an opening `<i>` tag, which then wraps all subsequent content.
8
+ *
9
+ * Solution: Transform `<i />` → `<i></i>` before parsing, so rehype-raw
10
+ * sees a properly closed element.
11
+ *
12
+ * This preprocessor:
13
+ * - Skips void elements (`<br />`, `<hr />`, `<img />`, etc.)
14
+ * - Skips PascalCase tags (custom components handled elsewhere)
15
+ * - Protects code blocks from transformation
16
+ *
17
+ * @example
18
+ * closeSelfClosingHtmlTags('<i/> text') // '<i></i> text'
19
+ * closeSelfClosingHtmlTags('<br />') // '<br />' (void, untouched)
20
+ * closeSelfClosingHtmlTags('<MyComp />') // '<MyComp />' (PascalCase, untouched)
21
+ * closeSelfClosingHtmlTags('<i class="icon" />') // '<i class="icon"></i>'
22
+ */
23
+ export declare function closeSelfClosingHtmlTags(content: string): string;
@@ -110,15 +110,3 @@ export interface MagicBlockEmbed {
110
110
  position?: Position;
111
111
  type: 'embed';
112
112
  }
113
- /**
114
- * Figure node that may contain an image (from magicBlockTransformer with caption).
115
- * This is an intermediate format before conversion to Figure.
116
- */
117
- export interface MagicBlockFigure {
118
- children: RootContent[];
119
- data?: {
120
- hName?: string;
121
- };
122
- position?: Position;
123
- type: 'figure';
124
- }
@@ -1,13 +1,15 @@
1
1
  import type { Parent } from 'mdast';
2
2
  import type { Plugin } from 'unified';
3
3
  /**
4
- * Transform mdxJsxFlowElement nodes and magic block nodes into proper MDAST node types.
4
+ * Transform mdxJsxFlowElement nodes, magic block nodes, and HTML figure elements
5
+ * into proper MDAST node types.
5
6
  *
6
7
  * This transformer runs after mdxishComponentBlocks and converts:
7
- * - JSX component elements (Image, Callout, Embed, Recipe) into their corresponding MDAST types
8
+ * - JSX component elements (Image, Callout, Embed, Recipe, figure) into their corresponding MDAST types
8
9
  * - Magic block image nodes (type: 'image') into image-block
9
10
  * - Magic block embed nodes (type: 'embed') into embed-block
10
- * - Figure nodes (magic blocks with captions) into flat image-block with caption string
11
+ * - Fragmented HTML <figure> blocks (from terminateHtmlFlowBlocks) back into figure nodes
12
+ * - Figure nodes (from magic blocks, HTML, or JSX) into flat image-block with caption string
11
13
  * - Normalizes all image-block attrs (border, align, sizing, caption) to a consistent shape
12
14
  *
13
15
  * This is controlled by the `newEditorTypes` flag to maintain backwards compatibility.
@@ -0,0 +1,15 @@
1
+ import type { RootContent } from 'mdast';
2
+ import type { Position } from 'unist';
3
+ /**
4
+ * Intermediate figure node before conversion to the final Figure type.
5
+ * Produced by magicBlockTransformer (for magic block images with captions)
6
+ * and by reassembleHtmlFigures (for raw HTML <figure> elements).
7
+ */
8
+ export interface FigureNode {
9
+ children: RootContent[];
10
+ data?: {
11
+ hName?: string;
12
+ };
13
+ position?: Position;
14
+ type: 'figure';
15
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@readme/markdown",
3
3
  "description": "ReadMe's React-based Markdown parser",
4
4
  "author": "Rafe Goldberg <rafe@readme.io>",
5
- "version": "13.7.2",
5
+ "version": "13.7.4",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",
@@ -169,7 +169,7 @@
169
169
  },
170
170
  {
171
171
  "path": "dist/main.node.js",
172
- "maxSize": "855KB"
172
+ "maxSize": "860KB"
173
173
  }
174
174
  ]
175
175
  },