Provides base parsers that abstract aspects of block parsing common to most lightweight markup languages.
A block parser in Laika can always safely assume that it is invoked at the start of the current line and that the line is not empty.
- Companion:
- object
Value members
Concrete methods
Parses a full block based on the specified helper parsers.
Parses a full block based on the specified helper parsers.
The string result of this parser will not contain the characters consumed by any of the specified prefix parsers.
- Value parameters:
- firstLinePrefix
parser that recognizes the start of the first line of this block
- linePrefix
parser that recognizes the start of subsequent lines that still belong to the same block
Parses a full block based on the specified helper parsers.
Parses a full block based on the specified helper parsers.
The result of this parser will not contain the characters consumed by any of the specified prefix parsers. The block source returned by this method maintains x-offsets for each individual line so that it can be passed down to recursive block or span parsers without losing position tracking.
- Value parameters:
- firstLinePrefix
parser that recognizes the start of the first line of this block
- linePrefix
parser that recognizes the start of subsequent lines that still belong to the same block
- nextBlockPrefix
parser that recognizes whether a line after one or more blank lines still belongs to the same block
Parses a full block based on the specified helper parsers, expecting an indentation for all lines except the first. The indentation may vary between the parts of the indented block, so that this parser only cuts off the minimum indentation shared by all lines, but each line must have at least the specified minimum indentation.
Parses a full block based on the specified helper parsers, expecting an indentation for all lines except the first. The indentation may vary between the parts of the indented block, so that this parser only cuts off the minimum indentation shared by all lines, but each line must have at least the specified minimum indentation.
- Value parameters:
- endsOnBlankLine
indicates whether parsing should end on the first blank line
- firstLineIndented
indicates whether the first line is expected to be indented, too
- linePredicate
parser that recognizes the start of subsequent lines that still belong to the same block
- maxIndent
the maximum indentation that will get dropped from the start of each line of the result
- minIndent
the minimum indentation that each line in this block must have
- Returns:
a parser that produces the raw text of the parsed block with the indentation removed
Parses a full block based on the specified helper parsers, expecting an indentation for all lines except the first. The indentation may vary between the parts of the indented block, so that this parser only cuts off the minimum indentation shared by all lines, but each line must have at least the specified minimum indentation.
Parses a full block based on the specified helper parsers, expecting an indentation for all lines except the first. The indentation may vary between the parts of the indented block, so that this parser only cuts off the minimum indentation shared by all lines, but each line must have at least the specified minimum indentation.
- Value parameters:
- endsOnBlankLine
indicates whether parsing should end on the first blank line
- firstLineIndented
indicates whether the first line is expected to be indented, too
- linePredicate
parser that recognizes the start of subsequent lines that still belong to the same block
- maxIndent
the maximum indentation that will get dropped from the start of each line of the result
- minIndent
the minimum indentation that each line in this block must have
- Returns:
a parser that produces the raw text of the parsed block with the indentation removed and the indentation level (number of whitespace characters removed from the text lines)