-
-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Describe the bug
If you use the markdown component and give as input a null value or an empty string the whole component won't work anymore because it throws an ArgumentOutOfException exception.
To Reproduce
- Go to the demo website of this component https://demos.blazorbootstrap.com/markdown#live-preview
- clear the complete text from the markdown textarea
- the preview won't render anymore if you type valid markdown in the textarea
OR
<Markdown style="max-height: 437px;overflow-y:auto;"> @string.Empty </Markdown>
Expected behavior
display an empty string if the input is null or an empty string
Screenshots
When debugging in VS 2022 the problem lies in the GetLines() function in Markdown.cs when list.Count = 0 and the function tries ao access an item at position -1.

Versions (please complete the following information):
- .NET Version: .NET 9
- BlazorBootstrap: 3.2.0
- Blazor WebAssembly / Server: Blazor Server
- Blazor Interactive Render Mode: Server
Sample code
Sample code to reproduce the issue.
GitHub repo
GitHub repo with minimal code to reproduce the issue.
Desktop (please complete the following information):
- OS: Windows 10
- Browser Chrome
- Version 131