@readme/markdown 14.11.5 → 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.
@@ -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. Three shapes occur:
5
+ * expression. Two shapes occur:
6
6
  *
7
- * 1. JSX element (`mdxJsxFlowElement`/`mdxJsxTextElement`) — multiline/block
8
- * context and table cells (after their remarkMdx re-parse).
9
- * 2. Raw `html` blob (`splitRawHtmlBlocks`) single-line top-level, or nested
10
- * in raw HTML like an inline `<div>`.
11
- * 3. Inline-in-paragraph split into `html` + expression + `html` siblings.
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;