Whitespace

Description

sealed class Tinman.Core.Document.Whitespace

The Whitespace class is used to determine when to output whitespace characters in a flow of inline nodes (according to the ITextContentNode.Flags flags).

Public / Constructors

Whitespace


public constructor Whitespace → (1)

other opt : Whitespace = null

The other Whitespace object to copy the whitespace state from or null to use the initial state (see Reset).

Creates a new instance of Whitespace.

Public / Methods

Collapse


public static method Collapse → (2)

text in : string

[not-null]
The text to trim.

words opt : ICollector<RangeI> = null

Optional collector for word ranges in the resulting text.

returns → Pair<string, WhitespaceFlags>

The resulting text and the resulting whitespace flags:
Pair.First: resulting text
Pair.Second: whitespace flags

Collapses all consecutive whitespace characters (see FormattingUtil.IsWhitespace) in the given text to single ' ', trimming both leading and trailing whitespaces.

Consume

2 overloads


public method Consume1 → (1)

node opt : ITextContentNode = null

The text node or null if some other non-whitespace token will be emitted instead of a ITextContentNode object.

returns → bool

true if a whitespace character needs to be output before node opt, false if not.

Consumes the given text node for updating the whitespace flags.

The method assumes that a whitespace will be emitted iff it returns true and that the text content of node opt will be output after that.


public method Consume2 → (1)

flags in : WhitespaceFlags

The white space flags of the non-whitespace text content.

returns → bool

true if a whitespace character needs to be output before the text content, false if not.

Consumes the given text node flags for updating the whitespace flags.

The method assumes that a whitespace will be emitted iff it returns true and that the text content belonging to flags in will be output after that.

Require


public method Require → ()

returns → Whitespace

this

The need for a whitespace exists.

NeedsWhitespace will return true after this method has been called.

Reset


public method Reset → ()

Resets the whitespace state.

Satisfy


public method Satisfy → ()

returns → Whitespace

this

The need for a whitespace has been satisfied.

HasWhitespace will return true after this method has been called.

Public / Attributes

Flags


public attribute Flags → (get)

value : WhitespaceFlags

The effective whitespace flags for the text indicated by Consume2.

Returns the effective whitespace flags of the current non-whitespace text.

Has​Whitespace


public attribute HasWhitespace → (get)

value : bool

true if a whitespace is present, false if not.

Is a whitespace present for the next non-whitespace text?

Needs​Whitespace


public attribute NeedsWhitespace → (get)

value : bool

true if a whitespace is required, false if not.

Is a whitespace required before the next non-whitespace text?