Expand description
§marq
A markdown rendering library with pluggable code block handlers.
marq parses markdown documents and renders them to HTML, with support for:
- Frontmatter: TOML (
+++) or YAML (---) frontmatter extraction - Headings: Automatic extraction with slug generation for TOC
- Requirement definitions: req annotation syntax for specification traceability
- Code blocks: Pluggable handlers for syntax highlighting, diagrams, etc.
- Link resolution:
@/pathabsolute links and relative link handling
§Example
use marq::{render, RenderOptions};
let markdown = "# Hello World\n\nSome content.";
let opts = RenderOptions::default();
let doc = render(markdown, &opts).await?;
println!("HTML: {}", doc.html);
println!("Headings: {:?}", doc.headings);Re-exports§
pub use ast::Alignment;pub use ast::Block;pub use ast::Inline;pub use ast::parse as parse_ast;pub use ast::render_to_markdown;pub use diff::diff_markdown;pub use diff::diff_markdown_inline;
Modules§
Structs§
- Code
Block Output - The output of a code block handler.
- Default
ReqHandler - Default req handler that renders simple anchor divs.
- Document
- A rendered markdown document.
- Extracted
Reqs - Result of extracting requirements from markdown.
- Frontmatter
- Parsed frontmatter from a markdown document.
- Head
Injection - An HTML snippet to inject into the page’s
<head>(or body end). - Heading
- A heading extracted from the markdown document.
- Inline
Code Span - An inline code span (backtick-delimited) found in the markdown source.
- Mermaid
Handler - Mermaid diagram handler.
- Paragraph
- A paragraph extracted from the markdown document. This allows click-to-navigate features in tools like Tracy.
- Render
Options - Options for rendering markdown.
- ReqDefinition
- A requirement definition extracted from the markdown.
- ReqMetadata
- Metadata attributes for a requirement.
- ReqWarning
- Warning about requirement quality.
- RuleId
- Structured rule identifier with optional version.
- Source
Span - Byte offset and length in source content.
- Term
Handler - Terminal output handler that passes through HTML without escaping.
Enums§
- DocElement
- An element in the document, in document order. This allows consumers to build hierarchical structures (like outlines) by walking the elements in order.
- Error
- Error type for marq operations.
- Frontmatter
Format - Type of frontmatter delimiter.
- ReqLevel
- RFC 2119 requirement level for a requirement.
- ReqStatus
- Lifecycle status of a requirement.
- ReqWarning
Kind - Types of requirement warnings.
- Rfc2119
Keyword - RFC 2119 keyword found in requirement text.
Traits§
- Code
Block Handler - A handler for rendering code blocks.
- Inline
Code Handler - A handler for rendering inline code spans.
- Link
Resolver - A handler for resolving internal links.
- ReqHandler
- A handler for rendering req definitions.
Functions§
- detect_
rfc2119_ keywords - Detect RFC 2119 keywords in text.
- parse_
frontmatter - Parse frontmatter from a markdown document.
- parse_
rule_ id - Parse a rule ID with an optional
+Nversion suffix. - render
- Render markdown to HTML.
- resolve_
link - Resolve internal links (both
@/absolute and relative.mdlinks). - slugify
- Generate a URL-safe slug from text.
- strip_
frontmatter - Strip frontmatter from a markdown document without parsing it.
Type Aliases§
- Boxed
Handler - Type alias for a boxed code block handler.
- Boxed
Inline Code Handler - Type alias for a boxed inline code handler.
- Boxed
Link Resolver - Type alias for a boxed link resolver.
- Boxed
ReqHandler - Type alias for a boxed req handler.
- Result
- Result type alias for marq operations.