Skip to main content

clean

Function clean 

Source
pub fn clean(md: &str, section: DocSection) -> String
Expand description

Strips frontmatter (keeping the title as an H1), import lines, and JSX elements (single-line <span …>…</span> and multi-line <Component … /> blocks), and rewrites relative .md links to featherbit://docs/… URIs. Fenced code blocks (opened/closed by a line whose trimmed form starts with ```) pass through verbatim — no import/JSX/link processing — since example bodies routinely contain <Uppercase...> tokens (e.g. an RFC 5424 <PRI>... syslog frame) that would otherwise be mistaken for an unterminated JSX block, silently swallowing everything after it for the rest of the page.

The directory hint picks the target section (guides/, concepts/, plugins/, reference/, else the page’s own section). guides/ links used to be left as raw Markdown because the guides were not embedded — which left an agent reading “see the Lua scripting guide” with no way to open it. The guides are resources now, so those links resolve too.