Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having an extra <ul> tag throws an error "System.InvalidOperationException: Sequence contains no elements" #395

Closed
shettyanusha opened this issue May 7, 2024 · 3 comments · Fixed by #398
Labels
awaiting feedback This issue is awaiting feedback from the reporter bug Something isn't working

Comments

@shettyanusha
Copy link

shettyanusha commented May 7, 2024

Report issue

If there is an extra <ul> in the html string, the package throws the below error
System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.Aggregate[TSource](IEnumerable1 source, Func3 func)
at Html2Markdown.Replacement.HtmlParser.ReplaceList(String html)
at Html2Markdown.Replacement.HtmlParser.ReplaceLists(String html)
at Html2Markdown.Replacement.CustomReplacer.Replace(String html)
at Html2Markdown.Converter.<>c.b__5_0(String current, IReplacer element)
at System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable1 source, TAccumulate seed, Func3 func)
at Html2Markdown.Converter.Convert(String html)

The String used to test this -
<ul><ul><li>first list val</li></ul></ul>

Expected behavior

The extra <ul> tag should be ignored.

Actual Behaviour

Error

Steps to reproduce the problem

var description = "<ul><ul><li>first list val</li></ul></ul>"; var converter = new Converter(); markdown = converter.Convert(description);

@github-actions github-actions bot added the to do Work that is yet to be started label May 7, 2024
@baynezy baynezy added bug Something isn't working awaiting feedback This issue is awaiting feedback from the reporter labels May 7, 2024
@baynezy
Copy link
Owner

baynezy commented May 7, 2024

@shettyanusha thanks for raising the bug. Are you using the latest version of the package? If I try and use your reproduction case I get an empty string. That is obviously still a bug but not this error.

baynezy added a commit that referenced this issue May 7, 2024
@github-actions github-actions bot added in progress In flight work and removed to do Work that is yet to be started labels May 7, 2024
@github-actions github-actions bot added next release Completed work that is yet to be deployed and removed in progress In flight work labels May 7, 2024
@baynezy
Copy link
Owner

baynezy commented May 7, 2024

@shettyanusha - I am in the midst of releasing this to Nuget. It wil be in version 6.2.1.4.

Kind regards.

@baynezy baynezy removed the next release Completed work that is yet to be deployed label May 7, 2024
@ashetty-planview
Copy link

ashetty-planview commented May 10, 2024

Thank you so much @baynezy. I'm on .NETStandard 2.1 and it seems like version 6 is not compatible with it. The Html2Markdown version is 5.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback This issue is awaiting feedback from the reporter bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants