Skip to content

Commit

Permalink
Update AppVeyor to test with Linux
Browse files Browse the repository at this point in the history
Fix Linux issues and add Linux testing support

Closes #222
  • Loading branch information
baynezy committed Sep 21, 2022
1 parent 900930f commit 5cb3300
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
20 changes: 13 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
version: 5.0.2.{build}
skip_tags: true
configuration: Release
image: Visual Studio 2022
image:
- Visual Studio 2022
- Ubuntu
init:
- git config --global core.autocrlf true
install:
Expand All @@ -10,7 +12,8 @@ build:
publish_nuget: true
verbosity: minimal
environment:
Test.Path: C:\projects\html2markdown\test\Html2Markdown.Test\Files\
TestPathWindows: C:\projects\html2markdown\test\Html2Markdown.Test\Files\
TestPathLinux: /home/appveyor/projects/html2markdown/test/Html2Markdown.Test/Files/
GithubEmail: baynezy@gmail.com
GithubUsername: baynezy
GithubPersonalAccessToken:
Expand All @@ -22,18 +25,21 @@ deploy:
on:
branch: master
build_script:
- cmd: >-
cd %BUILD_DIR%
- ps: >-
markdownlint .
dotnet restore
dotnet build
dotnet pack .\src\Html2Markdown\Html2Markdown.csproj -c %CONFIGURATION% /p:PackageVersion=%APPVEYOR_BUILD_VERSION%
dotnet pack .\src\Html2Markdown\Html2Markdown.csproj -c $env:CONFIGURATION /p:PackageVersion=$env:APPVEYOR_BUILD_VERSION
test_script:
- cmd: >-
- ps: >-
if ($isLinux) {
$env:TestPath = $env:TestPathLinux
} else {
$env:TestPath = $env:TestPathWindows
}
dotnet test .\test\Html2Markdown.Test\Html2Markdown.Test.csproj --logger "trx;LogFileName=results.trx"
on_finish:
- ps: ./uploadTestResults.ps1
Expand Down
13 changes: 7 additions & 6 deletions src/Html2Markdown/Converter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -65,12 +66,12 @@ public string Convert(string html)

private static string CleanWhiteSpace(string markdown)
{
var cleaned = Regex.Replace(markdown, @"\r\n\s+\r\n", "\r\n\r\n");
cleaned = Regex.Replace(cleaned, @"(\r\n){3,}", "\r\n\r\n");
cleaned = Regex.Replace(cleaned, @"(> \r\n){2,}", "> \r\n");
cleaned = Regex.Replace(cleaned, @"^(\r\n)+", "");
cleaned = Regex.Replace(cleaned, @"(\r\n)+$", "");
return cleaned;
var cleaned = Regex.Replace(markdown, @"\r?\n\s+\r?\n", Environment.NewLine + Environment.NewLine);
cleaned = Regex.Replace(cleaned, @"(\r?\n){3,}", Environment.NewLine + Environment.NewLine);
cleaned = Regex.Replace(cleaned, @"(> \r?\n){2,}", "> " + Environment.NewLine + Environment.NewLine);
cleaned = Regex.Replace(cleaned, @"^(\r?\n)+", "");
cleaned = Regex.Replace(cleaned, @"(\r?\n)+$", "");
return cleaned.Trim();
}
}
}
6 changes: 3 additions & 3 deletions src/Html2Markdown/Replacement/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public static string ReplaceCode(string html)
else
{
markdown = ReplaceBreakTagsWithNewLines(code);
markdown = Regex.Replace(markdown, "^\r\n", "");
markdown = Regex.Replace(markdown, "\r\n$", "");
markdown = Regex.Replace(markdown, "^\r?\n", "");
markdown = Regex.Replace(markdown, "\r?\n$", "");
markdown = "```" + Environment.NewLine + markdown + Environment.NewLine + "```";
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public static string ReplaceBlockquote(string html)
markdown += $"> {line.TrimEnd()}{Environment.NewLine}";
});
markdown = Regex.Replace(markdown, @"(>\s\r\n)+$", "");
markdown = Regex.Replace(markdown, @"(>\s\r?\n)+$", "");
markdown = Environment.NewLine + Environment.NewLine + markdown + Environment.NewLine + Environment.NewLine;
Expand Down
2 changes: 1 addition & 1 deletion test/Html2Markdown.Test/ConvertFromFileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Task ConvertFile_WhenReadingInHtmlFile_ThenConvertToMarkdown()
private static string TestPath()
{
const string route = @"..\..\..\Files\";
var environmentPath = System.Environment.GetEnvironmentVariable("Test.Path");
var environmentPath = System.Environment.GetEnvironmentVariable("TestPath");

return environmentPath ?? route;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
 text text text
text text text

0 comments on commit 5cb3300

Please sign in to comment.