diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 0e5eca29..9f458e61 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -12,8 +12,9 @@ jobs: runs-on: ubuntu-latest environment: github-pages steps: - - uses: DenverCoder1/doxygen-github-pages-action@v1.3.0 + - uses: baynezy/doxygen-github-pages-action@feature/specific-version with: github_token: ${{ secrets.PUBLISH_DOCS_TOKEN }} branch: gh-pages - config_file: doxygen.config \ No newline at end of file + config_file: doxygen.config + doxygen_version: 1.9.6 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 099fa86d..b90a9039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.2.5.7] - 2024-08-07 + +### Fixed + +- Fixed issue where empty HTML lists would cause a `System.InvalidOperationException` + ## [6.2.4.6] - 2024-08-02 ### Added @@ -470,7 +476,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.0.1] - 2013-07-04 -[unreleased]: https://github.com/baynezy/Html2Markdown/compare/6.2.4.6...HEAD +[unreleased]: https://github.com/baynezy/Html2Markdown/compare/6.2.5.7...HEAD +[6.2.5.7]: https://github.com/baynezy/Html2Markdown/compare/6.2.4.6...6.2.5.7 [6.2.4.6]: https://github.com/baynezy/Html2Markdown/compare/6.2.3.6...6.2.4.6 [6.2.3.6]: https://github.com/baynezy/Html2Markdown/compare/6.2.2.5...6.2.3.6 [6.2.2.5]: https://github.com/baynezy/Html2Markdown/compare/6.2.1.4...6.2.2.5 diff --git a/semver.json b/semver.json index 4b88c8fa..3bf8d8b5 100644 --- a/semver.json +++ b/semver.json @@ -1 +1 @@ -{"major":"6","minor":"2","patch":"4","build":"6"} \ No newline at end of file +{"major":"6","minor":"2","patch":"5","build":"7"} \ No newline at end of file diff --git a/src/Html2Markdown/Replacement/HtmlParser.cs b/src/Html2Markdown/Replacement/HtmlParser.cs index cc051ef5..27b46b76 100644 --- a/src/Html2Markdown/Replacement/HtmlParser.cs +++ b/src/Html2Markdown/Replacement/HtmlParser.cs @@ -68,6 +68,8 @@ private static string ReplaceList(string html) } markdownList.Add($"{listPrefix}{finalList}"); }); + + if (markdownList.Count == 0) return string.Empty; //If a new line is already ending the markdown item, then we don't need to add another one return Environment.NewLine + Environment.NewLine + markdownList.Aggregate((current, item) => current.EndsWith(Environment.NewLine) ? current + item : current + Environment.NewLine + item) + Environment.NewLine + Environment.NewLine; diff --git a/test/Html2Markdown.Test/CommonMarkSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt b/test/Html2Markdown.Test/CommonMarkSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/test/Html2Markdown.Test/CommonMarkSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/test/Html2Markdown.Test/MarkdownSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt b/test/Html2Markdown.Test/MarkdownSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt new file mode 100644 index 00000000..c1b8d743 --- /dev/null +++ b/test/Html2Markdown.Test/MarkdownSchemeConverterTest.Convert_WhenThereIsAnEmptyList_ThenRemoveTheList.verified.txt @@ -0,0 +1 @@ +emptyString \ No newline at end of file diff --git a/test/Html2Markdown.Test/MarkdownSchemeConverterTest.cs b/test/Html2Markdown.Test/MarkdownSchemeConverterTest.cs index 680c8328..741cf656 100644 --- a/test/Html2Markdown.Test/MarkdownSchemeConverterTest.cs +++ b/test/Html2Markdown.Test/MarkdownSchemeConverterTest.cs @@ -660,6 +660,15 @@ public Task Convert_WhenThereAreMultipleUnorderedLists_ThenReplaceWithMarkdownLi return CheckConversion(html); } + + // See issue https://github.com/baynezy/Html2Markdown/issues/109 + [Test] + public Task Convert_WhenThereIsAnEmptyList_ThenRemoveTheList() + { + const string html = ""; + + return CheckConversion(html); + } #endregion