File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -28,25 +28,30 @@ public partial class BitMarkdownViewer : BitComponentBase
2828
2929 protected override async Task OnInitializedAsync ( )
3030 {
31- _html = await _markdownService . Parse ( Markdown , _cts . Token ) ;
32-
33- StateHasChanged ( ) ;
31+ await ParseAndRender ( ) ;
3432
3533 await base . OnInitializedAsync ( ) ;
3634 }
3735
3836
3937
40- private async Task OnMarkdownSet ( )
38+ private void OnMarkdownSet ( )
4139 {
4240 if ( IsRendered is false ) return ;
4341
44- await ParseAndRender ( ) ;
42+ _ = ParseAndRender ( ) ;
4543 }
4644
4745 private async Task ParseAndRender ( )
4846 {
49- _html = await _markdownService . Parse ( Markdown , _cts . Token ) ;
47+ try
48+ {
49+ _html = await _markdownService . Parse ( Markdown , _cts . Token ) ;
50+ }
51+ catch
52+ {
53+ _html = "<b>Failed to parse the markdown!</b>" ;
54+ }
5055
5156 StateHasChanged ( ) ;
5257 }
You can’t perform that action at this time.
0 commit comments