Skip to main content

Module code_block_utils

Module code_block_utils 

Source
Expand description

Utility functions for detecting and handling code blocks and code spans in Markdown for rumdl.

Code block detection is delegated to pulldown-cmark, which correctly implements the CommonMark specification. This handles edge cases like:

  • Backtick fences with backticks in the info string (invalid per spec)
  • Nested fences (longer fence contains shorter fence as content)
  • Mixed fence types (tilde fence contains backticks as content)
  • Indented code blocks with proper list context handling

Structs§

CodeBlockDetail
Detailed information about a code block captured during parsing
CodeBlockUtils
Utility functions for detecting and handling code blocks in Markdown
ColonDefinitionDetail
A definition pulldown-cmark opens on a colon touching its text, together with the terms before it
DefinitionTextDetail
Text a definition holds directly, captured during parsing
ParseResult
Structure facts from document analysis, capturing data needed by individual rules.
StrippedLine
A line with its container prefixes removed (see strip_enclosure).
StrongSpanDetail
A strong emphasis span captured during parsing

Enums§

CodeBlockContext
Classification of code blocks relative to list contexts
Enclosure
A container a fenced block sits in, with the extent the parser gave it.

Functions§

continued_depth
How many of the containers in enclosing (outermost first) line continues: the longest prefix of enclosing that strip_enclosure accepts.
item_runs
For each container in enclosing, the number of consecutive items that start there.
strip_enclosure
Remove the prefixes the containers in enclosing (outermost first) put on line, or None when the line does not continue all of them.

Type Aliases§

LineToListMap
Ordered list membership: maps line number (1-indexed) to list ID
ListStartValues
Ordered list start values: maps list ID to the start value