markdown.state — Lilush API

←index

← markdown

Overview

Block state machine with pattern-based detection for CommonMark block structures: headings, code fences, thematic breaks, lists, tables, blockquotes, divs, link references, and footnotes.

Functions

NameSignature
is_blank_lineis_blank_line(line) -> blank
detect_headingdetect_heading(line) -> level, content
detect_code_fence_opendetect_code_fence_open(line) -> fence_char, fence_len, info, indent
is_code_fence_closeis_code_fence_close(line, fence_char, fence_len) -> closed
detect_thematic_breakdetect_thematic_break(line) -> is_break
detect_ul_markerdetect_ul_marker(line) -> marker, content, pre_indent, content_indent, task_info
detect_ol_markerdetect_ol_marker(line) -> start_num, delimiter, content, pre_indent, content_indent
detect_list_itemdetect_list_item(line) -> type, attrs
parse_table_rowparse_table_row(line) -> cells
detect_table_delimiterdetect_table_delimiter(line) -> alignments
detect_blockdetect_block(line) -> block_type, attrs
can_interrupt_paragraphcan_interrupt_paragraph(block_type, attrs) -> can_interrupt
detect_link_referencedetect_link_reference(line) -> label, dest, title
detect_footnote_definitiondetect_footnote_definition(line) -> label, content, indent
detect_blockquotedetect_blockquote(line) -> content, indent
detect_div_fence_opendetect_div_fence_open(line) -> fence_len, class_name, indent
is_div_fence_closeis_div_fence_close(line, fence_len) -> closed

is_blank_line(line) -> blank

Check if a line is blank or contains only whitespace

detect_heading(line) -> level, content

Detect ATX heading (# through ######)

detect_code_fence_open(line) -> fence_char, fence_len, info, indent

Detect fenced code block opening

is_code_fence_close(line, fence_char, fence_len) -> closed

Check if a line closes a code fence

detect_thematic_break(line) -> is_break

Detect thematic break (---, ***, ___)

detect_ul_marker(line) -> marker, content, pre_indent, content_indent, task_info

Detect unordered list marker with optional task list syntax

detect_ol_marker(line) -> start_num, delimiter, content, pre_indent, content_indent

Detect ordered list marker (digits followed by . or ))

detect_list_item(line) -> type, attrs

Detect any list item (ordered or unordered)

parse_table_row(line) -> cells

Parse a GFM table row into an array of cell strings

detect_table_delimiter(line) -> alignments

Detect GFM table delimiter row and parse column alignments

detect_block(line) -> block_type, attrs

Detect block type from a line

can_interrupt_paragraph(block_type, attrs) -> can_interrupt

Check if a block type can interrupt a paragraph

detect_link_reference(line) -> label, dest, title

Detect link reference definition

detect_footnote_definition(line) -> label, content, indent

Detect footnote definition

detect_blockquote(line) -> content, indent

Detect blockquote line

detect_div_fence_open(line) -> fence_len, class_name, indent

Detect fenced div opening (Djot extension)

is_div_fence_close(line, fence_len) -> closed

Check if a line closes a div fence