A type representing text with formatting.
Turn a plain string into formatted text.
Take a list of text chunks with formatting and turn them into formatted text.
Apply some formatting to the entirety of a piece of formatted text.
Extract the plain string from formatted text.
Certain operations, like rendering to Html, can be hard to perform with FormattedText directly.
chunks splits a FormattedText up into chunks with equal markup.
It's up to you to define what you want your chunks to look like.
You can get tuples of Strings and markup by passing (,), or you can render directly into Html!
Certain operations, like rendering to Html, can be hard to perform with FormattedText directly.
trees creates a markup tree from a FormattedText.
You can pass it a function for generating a text leaf of the tree, and a function to generate a markup node of the tree.
Check if all characters in a FormattedText meets a condition.
This is the equivalent of String.all.
Check if any character in a FormattedText meets a condition.
This is the equivalent of String.any.
Are two FormattedText the exact same?
Append two FormattedTexts together. The equivalent of String.append or (++).
Concatenate a list of FormattedTexts together. The equivalent of String.concat.
Prepend a character onto a FormattedText.
The added character will not be formatted.
The equivalent of String.cons.
Checks if a FormattedText contains a sub-FormattedText.
Both text and markup of the contained occurrence need to match the sub-FormattedText.
Equivalent of String.contains.
Remove the first n characters of a FormattedText.
Equivalent of String.dropLeft.
Remove the last n characters of a FormattedText.
Equivalent of String.dropRight.
Get an empty FormattedText, the equivalent of an empty string.
Check if a FormattedText end with a sub-FormattedText.
Both text and markup of the contained occurence need to match the sub-FormattedText.
Equivalent of String.endsWith.
Filter out characters from a FormattedText.
This is the equivalent of String.filter.
Fold from the left over a Formattedtext.
This is the equivalent of String.foldl.
Fold from the right over a Formattedtext.
This is the equivalent of String.foldr.
Turn a single character into a FormattedText with no markup applied.
The equivalent of String.fromChar.
Generate a FormattedText from a list of Chars.
The resulting FormattedText will not contain any markup.
This is the equivalent of String.fromList.
Get indexes of occurences of a sub-FormattdText inside a larger one.
Both text and markup of the contained occurrence need to match the sub-FormattedText.
The equivalent of String.indexes.
Alias of indexes.
Check if a FormattedText is empty. Same as text >> String.isEmpty.
Join a list FormattedTexts on a joining FormattedText.
This is the equivalent of String.join.
Markup on all the characters of the component FormattedTexts will be preserved.
Take the first n characters of a FormattedText, with their markup.
Equivalent of String.left.
Length of the string in a FormattedText.
Split a FormattedText on newline characters. The equivalent of String.lines.
Modify each character of a FormattedText by passing it through a mapping function.
This will not affect markup, which is to say: the character returned by the mapping function will have the same markup applied to it that the character passed into the mapping function had applied to it.
This is the equivalent of String.map.
Pad a FormattedText on both sides with a character, until the length of the FormattedText matches or exceeds a certain length.
You can provide markup to be applied to the padding.
This is the equivalent of String.pad.
Pad a FormattedText on the left with a character, until the length of the FormattedText matches or exceeds a certain length.
You can provide markup to be applied to the padding.
This is the equivalent of String.padLeft.
Pad a FormattedText on the right with a character, until the length of the FormattedText matches or exceeds a certain length.
You can provide markup to be applied to the padding.
This is the equivalent of String.padRight.
Repeat a FormattedText a number of times. The equivalent of String.repeat.
Reverse the string in a FormattedText along with its formatting. In other words: every single character will have the same markup after reversal as it had before.
Take the last n characters of a FormattedText, with their markup.
Equivalent of String.right.
Get a slice of a FormattedText as defined by a starting and ending index.
Equivalent of String.slice.
Each character in the slice will have the same markup it had in the original FormattedText.
Split a FormattedText on a string. The equivalent of String.split.
Markup of all characters on the FormattedText will be preserved.
Check if a FormattedText starts with a sub-FormattedText.
Both text and markup of the contained occurence need to match the sub-FormattedText.
Equivalent of String.startsWith.
Parse the FormattedText as a Float.
Markup has no effect on the result.
The equivalent of String.toInt.
Parse the FormattedText as an Int.
Markup has no effect on the result.
The equivalent of String.toInt.
Turn a FormattedText into a list of Chars.
Markup is discarded.
The equivalent of String.toList.
Lowercase the text in a FormattedText.
Markup will not be affected.
This is the equivalent of String.toLowr.
Uppercase the text in a FormattedText.
Markup will not be affected.
This is the equivalent of String.toUpper.
Trim whitespace from both ends of a FormattedText. The equivalent of String.trim.
Trim whitespace from the left end of a FormattedText. The equivalent of String.trimLeft.
Trim whitespace from the right end of a FormattedText. The equivalent of String.trimRight.
Remove the first character from a FormattedText.
The equivalent of String.uncons.
Split a FormattedText on whitespace. The equivalent of String.words.
These functions provide a look behind the curtains at the ranges that are used to implement the FormattedText type. You might need these functions to write encoders / decoders of the FormattedText type. The FormattedText type is upholding some internal constraints, which mean that if you try to micromanage the exact ranges on it you're probably going to have a bad time. If you feel the need to do this, please create an issue on our Github repo with your use case, we might be missing a function!
A format applied to a range. Formatting applies from the start index up to but excluding the end index.
Create a FormattedText from a string and a list of markup ranges.
Note that the FormattedText type obeys certain constraints (see documentation for the FormattedText type).
This means the addRange function makes no promises with regards to what you get back when you call ranges,
only that the characters in the range you indicated will have the formatting you specified attached to them.
Format a range in the FormattedText with a certain type of markup.
Note that the FormattedText type obeys certain constraints (see documentation for the FormattedText type).
This means the addRange function makes no promises with regards to what you get back when you call ranges,
only that the characters in the range you indicated will have the formatting you specified attached to them.
Extract all the markup ranges from the FormattedText.
This function is provided to enable encoding of the FormattedText type. If you feel you need it to achieve something else, please share your use case in an issue on the FormattedText Github repo. Your use case might be inspiration for an additional method.
Text with formatting.