plusparse/scanner library
Low-level, single-pass line helpers shared by the block parser. No regex — everything is hand-written character scanning (ported 1:1 from the Rust plusparse scanner).
Classes
- DollarMathCloser
-
Finds the closing
$of single-dollar maths, for one text.
Functions
-
backtickRunAt(
String text, int i) → int -
Length of the backtick run starting at
i. -
checkboxMarker(
String trimmed) → ({bool checked, String content})? -
[x]/[ ]checkbox. Returns (checked, content). -
codePointAt(
String text, int i) → int -
The code point that starts at
i, or -1 at the end. -
codePointBefore(
String text, int i) → int -
The code point that ends just before
i, or -1 at the start. -
codeSpanAt(
String text, int i, {int? end}) → ({int close, int run})? -
The code span whose opening backtick run starts at
i, if it closes. -
codeSpanContent(
String raw) → String -
The content of a code span, normalised the CommonMark way: line endings
become spaces, and one space is stripped from each end when both ends have
one and the content is not all spaces — which is what lets
`` `a` ``hold a backtick at its edge. -
fenceOpen(
String trimmed) → FenceOpen? -
The fence
trimmed(an already left-trimmed line) opens, or null. -
firstNonSpace(
String line) → int - Index of the first character that is not a space or tab, or -1.
-
indentWidth(
String line) → int - Number of leading-indent columns (space = 1, tab = 4).
-
isAsciiPunctuation(
int unit) → bool -
Whether
unitis ASCII punctuation — the set a backslash can escape. -
isBlank(
String line) → bool -
isFenceClose(
String line, FenceOpen open) → bool -
Whether
lineclosesopen: the same character, at least as many of them, and nothing after but whitespace. -
isHeading(
String trimmed) → ({String content, int level})? -
ATX heading: 1–6
#followed by a space. Returns (level, content), with the optional closing sequence (## Title ##) removed. -
isHr(
String trimmed) → bool -
Thematic break: 3+ of
-,*, or_(optionally space-separated), or⸻. -
isUnicodePunctuation(
int codePoint) → bool -
Unicode punctuation in CommonMark's sense: the
PandScategories. -
isUnicodeWhitespace(
int codePoint) → bool -
Unicode whitespace in CommonMark's sense: the
Zscategory plus tab, line feed, form feed and carriage return. -1 (outside the text) counts as whitespace, so the start and end of a run behave like a space. -
openFenceAfter(
Iterable< String> lines) → FenceOpen? -
Whether a fence opened in
linesis still open after the last line. -
orderedMarker(
String trimmed) → ({String content, int number})? -
N.orN)ordered marker. Returns (number, content). -
paragraphEnd(
String text, int i) → int -
Index of the end of the paragraph containing
i: the next line break that is followed by a blank line, or the end oftext. -
radioMarker(
String trimmed) → ({String content, bool selected})? -
(x)/( )radio. Returns (selected, content). -
setextUnderlineLevel(
String line) → int? -
The level of a setext underline —
1for===,2for---— or null. -
startsAfterIndent(
String line, int unit) → bool -
Whether
linestarts, after up to three spaces, withunit— the cheap test that lets a line-level check skip copying a line that cannot match. -
startsHtmlComment(
String trimmed) → bool -
Whether
trimmedopens an HTML comment. -
stripClosingHashes(
String content) → String -
contentwithout an ATX heading's optional closing sequence. -
stripIndent(
String line, int max) → String -
Remove up to
maxcolumns of leading indentation, returning the remainder. -
unorderedMarker(
String trimmed) → String? -
-,*, or+bullet. Returns the content after the marker.