Skip to main content

Crate marq

Crate marq 

Source
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: @/path absolute 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§

ast
diff

Structs§

CodeBlockOutput
The output of a code block handler.
DefaultReqHandler
Default req handler that renders simple anchor divs.
Document
A rendered markdown document.
ExtractedReqs
Result of extracting requirements from markdown.
Frontmatter
Parsed frontmatter from a markdown document.
HeadInjection
An HTML snippet to inject into the page’s <head> (or body end).
Heading
A heading extracted from the markdown document.
InlineCodeSpan
An inline code span (backtick-delimited) found in the markdown source.
MermaidHandler
Mermaid diagram handler.
Paragraph
A paragraph extracted from the markdown document. This allows click-to-navigate features in tools like Tracy.
RenderOptions
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.
SourceSpan
Byte offset and length in source content.
TermHandler
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.
FrontmatterFormat
Type of frontmatter delimiter.
ReqLevel
RFC 2119 requirement level for a requirement.
ReqStatus
Lifecycle status of a requirement.
ReqWarningKind
Types of requirement warnings.
Rfc2119Keyword
RFC 2119 keyword found in requirement text.

Traits§

CodeBlockHandler
A handler for rendering code blocks.
InlineCodeHandler
A handler for rendering inline code spans.
LinkResolver
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 +N version suffix.
render
Render markdown to HTML.
resolve_link
Resolve internal links (both @/ absolute and relative .md links).
slugify
Generate a URL-safe slug from text.
strip_frontmatter
Strip frontmatter from a markdown document without parsing it.

Type Aliases§

BoxedHandler
Type alias for a boxed code block handler.
BoxedInlineCodeHandler
Type alias for a boxed inline code handler.
BoxedLinkResolver
Type alias for a boxed link resolver.
BoxedReqHandler
Type alias for a boxed req handler.
Result
Result type alias for marq operations.