@tomerlichtash/hast-react
v0.1.0
Published
hast → React elements with className→component mapping
Readme
@tomerlichtash/hast-react
hast → React elements with className→component mapping — the gap in the
official hast-util-to-jsx-runtime, whose components option maps by tagName
only. When your remark/rehype plugins emit class="entry", map it straight to
<Entry>:
import { hastToReact } from '@tomerlichtash/hast-react';
hastToReact(tree, {
entry: Entry, // className → component
blockquote: Blockquote, // tagName → component (class wins)
aside: 'section', // → plain tag rename
thread: [Thread, { dir: 'rtl' }], // [Component, extraProps]
});Props are normalized for React: class/for → className/htmlFor,
hast-camelCased aria/data attrs back to aria-*/data-*, style strings
parsed to objects with CSS custom properties (--foo) kept literal.
Intended for author-controlled markdown processed at build time — not sanitized for untrusted input. React ≥18 peer; no other runtime deps.
