laika.parse.text

Members list

Type members

Classlikes

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 a Char => Boolean predicate.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
CharGroup.type
class Characters[T](predicate: Char => Boolean, resultBuilder: () => T, minChar: Int, maxChar: Int) extends Parser[T]

Optimized parser for character input.

Optimized parser for character input.

Attributes

Companion
object
Supertypes
class Parser[T]
class Object
trait Matchable
class Any
object Characters

Companion with factory methods for creating optimized character parsers.

Companion with factory methods for creating optimized character parsers.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Characters.type
class DelimitedText(val delimiter: TextDelimiter) 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.

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.

Attributes

Companion
object
Supertypes
class Parser[String]
class Object
trait Matchable
class Any
object DelimitedText

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class DelimiterParser(prefix: PrefixedParser[String], prevCharInvalid: Char => Boolean, nextCharInvalid: Char => Boolean, enclosingCharsInvalid: (Char, Char) => Boolean) extends 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.

Attributes

Supertypes
trait PrefixedParser[String]
class Parser[String]
class Object
trait Matchable
class Any
case class Literal(expected: String) extends PrefixedParser[String]

A parser that matches a literal string.

A parser that matches a literal string.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait PrefixedParser[String]
class Parser[String]
class Object
trait Matchable
class Any
Show all
class PrefixCharacters[T](val underlying: Characters[T], val startChars: Type[Char]) extends 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. It's created by the oneOf method in TextParsers and usually not used directly.

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 in TextParsers and usually not used directly.

Attributes

Supertypes
trait PrefixedParser[T]
class Parser[T]
class Object
trait Matchable
class Any
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. the literal, oneOf or someOf 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 or SpanParser.recursive) or passed to a custom span parser with InlineParser.embed. In all other use cases this parser behaves just like plain parser.

Attributes

Companion
object
Supertypes
class Parser[T]
class Object
trait Matchable
class Any
Known subtypes
class CharParser
class StringParser
class TagParser
class IdParser
class Literal
class PrefixCharacters[T]
Show all
Self type

Factories and utilities for creating or processing PrefixedParser instances.

Factories and utilities for creating or processing PrefixedParser instances.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait TextParsers extends 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.

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.

Attributes

Companion
object
Supertypes
trait Parsers
class Object
trait Matchable
class Any
Known subtypes
object TextParsers.type
object builders.type
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.

Attributes

Companion
trait
Supertypes
trait TextParsers
trait Parsers
class Object
trait Matchable
class Any
Self type
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.

Attributes

Companion
object
Supertypes
trait String => String
class Object
trait Matchable
class Any

Companion for creating instances of WhitespacePreprocessor.

Companion for creating instances of WhitespacePreprocessor.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type