@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
117 lines • 3.99 kB
text/typescript
/**
* createMarkdownNodes.ts - Helper functions for creating MD AST nodes
*
* This module provides utility functions to create nodes for Markdown
* abstract syntax trees, making transformer code more readable and maintainable.
*/
import type { PhrasingContent, Text, Paragraph, Heading, Code, InlineCode, Table, Emphasis, Strong, Definition, Break } from 'mdast';
/**
* Create a text node
* @param value - The text content
* @returns A text node
*/
export declare function text(value: string): Text;
type Child = PhrasingContent | string;
/**
* Create a paragraph node
* @param children - Child node, string, or array of nodes/strings
* @returns A paragraph node
*/
export declare function paragraph(children: Child | Child[]): Paragraph;
/**
* Create an emphasis (italic) node
* @param children - Child node, string, or array of nodes/strings
* @returns An emphasis node
*/
export declare function emphasis(children: Child | Child[]): Emphasis;
/**
* Create a strong (bold) node
* @param children - Child node, string, or array of nodes/strings
* @returns A strong node
*/
export declare function strong(children: Child | Child[]): Strong;
/**
* Create a heading node
* @param depth - Heading level (1-6)
* @param children - Child node, string, or array of nodes/strings
* @returns A heading node
*/
export declare function heading(depth: 1 | 2 | 3 | 4 | 5 | 6, children: Child | Child[]): Heading;
/**
* Create a code block node
* @param {string} value - Code content
* @param {string} lang - Language for syntax highlighting
* @returns {Object} A code node
*/
export declare function code(value: string, lang?: string): Code;
/**
* Create an inline code node
* @param {string} value - Code content
* @returns {Object} An inline code node
*/
export declare function inlineCode(value: string): InlineCode;
/**
* Create a hard line break node (renders as <br> in HTML)
* @returns A break node
*/
export declare function hardBreak(): Break;
/**
* Creates a markdown table node (GFM)
* @param {Array<string|Object>} headers - Array of header strings or nodes
* @param {Array<Array<string|Object>>} rows - Array of row data, each row is an array of cell content
* @param {Array<string>} [alignment] - Optional array of alignments ('left', 'center', 'right') for each column
* @returns {Object} A table node
*/
export declare function table(headers: (Child | Child[])[], rows: (Child | Child[])[][], alignment?: string[] | null): Table;
/**
* Create a list item node
* @param children - Child node, string, or array of nodes/strings
* @returns A list item node
*/
export declare function listItem(children: Child | Child[]): {
type: 'listItem';
spread: false;
children: Paragraph[];
};
/**
* Create a list node
* @param items - Array of list item nodes
* @param ordered - Whether the list is ordered (numbered) or unordered (bulleted)
* @returns A list node
*/
export declare function list(items: {
type: 'listItem';
spread: false;
children: Paragraph[];
}[], ordered?: boolean): {
type: 'list';
ordered: boolean;
spread: false;
children: {
type: 'listItem';
spread: false;
children: Paragraph[];
}[];
};
/**
* Create a comment node. Comment text will not be rendered in HTML output.
* @param value - Comment text
* @returns A comment node
*/
export declare function comment(value: string, ref?: string): Definition;
/**
* Create a link node
* @param url - The URL to link to
* @param children - Child node, string, or array of nodes/strings
* @param title - Optional title attribute
* @returns A link node
*/
export declare function link(url: string, children: Child | Child[], title?: string): PhrasingContent;
/**
* Create a raw HTML node. Content passes through without escaping.
* Use sparingly - only when you need to prevent character escaping.
* @param value - Raw HTML/text content
* @returns An HTML node
*/
export declare function raw(value: string): PhrasingContent;
export {};