package text
- Alphabetic
- Public
- All
Type Members
-
class
Characters[T] extends Parser[T]
Optimized parser for character input.
-
class
DelimitedText extends Parser[String]
A parser for text that ends with a specific delimiter condition, either marking the end of the text span or the start of an embedded inner span.
-
class
DelimiterParser extends Parser[String] with PrefixedParser[String]
A parser that simplifies the expression of typical conditions for start and end delimiters of inline spans.
A parser that simplifies the expression of typical conditions for start and end delimiters of inline spans.
It allows to specify conditions for the immediately preceding and following character of the parsed delimiter.
As an example, the following parser is only composed of base combinators
lookBehind(1, not(' ')) ~ "**" ~ lookAhead(not(' '))
It looks for the string "**" as a delimiter and does not allow any space character before or after the delimiter
With this API it can be rewritten as:
delimiter("**").prevNot(' ').nextNot(' ')
The only characters that this parser will consume and return as a result are those of the delimiter itself, not the surrounding characters that it validated.
-
case class
Literal(expected: String) extends Parser[String] with PrefixedParser[String] with Product with Serializable
A parser that matches a literal string.
-
class
PrefixCharacters[T] extends Parser[T] with PrefixedParser[T]
A variant of the Characters type that can be used as a stable prefix for an optimized span parser as it is always non-empty.
A variant of the Characters type that can be used as a stable prefix for an optimized span parser as it is always non-empty. It's created by the
oneOf
method inTextParsers
and usually not used directly. -
trait
PrefixedParser[+T] extends Parser[T]
A parser that is associated with a non-empty set of trigger characters for performance optimizations.
A parser that is associated with a non-empty set of trigger characters for performance optimizations.
There is usually no need to create such a parser manually, as some of the basic building blocks in
TextParsers
create such a parser (e.g. theliteral
,oneOf
orsomeOf
parsers).This set only has only an effect when this parser is used in an optimized parser for recursive spans, meaning it is either registered as a top-level parser (with
SpanParser.standalone
orSpanParser.recursive
) or passed to a custom span parser withInlineParser.embed
. In all other use cases this parser behaves just like plain parser. -
trait
TextParsers extends Parsers
Base text parsers that provide optimized low-level parsers for typical requirements of text markup parsers.
Base text parsers that provide optimized low-level parsers for typical requirements of text markup parsers. In particular they are meant as an efficient replacement for scenarios where usually regex parsers are used. In cases where different parsers need to be tried for relatively short input sequences, regex parsers tend to be less efficient. Furthermore, these base parsers may also improve readability, as it allows to combine simple low-level parsers to higher-level parsers based on the Laika combinator API, instead of producing long regexes which may be hard to read.
-
class
WhitespacePreprocessor extends (String) ⇒ String
Processes whitespace, removing or replacing most whitespace characters except for newline and space.
Processes whitespace, removing or replacing most whitespace characters except for newline and space.
It modifies string input in the following ways:
- Replaces all occurrences of tabs with the corresponding number of spaces,
depending on the column the tab is placed in and the configured
tabStops
value. - Removes any return character.
- Replaces form feed and vertical tab with spaces.
The processor should run on text input before it is passed to the actual parsers as they would not be able to deal with tabs properly.
- Replaces all occurrences of tabs with the corresponding number of spaces,
depending on the column the tab is placed in and the configured
Value Members
-
object
CharGroup
Common groups of characters as input for parser definitions.
Common groups of characters as input for parser definitions.
These groups are all in the ASCII range. For dealing with the entire unicode range you can use the generic
anyWhile
parser that accepts aChar => Boolean
predicate. -
object
Characters
Companion with factory methods for creating optimized character parsers.
- object DelimitedText
-
object
PrefixedParser
Factories and utilities for creating or processing PrefixedParser instances.
-
object
TextParsers extends TextParsers
Instance that allows to import all text parsers in isolation.
Instance that allows to import all text parsers in isolation.
Usually it is more convenient to import laika.parse.api._ to get all parser builders with one import.
-
object
WhitespacePreprocessor
Companion for creating instances of WhitespacePreprocessor.