Package-level declarations

Types

Link copied to clipboard
sealed interface BlockLexState

State machine for block-level lexing.

Functions

Link copied to clipboard
fun blockLex(lexemes: List<Lexeme>): List<Token>

Lexes a flat list of lexemes into block-level tokens.

Link copied to clipboard

Detects the HTML block type (1–7) for a line, or 0 if not an HTML block start. Requires 0–3 leading spaces.

Link copied to clipboard

Checks if a line contains the end condition for an HTML block type.

Link copied to clipboard

Converts a list of lexemes back to their source text representation.

Link copied to clipboard
fun splitLines(lexemes: List<Lexeme>): List<List<Lexeme>>

Splits a flat list of lexemes into logical lines. Each line is a list of lexemes up to (and including) a Lexeme.Newline. The last line may not end with a newline.

Link copied to clipboard
fun stripIndent(line: List<Lexeme>, count: Int): List<Lexeme>

Strips exactly count spaces worth of indent from the front of a line. Tabs count as enough spaces to reach the next tab stop (multiple of 4).

Link copied to clipboard

Tries to lex an ATX heading: 0–3 spaces, 1–6 #s, then space/tab/line-end. Returns a pair of (AtxHeadingMarker, AtxHeadingContent?) or null.

Link copied to clipboard

Tries to lex a blank line: a line with only whitespace (and newline).

Link copied to clipboard
fun tryCodeFenceClose(line: List<Lexeme>, openChar: Char, openLength: Int): Token.CodeFenceClose?

Tries to lex a closing code fence that matches the given opening.

Link copied to clipboard

Tries to lex a code fence opening: 0–3 spaces, 3+ backticks or tildes. Returns (CodeFenceOpen, CodeFenceInfo?) or null.

Link copied to clipboard

Tries to lex an indented code line: 4+ spaces (or 1+ tab) of leading indent. Returns the line with the indent prefix stripped.

Link copied to clipboard

Tries to lex a setext heading underline: 0–3 spaces, then 1+ = or -, optional trailing spaces.

Link copied to clipboard

Tries to lex a thematic break: 0–3 spaces, then 3+ of same marker (-,*,_) interspersed with optional spaces/tabs, then line ending/EOF.