@readme/markdown 14.0.0 → 14.1.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.
@@ -5,5 +5,6 @@ declare const components: {
5
5
  TailwindRootTest: string;
6
6
  Steps: string;
7
7
  DarkMode: string;
8
+ Snake_case_component: string;
8
9
  };
9
10
  export default components;
@@ -15,7 +15,7 @@ export declare const FLOW_TYPES: Set<string>;
15
15
  * paragraph nodes. Excluding them from the generic `mdxComponent` micromark
16
16
  * construct lets the dedicated inline transformer handle them instead.
17
17
  *
18
- * @see processor/transform/mdxish/mdxish-inline-components.ts
18
+ * @see processor/transform/mdxish/components/inline-mdx-blocks.ts
19
19
  */
20
20
  export declare const INLINE_COMPONENT_TAGS: Set<string>;
21
21
  /**
@@ -1,10 +1,8 @@
1
1
  import type { CustomComponents, Variables } from '../types';
2
2
  import type { Root } from 'hast';
3
3
  import type { Root as MdastRoot } from 'mdast';
4
- import { type JSXContext } from '../processor/transform/mdxish/preprocess-jsx-expressions';
5
4
  export interface MdxishOpts {
6
5
  components?: CustomComponents;
7
- jsxContext?: JSXContext;
8
6
  newEditorTypes?: boolean;
9
7
  /**
10
8
  * When enabled, the pipeline ignores all expression syntax `{...}`.
@@ -6,18 +6,25 @@ declare module 'micromark-util-types' {
6
6
  }
7
7
  }
8
8
  /**
9
- * Micromark extension that tokenizes PascalCase MDX components as single
10
- * flow blocks.
9
+ * Micromark extension that tokenizes MDX-like components.
11
10
  *
12
- * Captures `<Component ...>...</Component>` (including self-closing
13
- * `<Component />`) in their entirety, preventing CommonMark from
14
- * fragmenting them across multiple HTML / paragraph nodes.
11
+ * **Flow (block)** captures 1) PascalCase components and 2) lowercase HTML tags
12
+ * that carry `{…}` attribute expressions as single flow blocks (including
13
+ * self-closing `<Component />`). Prevents CommonMark from fragmenting them
14
+ * across multiple HTML / paragraph nodes.
15
15
  *
16
- * Excludes tags handled by dedicated tokenizers: Table, HTMLBlock,
17
- * Glossary, Anchor.
16
+ * **Text (inline)** registers only for lowercase tags with brace attrs
17
+ * (e.g. `Start <a href={url}>here</a> end`). Picks them up during inline
18
+ * parsing so they render inline inside their paragraph, then are rewritten
19
+ * to `mdxJsxTextElement` by the `components/inline-html` transformer.
20
+ * PascalCase is intentionally flow-only; ReadMe's custom components are
21
+ * authored as block-level elements.
18
22
  *
19
- * The tokenizer claims the block atomically; the resulting `html` mdast
20
- * node is later restructured into an `mdxJsxFlowElement` by the
21
- * `mdxish-component-blocks` transformer.
23
+ * Excludes tags handled by dedicated tokenizers: Table, HTMLBlock, Glossary,
24
+ * Anchor.
25
+ *
26
+ * The resulting `html` mdast node is later restructured into an
27
+ * `mdxJsxFlowElement` (block) or `mdxJsxTextElement` (inline) by the
28
+ * corresponding component-block transformer.
22
29
  */
23
30
  export declare function mdxComponent(): Extension;
@@ -0,0 +1,33 @@
1
+ import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
2
+ export interface ParseAttributesOptions {
3
+ /**
4
+ * When true, attribute expressions (`attr={expr}`) are kept as literal strings with
5
+ * their braces so downstream consumers don't evaluate them. This preserves safeMode
6
+ * semantics where all expression syntax is ignored.
7
+ */
8
+ preserveExpressionsAsText?: boolean;
9
+ }
10
+ /**
11
+ * Convert raw attribute string into mdxJsxAttribute entries using a single-pass
12
+ * character-walking tokenizer. Handles arbitrary brace nesting depth.
13
+ *
14
+ * Supports:
15
+ * - Boolean attributes: `empty` → value: null
16
+ * - Quoted attributes: `attr="value"` or `attr='value'` → value: string
17
+ * - Expression attributes: `attr={expr}` → value: MdxJsxAttributeValueExpression
18
+ * - Unquoted attributes: `attr=value` → value: string
19
+ */
20
+ export declare const parseAttributes: (raw: string, opts?: ParseAttributesOptions) => MdxJsxAttribute[];
21
+ /**
22
+ * Parse an HTML tag string into structured data.
23
+ * Uses a simple regex for the tag name, then a character walker to find the
24
+ * closing `>` so that brace expressions and quoted strings inside attributes
25
+ * are handled correctly at any nesting depth.
26
+ */
27
+ export declare const parseTag: (value: string, opts?: ParseAttributesOptions) => {
28
+ tag: string;
29
+ attributes: MdxJsxAttribute[];
30
+ selfClosing: boolean;
31
+ contentAfterTag: string;
32
+ attrString: string;
33
+ };