Skip to content

Commit

Permalink
Merge pull request #399 from baynezy/release/6.2.1.4
Browse files Browse the repository at this point in the history
Release version 6.2.1.4
  • Loading branch information
baynezy authored May 7, 2024
2 parents 94ee56c + 83ea093 commit 72a9b12
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 46 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/branch-hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@ jobs:
run: |
echo "patch_version=$(($(cat semver.json | jq -r '.patch')+1))" > $GITHUB_OUTPUT
- name: Store New Version
uses: RadovanPelka/github-action-json@v1.0.1
uses: Afterlife-Guide/SemVer.Action@1.0.3.8
with:
path: semver.json
replaceWith: |
{
"major": "${{ needs.get-version.outputs.major }}",
"minor": "${{ needs.get-version.outputs.minor }}",
"patch": "${{ steps.increment_version.outputs.patch_version }}",
"build": "${{ github.run_number }}"
}
major-version: ${{ needs.get-version.outputs.major }}
minor-version: ${{ needs.get-version.outputs.minor }}
patch-version: ${{ steps.increment_version.outputs.patch_version }}
build-version: ${{ github.run_number }}
- name: Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
uses: thomaseizinger/keep-a-changelog-new-release@3.0.0
with:
tag: ${{ needs.get-version.outputs.major }}.${{ needs.get-version.outputs.minor }}.${{ steps.increment_version.outputs.patch_version }}.${{ github.run_number }}
- name: Commit Changes
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,16 @@ jobs:
run: git checkout -b release/${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}

- name: Update Version Number
uses: RadovanPelka/github-action-json@v1.0.1
uses: Afterlife-Guide/SemVer.Action@1.0.3.8
with:
path: semver.json
replaceWith: |
{
"major": "${{ github.event.inputs.major_version }}",
"minor": "${{ github.event.inputs.minor_version }}",
"patch": "${{ github.event.inputs.patch_version }}",
"build": "${{ github.run_number }}"
}
major-version: ${{ github.event.inputs.major_version }}
minor-version: ${{ github.event.inputs.minor_version }}
patch-version: ${{ github.event.inputs.patch_version }}
build-version: ${{ github.run_number }}

- name: Update changelog
uses: thomaseizinger/keep-a-changelog-new-release@1.3.0
uses: thomaseizinger/keep-a-changelog-new-release@3.0.0
with:
tag: ${{ github.event.inputs.major_version }}.${{ github.event.inputs.minor_version }}.${{ github.event.inputs.patch_version }}.${{ github.run_number }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/step-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ jobs:
with:
dotnet-version: 8.0.x
- name: Restore
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
with:
target: Restore
- name: Build
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
with:
target: Build
arguments: |
versionNumber: ${{inputs.version}}
- name: Run tests
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
env:
TestPath: /home/runner/work/Html2Markdown/Html2Markdown/test/Html2Markdown.Test/Files/
with:
Expand All @@ -47,7 +47,7 @@ jobs:
with:
files: "**/TestResults/*.xml"
- name: Build NuGet Package
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
with:
target: Pack
arguments: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/step-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v4
- name: Get Version
id: get-version
uses: RadovanPelka/github-action-json@v1.0.1
uses: Afterlife-Guide/SemVer.Action@1.0.3.8
with:
path: 'semver.json'
- id: set-version
Expand Down
4 changes: 3 additions & 1 deletion .idea/.idea.Html2Markdown/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.Html2Markdown/.idea/sonarlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/.idea.Html2Markdown/.idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [6.2.1.4] - 2024-05-07

## [6.2.0.3] - 2023-12-21

## [6.1.0.2] - 2023-12-11

## [6.0.0.1] - 2023-12-07

[Unreleased]: https://github.com/baynezy/Html2Markdown/compare/6.2.0.3...HEAD

[unreleased]: https://github.com/baynezy/Html2Markdown/compare/6.2.1.4...HEAD
[6.2.1.4]: https://github.com/baynezy/Html2Markdown/compare/6.2.0.3...6.2.1.4
[6.2.0.3]: https://github.com/baynezy/Html2Markdown/compare/6.1.0.2...6.2.0.3

[6.1.0.2]: https://github.com/baynezy/Html2Markdown/compare/6.0.0.1...6.1.0.2

[6.0.0.1]: https://github.com/baynezy/Html2Markdown/compare/6dab0aa86b4b6e4f30b64de9990165672639bc61...6.0.0.1
7 changes: 1 addition & 6 deletions semver.json
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"major": "6",
"minor": "2",
"patch": "0",
"build": "3"
}
{"major":"6","minor":"2","patch":"1","build":"4"}
2 changes: 1 addition & 1 deletion src/Html2Markdown/Html2Markdown.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.55" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
</ItemGroup>

