UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

19 lines (18 loc) 1.05 kB
import { MarkupParser } from "../../markup/MarkupParser.js"; import { requireMeta } from "./MetaContext.js"; /** * Parse a markup string and render the resulting elements inline. * - Defaults to `MARKUP_OPTIONS` (full block + inline rule set). Pass `rules`, `rel`, `url`, `root`, or `schemes` as props to override. * - `url`/`root` default to the current `<Meta>` context so link rules resolve site-absolute and relative hrefs. * - Renders inside whatever ancestor element the caller provides — wrap in `<Prose>` to get the standard prose typography for the produced `<p>` / `<ul>` / `<pre>` / etc. * * @example <Prose><Markup>{`A *bold* word with \`code\`.`}</Markup></Prose> */ export function Markup({ children, ...options }) { if (!children) return null; // Thread the current page URL + site root from `<Meta>` so link rules can resolve site-absolute and relative hrefs. const { url, root } = requireMeta(); // Return the parsed markup. return new MarkupParser({ url, root, ...options }).parse(children); }