SpanSink

class SpanSink

A mutable accumulator for Spans, used as the U (user context) type parameter when running a parser in highlighting mode.

Pass a SpanSink instance as the user context of a parsek.ParserInput. Parsers wrapped with pTag will push Spans into spans as they succeed. After parsing completes, spans contains a flat, ordered list of all highlighted ranges.

Example

val sink  = SpanSink()
val input = ParserInput.of(source.toList(), sink)
pDocument()(input)
val highlights: List<Span> = sink.spans

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Functions

Link copied to clipboard
fun SpanSink.emit(type: TokenType, start: Int, end: Int)

Emits a Span into this SpanSink if the range is non-empty.