Expand description
Markdown scanning, link rewriting, heading extraction, and anchor slugs.
OKF documents use Markdown with YAML frontmatter. This module provides pure-Rust Markdown utilities for inspecting and transforming Markdown content:
heading_slug: Generates kebab-case URL anchor slugs matching GitHub/CommonMark conventions.extract_headings: Extracts all headings in document order, skipping fenced code blocks.rewrite_markdown_links: Rewrites inline links while ignoring code blocks and inline code.
Structs§
- Markdown
Heading - A parsed markdown heading.
Enums§
- Link
Rewrite Action - Action to perform on a detected markdown link during rewrite.
Functions§
- blank_
inline_ code - Replaces inline code spans (backtick-delimited) with spaces so links/footnotes inside them are not extracted.
- clean_
destination - Normalizes a raw link destination.
- code_
free_ lines - Returns the body’s lines, as
(1-based line number, text), with fenced code blocks removed and inline code spans blanked out. - extract_
headings - Extracts all markdown headings in document order, ignoring headings inside fenced code blocks.
- extract_
title_ suffix - Extracts the title suffix part (e.g.
"My Title") from a destination string. - heading_
slug - Derives a standard Markdown anchor slug from a heading text.
- is_
escaped - Whether the character at
indexis preceded by an odd number of backslashes, and is therefore escaped in Markdown. - matches_
heading - Checks whether a heading text matches a search query by title, slug, or normalized spacing.
- parse_
heading_ line - Parses a single line as an ATX heading (
#through######). - parse_
inline_ link - Attempts to parse
[text](dest)starting atstart(the[). Returns the text, destination, and index just past the closing). - rewrite_
markdown_ links - Rewrites inline markdown links in a document body using a callback function.
- strip_
title - Removes an optional
"title"(or'title') suffix from a link destination.