@readme/markdown 11.10.1 → 11.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.
@@ -1,6 +1,6 @@
1
- import type { JSXContext } from './preprocess-jsx-expressions';
2
1
  import type { Root } from 'mdast';
3
2
  import type { Plugin } from 'unified';
3
+ import { type JSXContext } from './preprocess-jsx-expressions';
4
4
  /**
5
5
  * AST transformer to evaluate MDX expressions using the provided context.
6
6
  * Replaces mdxFlowExpression and mdxTextExpression nodes with their evaluated values.
@@ -0,0 +1,16 @@
1
+ export type SnakeCaseMapping = Record<string, string>;
2
+ export interface SnakeCasePreprocessResult {
3
+ content: string;
4
+ mapping: SnakeCaseMapping;
5
+ }
6
+ /**
7
+ * Replaces snake_case component names with valid HTML placeholders.
8
+ * Required because remark-parse rejects tags with underscores.
9
+ * Example: `<Snake_case />` → `<MDXishSnakeCase0 />`
10
+ */
11
+ export declare function processSnakeCaseComponent(content: string): SnakeCasePreprocessResult;
12
+ /**
13
+ * Restores placeholder name to original snake_case name.
14
+ * Uses case-insensitive matching since HTML parsers normalize to lowercase.
15
+ */
16
+ export declare function restoreSnakeCase(placeholderName: string, mapping: SnakeCaseMapping): string;
@@ -0,0 +1,15 @@
1
+ import type { Plugin } from 'unified';
2
+ /**
3
+ * A remark plugin that normalizes malformed bold and italic markers in text nodes.
4
+ * Detects patterns like `** bold**`, `Hello** Wrong Bold**`, `__ bold__`, `Hello__ Wrong Bold__`,
5
+ * `* italic*`, `Hello* Wrong Italic*`, `_ italic_`, or `Hello_ Wrong Italic_`
6
+ * and converts them to proper strong/emphasis nodes, matching the behavior of the legacy rdmd engine.
7
+ *
8
+ * Supports both asterisk (`**bold**`, `*italic*`) and underscore (`__bold__`, `_italic_`) syntax.
9
+ * Also supports snake_case content like `** some_snake_case**`.
10
+ *
11
+ * This runs after remark-parse, which (in v11+) is strict and doesn't parse
12
+ * malformed emphasis syntax. This plugin post-processes the AST to handle these cases.
13
+ */
14
+ declare const normalizeEmphasisAST: Plugin;
15
+ export default normalizeEmphasisAST;
@@ -1,11 +1,25 @@
1
+ export declare function base64Decode(str: string): string;
2
+ export declare const HTML_BLOCK_CONTENT_START = "<!--RDMX_HTMLBLOCK:";
3
+ export declare const HTML_BLOCK_CONTENT_END = ":RDMX_HTMLBLOCK-->";
1
4
  /**
2
5
  * Pre-processes JSX-like expressions before markdown parsing.
3
6
  * Converts href={'value'} to href="value", evaluates {expressions}, etc.
4
7
  */
5
8
  export type JSXContext = Record<string, unknown>;
6
- export declare function base64Decode(str: string): string;
7
- export declare const HTML_BLOCK_CONTENT_START = "<!--RDMX_HTMLBLOCK:";
8
- export declare const HTML_BLOCK_CONTENT_END = ":RDMX_HTMLBLOCK-->";
9
+ /**
10
+ * Evaluates a JavaScript expression using context variables.
11
+ *
12
+ * @param expression
13
+ * @param context
14
+ * @returns The evaluated result
15
+ * @example
16
+ * ```typescript
17
+ * const context = { baseUrl: 'https://example.com', path: '/api' };
18
+ * evaluateExpression('baseUrl + path', context)
19
+ * // Returns: 'https://example.com/api'
20
+ * ```
21
+ */
22
+ export declare function evaluateExpression(expression: string, context: JSXContext): any;
9
23
  /**
10
24
  * Preprocesses JSX-like expressions in markdown before parsing.
11
25
  * Inline expressions are handled separately; attribute expressions are processed here.
@@ -0,0 +1,12 @@
1
+ import type { SnakeCaseMapping } from './mdxish-snake-case-components';
2
+ import type { Parent } from 'mdast';
3
+ import type { Plugin } from 'unified';
4
+ interface Options {
5
+ mapping: SnakeCaseMapping;
6
+ }
7
+ /**
8
+ * Restores snake_case component names from placeholders after parsing.
9
+ * Runs after mdxishComponentBlocks converts HTML nodes to mdxJsxFlowElement.
10
+ */
11
+ declare const restoreSnakeCaseComponentNames: Plugin<[Options], Parent>;
12
+ export default restoreSnakeCaseComponentNames;
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": "11.10.1",
5
+ "version": "11.12.0",
6
6
  "main": "dist/main.node.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "browser": "dist/main.js",