TreeMarkupcomponent
TreeMarkup({ rules = TREE_MARKUP_RULES, ...props }: MarkupProps): ReactNode| Param | Type | |
|---|---|---|
children | MarkupProps | The source markup string to parse and render (renders null when empty). required |
.children | string | The source string to parse and render. |
| Return | |
|---|---|
ReactNode | The parsed markup as React nodes, or null when children is empty. |
Render a markup string with inline code spans auto-linked to their documented tree elements.
- Like
<Markup>but defaults toTREE_MARKUP_RULES, so each backtick span resolves throughTreeLinkagainst the surrounding<TreeProvider>— a known token links to its canonical page, an unknown one stays plain code. - The standard way to render documentation-site content (READMEs, docblocks, per-symbol pages); plain
<Markup>stays the choice for general user content that shouldn't cross-link. - Falls back to plain code spans outside a
<TreeProvider>, so it's safe to use anywhere. Pass anyMarkupOptionsprop (includingrules) to override.
Renders a markup string just like <Markup>, but auto-links every inline code span to its documented tree element. A backtick span whose text matches a token in the surrounding <TreeProvider> becomes a link to that token's canonical page; anything else stays a plain code token. It's the standard way to render documentation-site content, so cross-references happen automatically at render time instead of being hand-written into the source markdown.
Things to know:
- Defaults to
TREE_MARKUP_RULES— the full default rule set with the inline-code rule swapped forTREE_CODE_RULE, which renders each span throughTreeLink. - Resolution is exact-match against the tree map: a hit (
`BooleanSchema`,`Store.get`) links; a miss (`bun run fix`,`string`) falls back to a plain code token, so unknown spans never produce a broken link. - Falls back to plain code spans outside a
<TreeProvider>, so it's safe to use anywhere — it simply stops linking. - Inherits everything else from
<Markup>:url/rootdefault to the current<Meta>context, and anyMarkupOptionsprop (rules,rel,url,root,schemes) can be overridden directly. - Wrap in
<Prose>to give the produced<p>/<ul>/<pre>/ etc. the standard prose typography.
Usage
import { Prose } from "shelving/ui";
import { TreeMarkup } from "shelving/ui";
// Inline code spans link automatically: `BooleanSchema` → /schema/BooleanSchema.
<Prose>
<TreeMarkup>{element.props.content}</TreeMarkup>
</Prose>Examples
<Prose><TreeMarkup>{`Use \`BooleanSchema\` to validate.`}</TreeMarkup></Prose>