Expand description
Text helpers shared by the engines: markup stripping, previews, whole-word matching, tag balance and serialized sizes.
Statics§
- WHITESPACE_
TO_ 🔒COLLAPSE - Whitespace that isn’t a single space; collapsing only these leaves most text borrowed.
Functions§
- collapse_
whitespace 🔒 - is_
inside_ character_ reference - Whether byte offset
atfalls after the&of a character reference such as&and at or before its;. - is_
inside_ tag - Whether byte offset
atofhtmlfalls inside a tag (<a href="…">). - is_
word_ 🔒char - Letters, digits and
_, non-ASCII ones included. main-frontend’s glossary highlighting (textParsing.tsx) uses the same set; change both together. - open_
tags_ at - Inline elements still open at byte offset
at, outermost first. - plain_
text - The visible text of a rich-text string: tags removed, common entities decoded, whitespace collapsed to single spaces.
- preview
- Cuts
textto at mostmax_charscharacters at a word boundary, adding an ellipsis when cut. - serialized_
len - The size of
valueas JSON, in bytes, without building the JSON. - whole_
word_ matches - Byte ranges of the occurrences of
needleintextthat don’t start or end inside a word. An end ofneedlethat isn’t a word character (as in “C++”) needs no word boundary.