Upgrading to 12.4

12.4.0 is a breaking release (see Versioning). Most applications only need to update the packages together and recompile; check the changes below that apply to yours.

Update every package together

The extension packages of 12.4.0 (SyntaxHighlighting, Svg, Mermaid, Math) require MarkView.Avalonia 12.4.0, and apps built against 12.3.0 must be recompiled: UseMath(), UseMermaid() and AddMermaid() gained optional parameters, which is source compatible but not binary compatible.

The default pipeline is now GitHub's

A viewer without a Pipeline now uses UseGitHubExtensions() instead of UseSupportedExtensions(), so documents render as on GitHub:

  • ~text~ is strikethrough instead of subscript.
  • Alerts (> [!NOTE]), footnotes, <details> blocks and the HTML subset render.
  • Grid tables, ^superscript^, ++underline++ and ==highlight== are no longer parsed.

To keep the previous rendering, set the previous pipeline as the default:

MarkdownViewerDefaults.Pipeline = new MarkdownPipelineBuilder().UseSupportedExtensions().Build();

See Markdown and the pipeline for the differences and how to combine them.

Removed pipeline methods

UseAbbreviations(), UseCitations(), UseFigures(), UseFootnotes(), UseAlertBlocks() and UseMediaLinks() were removed from MarkView.Avalonia.MarkdownExtensions, the extension methods of MarkdownPipelineBuilder. They were identical to Markdig's own, and four of them clashed with them (error CS0121) when both namespaces were imported. Code that calls them keeps compiling and now calls Markdig's methods. The MarkdownViewer methods of the same names (viewer.UseFootnotes()…) are unchanged.

The viewer has a context menu

A right-click on the viewer opens its new context menu (copy, copy as Markdown, copy a link or a table, save an image, select all). Set your own ContextFlyout or ContextMenu to replace it, or remove it:

<mv:MarkdownViewer ContextFlyout="{x:Null}" />

See Selection and copy.

Mermaid diagrams render when shown

A diagram renders once its viewer is attached to a window, in the background on the desktop and, in the browser, once it comes within a screen of the visible area. A diagram that is never shown is never rendered.

Sealed classes

MarkdownSelectableTextBlock and SlugGenerator are sealed. Style headings and paragraphs through their control themes instead of deriving from them.

New defaults to know

These are not breaking, but change what a document shows:

  • Code blocks have a copy button above the code (ShowCodeBlockCopyButton, on by default); the language label is off by default (ShowCodeBlockLanguage).
  • Images, formulas, diagrams and code colours are built when they are about to scroll into view (IsLazyRenderingEnabled, on by default). Turn it off for a viewer that is rendered to a bitmap without being scrolled; see Lazy rendering.
  • Each block takes the direction of its text, so Hebrew and Arabic read right to left (DetectTextDirection, on by default).
  • The high-contrast palette follows the OS setting (HighContrastMode, System by default).

The release notes list every change of the release.