Upgraded MudBlazor, ReverseMarkdown, and System.CommandLine (#1236)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-26 11:16:27 +01:00
1 parent 506c06fbfc
commit 9ebfce3855
21 files changed
+506 -96

No files matched your search

@@ -51,11 +51,11 @@ public sealed class ExportableMarkdown : HighlightedMarkdown
#region Overrides of HighlightedMarkdown
/// <inheritdoc />
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info)
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info, Typo typo)
{
if (this.CodeBlockActions is null || FileAt(this.Files, this.ValueStart + code.Span.Start) is not { } file)
{
base.RenderCodeBlock(builder, ref elementIndex, code, info);
base.RenderCodeBlock(builder, ref elementIndex, code, info, typo);
return;
}
@@ -65,7 +65,7 @@ public sealed class ExportableMarkdown : HighlightedMarkdown
//
builder.OpenElement(0, "div");
builder.AddAttribute(1, "class", "code-block-with-actions");
base.RenderCodeBlock(builder, ref elementIndex, code, info);
base.RenderCodeBlock(builder, ref elementIndex, code, info, typo);
builder.OpenElement(2, "div");
builder.AddAttribute(3, "class", "code-block-actions");
@@ -11,8 +11,9 @@ namespace AIStudio.Components;
/// same classes, the same colors of the theme, and the same copy button.
/// </summary>
/// <remarks>
/// Its parameters are strings only. Blazor then renders it again only when the code or the language
/// change, so while an answer streams in, only the block which grows is highlighted again.
/// Its parameters are strings and an enum only. Blazor then renders it again only when the code, the
/// language, or the typography change, so while an answer streams in, only the block which grows is
/// highlighted again.
/// </remarks>
public sealed class HighlightedCodeBlock : ComponentBase
{
@@ -28,6 +29,12 @@ public sealed class HighlightedCodeBlock : ComponentBase
[Parameter]
public string Language { get; set; } = string.Empty;
/// <summary>
/// The typography of the block: that of the body text, which MudMarkdown gives the code blocks it renders itself.
/// </summary>
[Parameter]
public Typo Typo { get; set; }
#region Overrides of ComponentBase
protected override void BuildRenderTree(RenderTreeBuilder builder)
@@ -39,12 +46,9 @@ public sealed class HighlightedCodeBlock : ComponentBase
builder.AddComponentParameter(3, nameof(CodeBlockCopyButton.Text), this.Code);
builder.CloseComponent();
//
// MudMarkdown leaves the typography of its code blocks at the default value, and so do we:
//
builder.OpenComponent<MudText>(4);
builder.AddComponentParameter(5, nameof(MudText.HtmlTag), "pre");
builder.AddComponentParameter(6, nameof(MudText.Typo), default(Typo));
builder.AddComponentParameter(6, nameof(MudText.Typo), this.Typo);
builder.AddComponentParameter(7, nameof(MudText.ChildContent), (RenderFragment)this.RenderCode);
builder.CloseComponent();
@@ -27,7 +27,7 @@ public class HighlightedMarkdown : MudMarkdown
#region Overrides of MudMarkdown
/// <inheritdoc />
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info)
protected override void RenderCodeBlock(in RenderTreeBuilder builder, ref int elementIndex, in Markdig.Syntax.CodeBlock code, in string? info, Typo typo)
{
var text = TextOf(code);
var language = CodeLanguageDetector.FenceLanguageOf(info, text);
@@ -37,7 +37,7 @@ public class HighlightedMarkdown : MudMarkdown
// The copy button of the library confirms in the language of the app, as ours does:
//
this.Styling.CodeBlock.CopyButtonText = CodeBlockCopyButton.ConfirmationText;
base.RenderCodeBlock(builder, ref elementIndex, code, language);
base.RenderCodeBlock(builder, ref elementIndex, code, language, typo);
return;
}
@@ -48,6 +48,7 @@ public class HighlightedMarkdown : MudMarkdown
builder.OpenComponent<HighlightedCodeBlock>(0);
builder.AddComponentParameter(1, nameof(HighlightedCodeBlock.Code), text);
builder.AddComponentParameter(2, nameof(HighlightedCodeBlock.Language), language);
builder.AddComponentParameter(3, nameof(HighlightedCodeBlock.Typo), typo);
builder.CloseComponent();
}