MarkdownVisualTransformation

class MarkdownVisualTransformation(boldStyle: SpanStyle, italicStyle: SpanStyle, strikethroughStyle: SpanStyle, codeStyle: SpanStyle, linkStyle: SpanStyle, headingStyle: SpanStyle, listMarkerStyle: SpanStyle, quoteStyle: SpanStyle, symbolStyle: SpanStyle) : VisualTransformation(source)

Syntax highlighting for the Markdown a field is written in.

Styling only: every rule keeps the character count of the source text, so OffsetMapping.Identity stays correct and the caret, the selection handles and the text the ViewModel receives are the ones the author actually typed. That is also why a Markdown renderer cannot do this job — the field is an editor, so the markers have to stay visible, selectable and editable, and only their appearance may change.

Rules are applied in a fixed order and code spans win: text inside backticks or a fence is code, not emphasis, so ** inside a stack trace is not silently restyled as bold.

Parameters

boldStyle

Applied to the content of **bold** and __bold__.

italicStyle

Applied to the content of *italic* and _italic_.

strikethroughStyle

Applied to the content of ~~struck~~.

codeStyle

Applied to inline code spans and fenced blocks, markers included.

linkStyle

Applied to the label of [label](url).

headingStyle

Applied to a whole # heading line.

listMarkerStyle

Applied to the bullet or number that opens a list item.

quoteStyle

Applied to a whole > quoted line.

symbolStyle

Applied to the markers themselves, so syntax recedes behind the text.

Constructors

Link copied to clipboard
constructor(boldStyle: SpanStyle, italicStyle: SpanStyle, strikethroughStyle: SpanStyle, codeStyle: SpanStyle, linkStyle: SpanStyle, headingStyle: SpanStyle, listMarkerStyle: SpanStyle, quoteStyle: SpanStyle, symbolStyle: SpanStyle)

Functions

Link copied to clipboard
open override fun filter(text: AnnotatedString): TransformedText