whistyun / Markdown.Avalonia

render markdown with Avalonia UI
MIT License
301 stars 24 forks source link

Custom MarkdownStyle prevents SyntaxHighlight plugin from working #161

Closed DVaughan closed 1 month ago

DVaughan commented 1 month ago

Thanks for creating this terrific project.

If I assign a custom MarkdownStyle, identical to MarkdownStyleStandard.axaml, like so:

<mdxaml:MarkdownScrollViewer Markdown="{x:Static markdownDemoDan2:MainWindow.JavaCode}">
    <mdxaml:MarkdownScrollViewer.MarkdownStyle>
        <StyleInclude Source="/MarkdownStylesCustom.axaml" />
    </mdxaml:MarkdownScrollViewer.MarkdownStyle>
</mdxaml:MarkdownScrollViewer>

It breaks the code syntax highlighting, resulting in:

image

If I comment out custom style, like so:

<mdxaml:MarkdownScrollViewer Markdown="{x:Static markdownDemoDan2:MainWindow.JavaCode}">
    <!--<mdxaml:MarkdownScrollViewer.MarkdownStyle>
        <StyleInclude Source="/MarkdownStylesCustom.axaml" />
    </mdxaml:MarkdownScrollViewer.MarkdownStyle>-->
</mdxaml:MarkdownScrollViewer>

The highlighting works again:

image

DVaughan commented 1 month ago

I found the problem. It was my code. I should be using Styles not MarkdownStyle.

<mdxaml:MarkdownScrollViewer Markdown="{x:Static markdownDemoDan2:MainWindow.JavaCode}">
    <mdxaml:MarkdownScrollViewer.Styles>
        <StyleInclude Source="/MarkdownStylesCustom.axaml" />
    </mdxaml:MarkdownScrollViewer.Styles>
</mdxaml:MarkdownScrollViewer>