From e5cf3ebb75b7d935ac61e4fb995b4cb0e30cb94c Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Sat, 18 Oct 2025 13:54:55 +0200 Subject: [PATCH 1/5] BlogPageBlockquote --- .../BlogRuntime/BlogRuntimeSink.cs | 22 ++++++++----------- .../Components/BlogPageBlockquote.razor | 8 +++++++ 2 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 Documentation/Blazorise.Docs/Components/BlogPageBlockquote.razor diff --git a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs index acc482a05e..4bdb3a838d 100644 --- a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs +++ b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs @@ -128,23 +128,19 @@ public void AddPageParagraph( ParagraphBlock p ) public void AddPageQuote( QuoteBlock q ) { - foreach ( var block in q ) + ops.Add( b => { - if ( block is ParagraphBlock p ) + b.OpenComponent( 50, typeof( BlogPageBlockquote ) ); + b.AddAttribute( 51, nameof( BlogPageBlockquote.ChildContent ), (RenderFragment)( bb => { - ops.Add( b => + foreach ( var block in q ) { - b.OpenComponent( 50, typeof( BlogPageParagraph ) ); - b.AddAttribute( 51, nameof( BlogPageParagraph.ChildContent ), (RenderFragment)( bb => - { - bb.OpenElement( 52, "blockquote" ); + if ( block is ParagraphBlock p ) RenderInlines( bb, p.Inline ); - bb.CloseElement(); - } ) ); - b.CloseComponent(); - } ); - } - } + } + } ) ); + b.CloseComponent(); + } ); } public void AddPageList( ListBlock list ) diff --git a/Documentation/Blazorise.Docs/Components/BlogPageBlockquote.razor b/Documentation/Blazorise.Docs/Components/BlogPageBlockquote.razor new file mode 100644 index 0000000000..e31494c91c --- /dev/null +++ b/Documentation/Blazorise.Docs/Components/BlogPageBlockquote.razor @@ -0,0 +1,8 @@ +
+ + @ChildContent + +
+@code { + [Parameter] public RenderFragment ChildContent { get; set; } +} From ac67ab0c3865719a1cf4c1a160a66da686247d90 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Sat, 18 Oct 2025 13:55:43 +0200 Subject: [PATCH 2/5] Improve inline rendering --- .../BlogRuntime/BlogRuntimeSink.cs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs index 4bdb3a838d..953b0b3262 100644 --- a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs +++ b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs @@ -273,25 +273,20 @@ private static void RenderInlines( RenderTreeBuilder b, ContainerInline inline, { switch ( child ) { - case EmphasisInline em when em.DelimiterCount == 2: - b.OpenComponent( 110, typeof( Strong ) ); - b.AddAttribute( 111, nameof( Strong.ChildContent ), (RenderFragment)( bb => + // Bold + Italic + Strikethrough + case EmphasisInline em: + b.OpenComponent( 101, typeof( Blazorise.Text ) ); + b.AddAttribute( 102, nameof( Blazorise.Text.Italic ), em.DelimiterCount == 1 || em.DelimiterCount == 3 ); + b.AddAttribute( 103, nameof( Blazorise.Text.TextWeight ), em.DelimiterCount == 2 || em.DelimiterCount == 3 ? TextWeight.Bold : TextWeight.Default ); + b.AddAttribute( 104, nameof( Blazorise.Text.TextDecoration ), em.DelimiterChar == '~' ? TextDecoration.LineThrough : TextDecoration.Default ); + b.AddAttribute( 105, nameof( Blazorise.Text.ChildContent ), (RenderFragment)( bb => { - bb.AddContent( 112, string.Join( "", em ) ); - } ) ); - b.CloseComponent(); - break; - - case EmphasisInline em1 when em1.DelimiterCount == 1: - b.OpenComponent( 120, typeof( Text ) ); - b.AddAttribute( 121, nameof( Text.Italic ), true ); - b.AddAttribute( 122, nameof( Text.ChildContent ), (RenderFragment)( bb => - { - bb.AddContent( 123, string.Join( "", em1 ) ); + bb.AddContent( 106, string.Join( "", em ) ); } ) ); b.CloseComponent(); break; + // Links case LinkInline link when !link.IsImage: b.OpenComponent( 130, typeof( Anchor ) ); b.AddAttribute( 131, nameof( Anchor.To ), link.Url ); @@ -304,6 +299,7 @@ private static void RenderInlines( RenderTreeBuilder b, ContainerInline inline, b.CloseComponent(); break; + // Image case LinkInline img when img.IsImage: var t = string.IsNullOrEmpty( img.Title ) ? img.FirstChild?.ToString() : img.Title; var imageSource = rewriteImageUrl is null ? img.Url : rewriteImageUrl( img.Url ); @@ -313,6 +309,7 @@ private static void RenderInlines( RenderTreeBuilder b, ContainerInline inline, b.CloseComponent(); break; + // Code case CodeInline ci: var content = ci.Content; var isTag = content.StartsWith( '<' ) && content.EndsWith( '>' ); @@ -324,8 +321,12 @@ private static void RenderInlines( RenderTreeBuilder b, ContainerInline inline, b.CloseComponent(); break; + case LineBreakInline: + b.AddMarkupContent( 160, "
" ); + break; + default: - b.AddContent( 160, child.ToString() ); + b.AddContent( 180, child.ToString() ); break; } } From 6f7de9c4a00245e0a18063d198dde634873d4df9 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Sat, 18 Oct 2025 13:55:58 +0200 Subject: [PATCH 3/5] Fix table naming --- Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs index 953b0b3262..8c31cc4720 100644 --- a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs +++ b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs @@ -149,7 +149,7 @@ public void AddPageList( ListBlock list ) { b.OpenComponent( 60, typeof( BlogPageList ) ); if ( list.IsOrdered ) - b.AddAttribute( 61, nameof( BlogPageList.Ordered ), true ); + b.AddAttribute( 61, nameof( BlogPageList.Ordered ), list.IsOrdered ); b.AddAttribute( 62, nameof( BlogPageList.ChildContent ), (RenderFragment)( bb => { foreach ( ListItemBlock item in list ) @@ -198,7 +198,7 @@ public void AddPageTable( Markdig.Extensions.Tables.Table table ) hb.OpenComponent( 84, typeof( Blazorise.TableRow ) ); hb.AddAttribute( 85, "ChildContent", (RenderFragment)( hrb => { - foreach ( var cell in row.OfType() ) + foreach ( var cell in row.OfType() ) { hrb.OpenComponent( 86, typeof( Blazorise.TableHeaderCell ) ); hrb.AddAttribute( 87, "ChildContent", (RenderFragment)( hcb => @@ -229,7 +229,7 @@ public void AddPageTable( Markdig.Extensions.Tables.Table table ) tb.OpenComponent( 90, typeof( Blazorise.TableRow ) ); tb.AddAttribute( 91, "ChildContent", (RenderFragment)( trb => { - foreach ( var cell in row.OfType() ) + foreach ( var cell in row.OfType() ) { trb.OpenComponent( 92, typeof( Blazorise.TableRowCell ) ); trb.AddAttribute( 93, "ChildContent", (RenderFragment)( tcb => From dd31ad18d3d68ff49cd27842d25c4bdc7a3deacf Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Sat, 18 Oct 2025 14:13:10 +0200 Subject: [PATCH 4/5] Nested lists --- .../BlogRuntime/BlogRuntimeSink.cs | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs index 8c31cc4720..7a78a3d342 100644 --- a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs +++ b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs @@ -145,31 +145,51 @@ public void AddPageQuote( QuoteBlock q ) public void AddPageList( ListBlock list ) { - ops.Add( b => + ops.Add( b => RenderList( b, list ) ); + } + + private void RenderList( RenderTreeBuilder b, ListBlock list ) + { + b.OpenComponent( 60, typeof( BlogPageList ) ); + b.AddAttribute( 61, nameof( BlogPageList.Ordered ), list.IsOrdered ); + b.AddAttribute( 62, nameof( BlogPageList.ChildContent ), (RenderFragment)( bb => { - b.OpenComponent( 60, typeof( BlogPageList ) ); - if ( list.IsOrdered ) - b.AddAttribute( 61, nameof( BlogPageList.Ordered ), list.IsOrdered ); - b.AddAttribute( 62, nameof( BlogPageList.ChildContent ), (RenderFragment)( bb => + foreach ( ListItemBlock item in list ) { - foreach ( ListItemBlock item in list ) + bb.OpenComponent( 63, typeof( BlogPageListItem ) ); + bb.AddAttribute( 64, nameof( BlogPageListItem.ChildContent ), (RenderFragment)( bbb => { - bb.OpenComponent( 63, typeof( BlogPageListItem ) ); - bb.AddAttribute( 64, nameof( BlogPageListItem.ChildContent ), (RenderFragment)( bbb => + foreach ( var child in item ) { - foreach ( var child in item ) + switch ( child ) { - if ( child is ParagraphBlock p ) + case ParagraphBlock p: RenderInlines( bbb, p.Inline ); - else if ( child is FencedCodeBlock code ) + break; + + case FencedCodeBlock code: PersistCodeBlockInternal( bbb, code ); + break; + + case ListBlock nested: + RenderList( bbb, nested ); + break; + + case QuoteBlock q: + foreach ( var qChild in q ) + if ( qChild is ParagraphBlock qp ) + RenderInlines( bbb, qp.Inline ); + break; + + default: + break; } - } ) ); - bb.CloseComponent(); - } - } ) ); - b.CloseComponent(); - } ); + } + } ) ); + bb.CloseComponent(); + } + } ) ); + b.CloseComponent(); } public void AddPageDivider() From f7c677d3f92b318897eb4633d821d5cf35f28633 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Sat, 18 Oct 2025 14:29:06 +0200 Subject: [PATCH 5/5] Fix bold+italic combo --- .../Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs index 7a78a3d342..b0ed9a0713 100644 --- a/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs +++ b/Documentation/Blazorise.Docs/BlogRuntime/BlogRuntimeSink.cs @@ -295,13 +295,17 @@ private static void RenderInlines( RenderTreeBuilder b, ContainerInline inline, { // Bold + Italic + Strikethrough case EmphasisInline em: + var isStrike = em.DelimiterChar == '~'; + var isBold = !isStrike && em.DelimiterCount >= 2; + var isItalic = !isStrike && ( em.DelimiterCount == 1 || em.DelimiterCount == 3 ); + b.OpenComponent( 101, typeof( Blazorise.Text ) ); - b.AddAttribute( 102, nameof( Blazorise.Text.Italic ), em.DelimiterCount == 1 || em.DelimiterCount == 3 ); - b.AddAttribute( 103, nameof( Blazorise.Text.TextWeight ), em.DelimiterCount == 2 || em.DelimiterCount == 3 ? TextWeight.Bold : TextWeight.Default ); - b.AddAttribute( 104, nameof( Blazorise.Text.TextDecoration ), em.DelimiterChar == '~' ? TextDecoration.LineThrough : TextDecoration.Default ); + b.AddAttribute( 102, nameof( Blazorise.Text.Italic ), isItalic ); + b.AddAttribute( 103, nameof( Blazorise.Text.TextWeight ), isBold ? TextWeight.Bold : TextWeight.Default ); + b.AddAttribute( 104, nameof( Blazorise.Text.TextDecoration ), isStrike ? TextDecoration.LineThrough : TextDecoration.Default ); b.AddAttribute( 105, nameof( Blazorise.Text.ChildContent ), (RenderFragment)( bb => { - bb.AddContent( 106, string.Join( "", em ) ); + RenderInlines( bb, em ); } ) ); b.CloseComponent(); break;