Skip to main content

Module markdown

Module markdown 

Source
Expand description

The markdown module contains the core processing pipeline. Core Markdown processing functionality.

This module handles the conversion of Markdown content into HTML, with support for custom blocks, enhanced tables, and syntax highlighting.

§Processing Pipeline

  1. Parse — Markdown source → comrak AST (arena-allocated).
  2. Transform — Walk the AST to rewrite custom-block HtmlBlock nodes in-place.
  3. Render — Convert the (possibly modified) AST to HTML, using comrak’s plugin system for syntax highlighting.
  4. Enhance — Post-process table HTML for responsive wrappers and alignment classes.
  5. Sanitize — When allow_unsafe_html is false, run ammonia to strip dangerous tags while preserving safe structural markup.

Structs§

MarkdownOptions
Options for configuring Markdown processing behavior.
SanitizerConfig
User-supplied extensions to the default HTML sanitizer allow-list.

Constants§

DEFAULT_MAX_INPUT_SIZE
Default maximum input size: 1 MiB.

Functions§

default_markdown_options
Creates a convenience set of options with all features enabled.
process_markdown
Processes the input Markdown content and converts it into HTML.
process_markdown_to_plain_text
Extracts plain-text content from Markdown, stripping all formatting and markup.
process_markdown_to_writer
Streams processed HTML directly to a Write sink.
process_markdown_with_toc
Processes Markdown and returns both the rendered HTML and a document-order table of contents.
process_markdown_with_toc_to_writer
Streams processed HTML to writer and returns the table of contents collected during the AST walk.