ParseRule
Base class for text parsing rules that identify modifier application ranges.
Remarks
Derived Types(15)
Types that inherit from ParseRule.
The literal-escape capability: a rule that consumes an escape prefix to protect the following character from markup interpretation returns that prefix; '\0' (default) = the rule provides no escaping. Consumers (literal-paste serialization, escaping injection) check this contract instead of naming a concrete rule type, so a custom escaping rule participates by overriding it.
The source-markup token this rule's syntax is externally known by — whatever form the syntax takes (color for a tag rule, a marker for a marker rule) — or for a markerless rule. Interop consumers (clipboard bindings) pair rules with format schemas by this token instead of testing syntax families.
Stable identity shared by rule instances that match the same syntax, compared case-insensitively — pairs separately configured instances (style merging, ByRule chrome selectors). The default (full type name) is correct for configuration-free rules. A rule whose instances can be configured to match different syntaxes MUST qualify it (TagRule → "tag:" + name, marker rule → "marker:" + marker) or return (identity by reference only) — otherwise differently configured instances are falsely treated as the same rule. Called on hot paths — cache the string, don't rebuild it per access.
Characters of which at least one must start any match of this rule that alters the visible text — strips markup (tags, markers), replaces it, or inserts content. Empty = the rule never consumes text (style-only matches like raw-URL detection); (default) = unknown, callers must assume any text can be consumed. Literal-paste escaping protects exactly these characters, so under-reporting silently mutates pasted text.
Characters whose insertion or removal can make this rule begin or complete a consuming markup match. The editable document parses typed syntax only when an edit contains one of these characters or touches its immediate boundary; empty means this rule has no source syntax, while conservatively parses every direct typing edit. Include closing delimiters and required separators, not only match starts.
Characters of which at least one must be at the match position for TryMatch to succeed at all (consuming or style-only). Defaults to MarkupTriggers — override when the rule matches at characters beyond its consuming set (raw-URL scheme letters). The parser bakes the union into a jump table and skips runs of non-trigger text, so an accurate set here is a large parse speedup; disables the fast scan for the whole component.
Deduplicated union of the rules' MarkupTriggers, or when any rule reports unknown — shared by the parser and CompositeParseRule to advertise the combined trigger set. Null rules are skipped.
public abstract int TryMatch(ReadOnlySpan<char> text, int index, PooledList<ParsedRange> results)Attempts to match a pattern starting at the specified index.
Emits this rule's source syntax wrapping content — the inverse of parsing, used by the editing layer to apply a style and to reconstruct copied markup. Returns when the rule has no content-wrapping form (void, block, or composite rules), meaning it cannot be applied as an inline style.
