Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.4" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>

Expand Down
8 changes: 7 additions & 1 deletion samples/MudBlazor.Markdown.Core/sample-issues.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# [Unknown language - Razor](https://github.com/MyNihongo/MudBlazor.Markdown/issues/260)
# [Indented code block](https://github.com/MyNihongo/MudBlazor.Markdown/issues/294)
if
{
return;
}

# [Unknown language - Razor](https://github.com/MyNihongo/MudBlazor.Markdown/issues/260)
```razor
@page
@model IndexModel
Expand Down
6 changes: 3 additions & 3 deletions samples/WebAssembly/MudBlazor.Markdown.Wasm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.4" PrivateAssets="all" />
<PackageReference Include="ReactiveUI.Blazor" Version="20.2.45" />
<PackageReference Include="System.Net.Http.Json" Version="9.0.3" />
<PackageReference Include="System.Net.Http.Json" Version="9.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/MudBlazor.Markdown/MudBlazor.Markdown.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Markdig" Version="0.40.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.3" />
<PackageReference Include="MudBlazor" Version="8.4.0" />
<PackageReference Include="Markdig" Version="0.41.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.4" />
<PackageReference Include="MudBlazor" Version="8.5.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 14 additions & 4 deletions src/MudBlazor.Markdown/MudMarkdown.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ protected virtual void RenderMarkdown(ContainerBlock container, RenderTreeBuilde
}
case FencedCodeBlock code:
{
RenderFencedCodeBlock(builder, code);
RenderCodeBlock(builder, code, code.Info);
break;
}
case CodeBlock code:
{
RenderCodeBlock(builder, code, info: null);
break;
}
case HtmlBlock html:
Expand Down Expand Up @@ -481,7 +486,12 @@ protected virtual void RenderList(ListBlock list, RenderTreeBuilder builder)
}
case FencedCodeBlock x:
{
RenderFencedCodeBlock(builder, x);
RenderCodeBlock(builder, x, x.Info);
break;
}
case CodeBlock x:
{
RenderCodeBlock(builder, x, info: null);
break;
}
default:
Expand Down Expand Up @@ -523,13 +533,13 @@ protected virtual void RenderHtml(in RenderTreeBuilder builder, in StringLineGro
builder.AddContent(ElementIndex, markupString);
}

protected virtual void RenderFencedCodeBlock(in RenderTreeBuilder builder, in FencedCodeBlock code)
protected virtual void RenderCodeBlock(in RenderTreeBuilder builder, in CodeBlock code, in string? info)
{
var text = code.CreateCodeBlockText();

builder.OpenComponent<MudCodeHighlight>(ElementIndex++);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Text), text);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Language), code.Info ?? string.Empty);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Language), info ?? string.Empty);
builder.AddAttribute(ElementIndex++, nameof(MudCodeHighlight.Theme), CodeBlockTheme);
builder.CloseComponent();
}
Expand Down
4 changes: 2 additions & 2 deletions src/MudBlazor.Markdown/Utils/Extensions/FencedCodeBlockEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MudBlazor;

internal static class FencedCodeBlockEx
{
public static string CreateCodeBlockText(this FencedCodeBlock @this)
public static string CreateCodeBlockText(this CodeBlock @this)
{
if (@this.Lines.Count == 0)
return string.Empty;
Expand All @@ -27,4 +27,4 @@ public static string CreateCodeBlockText(this FencedCodeBlock @this)

return sb.ToString();
}
}
}
Loading
Loading