TextMateCodeBlockRendererReplaces the built-in CodeBlockRenderer when syntax highlighting is active. For fenced code blocks it highlights each line with the CodeHighlighter and, when that highlighter is an IDualThemeCodeHighlighter, recolours the tokens in-place when the user switches between light and dark themes — without tokenising the code again or rebuilding the surrounding document tree.
TextMateExtensionWires MarkView.Avalonia.SyntaxHighlighting.DualThemeTextMateHighlighter and TextMateCodeBlockRenderer into an AvaloniaRenderer. The highlighter is created lazily, holds the dark and the light theme over one shared set of grammars, and is exposed as an IDualThemeCodeHighlighter so code block renderers can update token colours in-place when the theme changes without rebuilding the entire document. Every extension with the same pair of themes shares one highlighter while any of them is alive, so a viewer per message (a chat) loads the themes and grammars once, not once per viewer.
TextMateHighlighterTokenises source-code lines using TextMate grammars and maps token scopes to Avalonia.Media.IBrush colours via the chosen theme.