Skip to main content

Crate mdstitch

Crate mdstitch 

Source
Expand description

Streaming markdown preprocessor that auto-completes incomplete syntax.

Runs on raw markdown strings before the pulldown-cmark parser, detecting and closing unterminated formatting markers so content renders correctly during token-by-token streaming.

Modules§

priority
Built-in handler priorities.

Structs§

CodeBlockRanges
Pre-computed ranges of text that are inside code blocks, inline code spans, or math blocks. Used to skip these regions in emphasis/katex handlers without redundant O(n) scans.
StitchOptions
Configuration options for the stitch function.

Enums§

LinkMode
How to handle incomplete links.
TextDirection
Text direction: left-to-right or right-to-left.

Traits§

StitchHandler
A custom handler that transforms text during the stitch pipeline.

Functions§

detect_text_direction
Detects text direction using the “first strong character” algorithm.
has_incomplete_code_fence
Returns true if the markdown text has an unclosed code fence.
has_table
Returns true if the markdown text contains a table delimiter row.
is_inside_code_block
Returns true if the position is inside a fenced code block (between ``` markers) or an inline code span (between ` markers).
is_within_link_or_image_url
Returns true if position is inside the URL portion of a link/image ](url).
is_within_math_block
Returns true if position is inside a math block ($ or $$).
is_word_char
Returns true if ch is a Unicode letter, digit, or underscore. Matches the TS isWordChar / [\p{L}\p{N}_].
normalize_html_indentation
Strips excessive indentation (4+ spaces/tabs) from lines that start HTML blocks.
preprocess_custom_tags
Preprocesses custom HTML tags to prevent blank lines within them from causing CommonMark to split the block.
preprocess_literal_tag_content
Escapes markdown metacharacters inside specified HTML tags so their content renders as plain text.
stitch
Preprocesses streaming markdown text, auto-completing any incomplete syntax.