@readme/markdown 14.11.4 → 14.12.0
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/components/HTMLBlock/index.tsx +12 -10
- package/dist/main.js +2055 -1886
- package/dist/main.node.js +2054 -1885
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/text.d.ts +4 -0
- package/dist/processor/transform/mdxish/components/mdx-blocks.d.ts +4 -0
- package/dist/processor/transform/mdxish/components/utils.d.ts +13 -1
- package/dist/processor/transform/mdxish/mdxish-html-blocks.d.ts +7 -6
- package/dist/processor/transform/mdxish/normalize-closing-tag-whitespace.d.ts +13 -0
- package/dist/processor/transform/mdxish/terminate-html-flow-blocks.d.ts +3 -17
- package/dist/render-fixture.node.js +2055 -1886
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,6 +9,10 @@ export { parseAttributes, parseTag } from '../../../../lib/utils/mdxish/mdxish-c
|
|
|
9
9
|
* This transformer identifies these patterns and converts them to proper MDX JSX elements so they
|
|
10
10
|
* can be accurately recognized and rendered later with their component definition code.
|
|
11
11
|
*
|
|
12
|
+
* Note: The main goal is to promote PascalCase tags to MDX elements, but we want to promote
|
|
13
|
+
* normal HTML to MDX elements in some cases so they get the full custom parsing behavior.
|
|
14
|
+
* E.g. tags with JSX expressions, nested components, etc.
|
|
15
|
+
*
|
|
12
16
|
* The mdx-component micromark tokenizer ensures that multi-line components are captured
|
|
13
17
|
* as single HTML nodes, so this transformer only needs to handle two cases:
|
|
14
18
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Html, PhrasingContent } from 'mdast';
|
|
1
|
+
import type { Html, Node, PhrasingContent } from 'mdast';
|
|
2
2
|
import type { MdxJsxAttribute, MdxJsxExpressionAttribute, MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
|
3
3
|
export type MdxAttributes = (MdxJsxAttribute | MdxJsxExpressionAttribute)[];
|
|
4
4
|
/**
|
|
@@ -29,3 +29,15 @@ export declare const hasExpressionAttr: (attributes: MdxAttributes) => boolean;
|
|
|
29
29
|
* composes children from pre-existing nodes with no outer position.
|
|
30
30
|
*/
|
|
31
31
|
export declare const toMdxJsxTextElement: (name: string, attributes: MdxAttributes, children: PhrasingContent[], position?: Html["position"]) => MdxJsxTextElement;
|
|
32
|
+
export declare const NESTED_TABLE_RE: RegExp;
|
|
33
|
+
export declare const isMarkdownPromotableHtmlTag: (tag: string) => boolean;
|
|
34
|
+
export declare const containsMarkdownConstruct: (nodes: Node[]) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Index of the `</tag>` that balances the already-consumed opening tag (the
|
|
37
|
+
* caller starts us one level deep). `lastIndexOf` mis-slices sibling same-tag
|
|
38
|
+
* pairs like `<div>**a**</div><div>**b**</div>`, so we depth-match instead —
|
|
39
|
+
* delegating to `walkTags` (htmlparser2) so quoted attributes (`title="</div>"`),
|
|
40
|
+
* code spans, and legacy `<<VARIABLE>>` are handled for free. Returns -1 when
|
|
41
|
+
* the wrapper is left open.
|
|
42
|
+
*/
|
|
43
|
+
export declare function findBalancedClosingTagIndex(content: string, tag: string): number;
|
|
@@ -2,13 +2,14 @@ import type { Transform } from 'mdast-util-from-markdown';
|
|
|
2
2
|
/**
|
|
3
3
|
* Converts every `<HTMLBlock>` shape that survives parsing into the canonical
|
|
4
4
|
* `html-block` MDAST node, reading the body from the tokenizer's template-literal
|
|
5
|
-
* expression.
|
|
5
|
+
* expression. Two shapes occur:
|
|
6
6
|
*
|
|
7
|
-
* 1. JSX element (`mdxJsxFlowElement`/`mdxJsxTextElement`) —
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* 1. JSX element (`mdxJsxFlowElement`/`mdxJsxTextElement`) — table cells, after
|
|
8
|
+
* their remarkMdx re-parse (that re-parse runs without the htmlBlockComponent
|
|
9
|
+
* tokenizer, so `<HTMLBlock>` arrives as JSX rather than an opaque `html` node).
|
|
10
|
+
* 2. Raw `html` blob (`splitRawHtmlBlocks`) — the htmlBlockComponent tokenizer's
|
|
11
|
+
* opaque output (top-level and inline), or an `<HTMLBlock>` embedded in a
|
|
12
|
+
* larger raw-HTML node like an inline `<div>` that the tokenizer never saw.
|
|
12
13
|
*
|
|
13
14
|
* Runs *after* `mdxishTables` so table cells are re-parsed first;
|
|
14
15
|
* `mdxishTables` recognizes the still-JSX `<HTMLBlock>` element when deciding to
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonicalize spaced closing tags (`</ td >` → `</td>`) for known HTML names.
|
|
3
|
+
*
|
|
4
|
+
* In HTML, `</` + whitespace is a bogus comment, so `</ table >` never closes the
|
|
5
|
+
* table (jsxTable misses it → empty table + pre; CX-3706). Only standard HTML tags;
|
|
6
|
+
* custom components, prose (`a </ b`), and code blocks are left alone.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* normalizeClosingTagWhitespace('</ td >') // '</td>'
|
|
10
|
+
* normalizeClosingTagWhitespace('</table >') // '</table>'
|
|
11
|
+
* normalizeClosingTagWhitespace('a </ b >') // unchanged
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeClosingTagWhitespace(content: string): string;
|
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* Without one, any content on the next line is consumed as part of the HTML block
|
|
6
|
-
* and never parsed as its own construct. For example, a `[block:callout]` immediately
|
|
7
|
-
* following `<div><p></p></div>` gets swallowed into the HTML flow token.
|
|
2
|
+
* CommonMark HTML blocks (types 6/7) end only at a blank line, so markdown on the
|
|
3
|
+
* next line is swallowed as HTML (`## heading` after `<div>` renders as literal text).
|
|
4
|
+
* Inserts the missing blank line; the gating rules live in `shouldTerminateBetween`.
|
|
8
5
|
*
|
|
9
6
|
* @link https://spec.commonmark.org/0.29/#html-blocks
|
|
10
|
-
*
|
|
11
|
-
* This preprocessor inserts a blank line after standalone HTML lines when the next
|
|
12
|
-
* line is non-blank and not an HTML construct, ensuring micromark's HTML flow
|
|
13
|
-
* tokenizer terminates and subsequent content is parsed independently.
|
|
14
|
-
*
|
|
15
|
-
* Conditions:
|
|
16
|
-
* 1. Only non-indented lines with lowercase tag names are considered. Uppercase tags
|
|
17
|
-
* (e.g. `<Table>`, `<MyComponent>`) are JSX custom components and don't trigger
|
|
18
|
-
* CommonMark HTML blocks.
|
|
19
|
-
* 2. Lines inside protected blocks (e.g. fenced code) are left untouched.
|
|
20
|
-
* 3. Lines with an unclosed RAW_CONTENT_TAGS opener are exempted.
|
|
21
7
|
*/
|
|
22
8
|
export declare function terminateHtmlFlowBlocks(content: string): string;
|