Markdown.Avalonia
Markdown.Avalonia copied to clipboard
Markdown code blocks render empty when language is specified
When rendering Markdown code blocks using MarkdownScrollViewer
, blocks with a language specifier at the top (e.g., ````csharp`) render as empty rectangles. Code blocks without a language specifier (e.g., `````) render correctly.
Steps to Reproduce:
- Create a
MarkdownScrollViewer
control in an Avalonia application. - Bind the
Markdown
property to a string containing a Markdown code block with a language specifier, for example:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
- Run the application.
Expected Behaviour:
The code block should be rendered with syntax highlighting according to the specified language (in this case, C#).
Actual Behaviour:
The code block is rendered as an empty rectangle with a border and padding, but no code content is displayed.
Screenshots:
-
Working code block (no language specifier):
-
Empty code block (with language specifier):
Relevant Code:
XAML:
<md:MarkdownScrollViewer Markdown="{Binding Message}" SelectionEnabled="True">
<md:MarkdownScrollViewer.Plugins>
<md:MdAvPlugins>
<mdt:ChatAISetup />
</md:MdAvPlugins>
</md:MarkdownScrollViewer.Plugins>
<md:MarkdownScrollViewer.Styles>
<Style Selector="Border.CodeBlock">
<Style.Setters>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="12"/>
<Setter Property="Margin" Value="10"/>
<Setter Property="Padding" Value="8"/>
</Style.Setters>
</Style>
</md:MarkdownScrollViewer.Styles>
</md:MarkdownScrollViewer>
Additional Information:
- Avalonia version: 11.1.3
- Markdown.Avalonia Version: 11.0.3-a1
Any suggestions on this ?