setSimpleStyledText

fun setSimpleStyledText(str: String, styles: Map<Char, Highlight>, terminators: Map<Char, Char> = emptyMap())

Parses str, looking for style markings, which are single characters from the keys of styles. The style markings are removed and the remainder is used as the document's text.

All existing HighlightRanges in the document are replaced.

styles specifies which Highlight to add to text enclosed in a particular character. For example,

mapOf( '_' to ThemeHighlight(".underline") )

Would apply Node.style .underline to all text that enclosed with underscores.

If you wish to use a different symbol as the terminator, then use terminators. For example,

terminators = mapOf( ']' to '[' )

Allows text within [ ... ] to be styled (you must also add [ to styles).

Backslash can be used to escape any character (which may clash with a style marking). e.g.

str = "No \_underlined\_ text"

Would set the document text to No _underlined_ text, with no HighlightRanges.