</Project>
24 changes: 18 additions & 6 deletions src/Html2Markdown/Replacement/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,25 @@ namespace Html2Markdown.Replacement;

internal static partial class HtmlParser
{
private static readonly Regex NoChildren = HtmlListHasNoChildren();

internal static string ReplaceLists(string html)
{
var finalHtml = html;
var lastRun = string.Empty;
while (HasNoChildLists(finalHtml))
{
var listToReplace = NoChildren.Match(finalHtml).Value;
var listToReplace = HtmlListHasNoChildren().Match(finalHtml).Value;
var formattedList = ReplaceList(listToReplace);

// an empty signifies that the HTML is malformed in some way.
// so we should leave the final HTML as is
if (string.IsNullOrEmpty(formattedList)) {
finalHtml = finalHtml.Replace(listToReplace, lastRun);
break;
}

lastRun = formattedList;

finalHtml = finalHtml.Replace(listToReplace, formattedList);
}

Expand Down Expand Up @@ -75,7 +85,7 @@ private static bool ListOnlyHasEmptyStringsForChildren(IEnumerable<string> listI

private static bool HasNoChildLists(string html)
{
return NoChildren.Match(html).Success;
return HtmlListHasNoChildren().Match(html).Success;
}

internal static string ReplacePre(string html)
Expand Down Expand Up @@ -221,9 +231,11 @@ private static string GetSyntaxHighlightLanguage(HtmlNode node)
return string.Empty;
}

return classAttributeValue.StartsWith("lang")
? classAttributeValue.Split('-').Last()
: classAttributeValue;
if (!classAttributeValue.StartsWith("lang")) return classAttributeValue;
var split = classAttributeValue.Split('-');

return split[^1]; // PERFORMANCE: https://sonarcloud.io/organizations/baynezy/rules?open=csharpsquid%3AS6608&rule_key=csharpsquid%3AS6608

}

internal static string ReplaceBlockquote(string html)
Expand Down
3 changes: 2 additions & 1 deletion src/Html2Markdown/Replacement/PatternReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class PatternReplacer : IReplacer
public string Replacement { get; init; }
public string Replace(string html)
{
var regex = new Regex(Pattern);
// SECURITY: https://sonarcloud.io/organizations/baynezy/rules?open=csharpsquid%3AS6444&rule_key=csharpsquid%3AS6444
var regex = new Regex(Pattern, RegexOptions.None, TimeSpan.FromSeconds(1));

return regex.Replace(html, Replacement);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* first list val
8 changes: 4 additions & 4 deletions test/Html2Markdown.Test/Html2Markdown.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JunitXml.TestLogger" Version="3.0.134" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="JunitXml.TestLogger" Version="3.1.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Verify.NUnit" Version="22.8.0" />
<PackageReference Include="Verify.NUnit" Version="23.2.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* first list val
9 changes: 9 additions & 0 deletions test/Html2Markdown.Test/MarkdownSchemeConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,15 @@ public Task Convert_WhenThereIsAMultilineOrderedListWithNestedParagraphsAndCodeE

return CheckConversion(html);
}

// See issue https://github.com/baynezy/Html2Markdown/issues/395
[Test]
public Task Convert_WhenThereAreMultipleUnorderedLists_ThenReplaceWithMarkdownLists()
{
const string html = "<ul><ul><li>first list val</li></ul></ul>";

return CheckConversion(html);
}

#endregion

Expand Down

0 comments on commit 72a9b12

Please sign in to comment.