micro-mdx-parser is a lightweight JavaScript parser engineered to efficiently convert Markdown or HTML content into a structured JSON representation. This package is specifically designed for scenarios requiring client-side parsing and component rendering within CMS-like applications, where a full MDX toolchain might be considered excessive. It is built as a fork of the `himalaya` parser, incorporating specific 'MDX-like' adjustments to better align with modern component-based content rendering needs. Currently stable at version 1.1.24, its release cadence is typically infrequent, characteristic of a mature, specialized utility library. Key differentiators include its minimal footprint, versatile compatibility across both browser and server environments, and its focus on generating a parseable JSON AST for programmatic content manipulation, rather than direct HTML output.
npm install micro-mdx-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the `parse` function and use it to convert both Markdown and HTML strings into a JSON Abstract Syntax Tree (AST).
For full MDX compilation with JavaScript evaluation, consider `MDX` (official package) or other robust MDX solutions. Use `micro-mdx-parser` when only a structural JSON representation of Markdown/HTML (including basic component tags) is needed.
Thoroughly test parsing results with diverse HTML/Markdown inputs if migrating from `himalaya` or relying on specific parsing behaviors. Consult the source code if unexpected parsing results occur.
Ensure input Markdown/HTML is as well-formed as possible. Implement input validation or pre-processing steps before feeding content to the parser, especially for user-generated content.
Verify compatibility with target browser environments using modern bundlers (e.g., Webpack, Rollup, Vite) which can transpile or polyfill as needed. Test thoroughly in target browsers.
Change the import statement to use named import syntax: `import { parse } from 'micro-mdx-parser';`Ensure the package is installed via `npm install micro-mdx-parser` or `yarn add micro-mdx-parser`, and that your module resolution paths are correctly configured.
Access text content through child nodes of type 'text'. For example, `element.children[0].content` if the first child is a text node, or iterate through children to find text nodes.
No dependency data recorded yet.