Skip to content

markdown

Helpers for writing Markdown safely: escaping, links, code, quotes, tables and heading anchors.

Everything here produces Markdown text; nothing parses it. The functions make untrusted text and awkward characters (backticks, pipes, brackets, parentheses) come out literally.

Cargo feature markdown (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features markdown

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.6", default-features = false, features = ["markdown"] }

Import path: helpers4::markdown.

ItemWhat it does
blockquoteTurns text into a Markdown blockquote by prefixing every line with > .
code_blockA fenced code block for code, tagged with language.
escapeEscapes text so that Markdown shows it literally instead of interpreting it.
heading_slugThe anchor GitHub gives to a heading: "Hello, World!" becomes "hello-world".
inline_codeWraps text in a Markdown code span, using enough backticks for the text to show literally.
linkA Markdown link [text](url), with the characters that would break it made safe.
tableA GitHub-flavored Markdown table.