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.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.7" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
</ItemGroup>

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.6" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.6" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.7" PrivateAssets="all" />
<PackageReference Include="ReactiveUI.Blazor" Version="20.4.1" />
<PackageReference Include="System.Net.Http.Json" Version="9.0.6" />
<PackageReference Include="System.Net.Http.Json" Version="9.0.7" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 10 additions & 3 deletions src/MudBlazor.Markdown/MudMarkdown.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,17 @@ protected virtual void RenderInlines(RenderTreeBuilder builder1, ref int element
builder1.AddMarkupContent(elementIndex1++, x.Tag);
break;
}
case LineBreakInline:
case LineBreakInline x:
{
builder1.OpenElement(elementIndex1++, "br");
builder1.CloseElement();
if (x.IsHard)
{
builder1.OpenElement(elementIndex1++, "br");
builder1.CloseElement();
}
else
{
builder1.AddContent(elementIndex1++, " ");
}
break;
}
case CodeInline x:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Another text
<div class='mud-collapse-wrapper' blazor:elementReference='f0339543-23a6-43d6-92b9-b8b55ec88622'>
<div class='mud-collapse-wrapper-inner'>
<div class='mud-expand-panel-content'>
<p class='mud-typography mud-typography-body1'>Some hidden text<br />Another text</p>
<p class='mud-typography mud-typography-body1'>Some hidden text Another text</p>
</div>
</div>
</div>
Expand All @@ -45,7 +45,7 @@ Another text
}

[Fact]
public void RenderDetailsSummaryMultiLine()
public void RenderDetailsSummaryMultiline()
{
const string value =
"""
Expand Down Expand Up @@ -75,7 +75,7 @@ Another text
<div class='mud-collapse-wrapper' blazor:elementReference='99a17eaa-605d-411d-968b-457a412ddd48'>
<div class='mud-collapse-wrapper-inner'>
<div class='mud-expand-panel-content'>
<p class='mud-typography mud-typography-body1'>Some hidden text<br />Another text</p>
<p class='mud-typography mud-typography-body1'>Some hidden text Another text</p>
</div>
</div>
</div>
Expand Down Expand Up @@ -184,7 +184,7 @@ Another text
<div class='mud-collapse-wrapper' blazor:elementReference=''>
<div class='mud-collapse-wrapper-inner'>
<div class='mud-expand-panel-content'>
<p class='mud-typography mud-typography-body1'>Some hidden text<br />Another text</p>
<p class='mud-typography mud-typography-body1'>Some hidden text Another text</p>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,9 @@ public void OverrideAllLinks()
<a rel='noopener noreferrer' href='overriddenhttps://www.google.co.jp/' target='_blank' class='mud-typography mud-link mud-primary-text mud-link-underline-hover mud-typography-body1'>
absolute
</a>
<br />
<a href='overridden/tokyo' class='mud-typography mud-link mud-primary-text mud-link-underline-hover mud-typography-body1'>
relative
</a>
<br />
<a href='overridden#edogawa' class='mud-typography mud-link mud-primary-text mud-link-underline-hover mud-typography-body1'>
id
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,49 @@ public void RenderInvalidEmphasis(string emphasisDelimiter)
[Theory]
[InlineData("\r\n")]
[InlineData("\n")]
public void ReplaceNewLineSymbols(string newLine)
public void RenderBreakSoft(string newLine)
{
var value = "line1" + newLine + "line2";
const string expected =
"""
<article id:ignore class='mud-markdown-body'>
<p class='mud-typography mud-typography-body1'>
line1 line2
</p>
</article>
""";

using var fixture = CreateFixture(value);
fixture.MarkupMatches(expected);
}

[Theory]
[InlineData("\r\n")]
[InlineData("\n")]
public void RenderBreakHard(string newLine)
{
var value = "line1" + newLine + newLine + "line2";
const string expected =
"""
<article id:ignore class='mud-markdown-body'>
<p class='mud-typography mud-typography-body1'>line1</p>
<p class='mud-typography mud-typography-body1'>line2</p>
</article>
""";

using var fixture = CreateFixture(value);
fixture.MarkupMatches(expected);
}

[Fact]
public void RenderBreakHardWithSpaces()
{
const string value =
"""
line1
line2
""";

const string expected =
"""
<article id:ignore class='mud-markdown-body'>
Expand All @@ -91,6 +131,29 @@ public void ReplaceNewLineSymbols(string newLine)
fixture.MarkupMatches(expected);
}

[Theory]
[InlineData("\r\n")]
[InlineData("\n")]
public void RenderBreakHardWithPipeline(string newLine)
{
var value = "line1" + newLine + "line2";
const string expected =
"""
<article id:ignore class='mud-markdown-body'>
<p class='mud-typography mud-typography-body1'>
line1<br />line2
</p>
</article>
""";

var markdownPipeline = new MarkdownPipelineBuilder()
.UseSoftlineBreakAsHardlineBreak()
.Build();

using var fixture = CreateFixture(value, markdownPipeline: markdownPipeline);
fixture.MarkupMatches(expected);
}

[Fact]
public void RenderExternalLink()
{
Expand Down