← markdown · version 0.2.5
7 public items, in source order. Generated from the registry index, which re-derives them from the package source at publish time — so a signature here is the one that version actually ships.
pub fn html_escape(s: text) -> text
Make text safe to put inside markup: &, <, > and " become entities.
⚠ ' IS NOT ESCAPED, so the result is safe in a double-quoted attribute and in element text, but not in a single-quoted one. Quote attributes with ".
pub fn render(source: text, base_dir: text, tag_url_prefix: text, image_url_prefix: text) -> text
Render markdown to HTML — the entry point, and the only one most callers need. The three prefixes each switch off with "", so the plainest possible call is render(src, "", "", ""); see the header for what each one turns on.
pub fn slugify(heading: text) -> text
A heading's anchor id, by GitHub's rules — lower-cased, spaces to hyphens, punctuation dropped. render puts this on every heading, so a caller building its own table of contents uses this to get links that match.
pub fn render_inline(src: text, base_dir: text, tag_url_prefix: text, image_url_prefix: text) -> text
Render only the INLINE constructs — bold, code, links, images — with no paragraph or block wrapper. What a title, a table cell or a tooltip wants, where render would wrap the result in <p>.
pub fn rewrite_link(url: text, base_dir: text) -> text
Resolve one relative URL the way a link in the body would be: joined onto base_dir and routed through /file/. Absolute URLs and anchors are left alone — a scheme, an anchor, and a root-relative /... are all already absolute. For a caller that builds its own navigation and needs it to agree with the links inside the rendered page.
pub struct Heading { level: integer, text: text, slug: text }
One heading of a document: its level (1..6), its raw text, and its anchor slug.
pub fn extract_headings(source: text) -> vector<Heading>
Extract every heading from source in source order — both ATX (# Title) and setext (Title\n=== / Title\n---). Each entry carries the level (1..6), the heading's plain text (BEFORE inline rendering — the caller can pass it through render_inline if needed), and a GitHub-compatible slug (the same one the rendered headings get as id=).
Useful for building an in-page table of contents: walk the returned vector, indent by level, link each entry to #<slug>.