Skip to content

Commit

Permalink
Optimize ParagraphRenderer's linebreak handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcpride committed May 3, 2023
1 parent c20ea96 commit 033e023
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,4 @@ paket-files/
/pkgs/_tmp

/coverage
/test-results
36 changes: 12 additions & 24 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
#tool nuget:?package=ReportGenerator&version=4.8.13
#addin nuget:?package=Cake.Coverlet&version=3.0.2
#addin nuget:?package=Cake.Incubator&version=8.0.0

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Debug");
var solution = "./src/mcpride-markdig-extensions.sln";

bool IsTestProject(SolutionProject project)
{
return (project.Path.HasExtension && project.Name.ToString().EndsWith("Tests"));
}

Task("Clean")
.Does(() =>
{
Information(string.Format("Cleaning files for configuration {0}...", configuration));
CleanDirectories(string.Format("./src/**/obj/{0}", configuration));
CleanDirectories(string.Format("./src/**/bin/{0}", configuration));
Information("Cleaning files...");
CleanDirectories("./src/**/obj");
CleanDirectories("./src/**/bin");
CleanDirectories("./test-results");
CleanDirectories("./coverage");
});

Task("Restore")
Expand Down Expand Up @@ -47,7 +42,7 @@ Task("Test")
var projectFiles = GetFiles("./src/**/*.Tests.csproj");
foreach(var file in projectFiles) {
var testResultsDirectory = MakeAbsolute(Directory($"./coverage/{file.GetFilenameWithoutExtension()}"));
var testResultsDirectory = MakeAbsolute(Directory($"./test-results/{file.GetFilenameWithoutExtension()}"));
EnsureDirectoryExists(testResultsDirectory);
CleanDirectory(testResultsDirectory);
Expand All @@ -60,8 +55,7 @@ Task("Test")
Verbosity = DotNetVerbosity.Normal,
Loggers = new []
{
"console;verbosity=normal",
$"trx;LogFileName={testResultsDirectory}/results.trx"
"console;verbosity=normal"
},
ResultsDirectory = testResultsDirectory,
Collectors = new []
Expand All @@ -70,15 +64,7 @@ Task("Test")
}
};
var coverletSettings = new CoverletSettings
{
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.cobertura,
CoverletOutputDirectory = testResultsDirectory,
CoverletOutputName = $"coverage"
};
DotNetTest(file, testSettings, coverletSettings);
DotNetTest(file.FullPath, testSettings);
}
});
Expand All @@ -93,10 +79,12 @@ Task("Coverage")
{
ReportTypes = new []
{
ReportGeneratorReportType.Html
ReportGeneratorReportType.Html, ReportGeneratorReportType.TextSummary
}
};
ReportGenerator(new GlobPattern("./coverage/**/coverage.cobertura.xml"), coverageDirectory, reportSettings);
ReportGenerator(new GlobPattern("./test-results/**/coverage.cobertura.xml"), coverageDirectory, reportSettings);
var summary = System.IO.File.ReadAllText("./coverage/Summary.txt");
Information(summary);
});


Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
http://a
http://a
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ g = Greeter.new("world")
g.salute
----

The end!
The end!
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<HtmlInlineEntity>
<HtmlInlineEntity>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Before thematic break

'''

After thematic break
After thematic break
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ this breaks +
this also breaks +
{empty} +
and this +
too
too
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ image::http://git-scm.com/figures/18333fig0319-tn.png["Branching Concepts", titl

This is link:http://example.com/["an example", title="Title"] inline link.

link:http://example.net/[This link] has no title attribute.
link:http://example.net/[This link] has no title attribute.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ _Italic Text_ is done using `+*Italic Text*+` +
~+Subscript Text+~ is done using `+<sub>Subscript Text</sub>+` +
^+Superscript Text+^ is done using `+^Superscript Text^+` +
^+Superscript Text+^ is done using `+<sup>Superscript Text</sup>+` +
[.underline]#Inserted Text# is done using `pass:[++Inserted Text++]`
[.underline]#Inserted Text# is done using `pass:[++Inserted Text++]` +
[.underline]#Underline Text# is done using `+<u>Underline Text</u>+`
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ __*Bold Italic Text*__ is done using `__*Bold Italic Text*__`
<sub>Subscript Text</sub> is done using `<sub>Subscript Text</sub>`
^Superscript Text^ is done using `^Superscript Text^`
<sup>Superscript Text</sup> is done using `<sup>Superscript Text</sup>`
++Inserted Text++ is done using `++Inserted Text++`
++Inserted Text++ is done using `++Inserted Text++`
<u>Underline Text</u> is done using `<u>Underline Text</u>`
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ protected override void Write(AsciiDocRenderer renderer, ParagraphBlock obj)
}

renderer.WriteLeafInline(obj);
renderer.EnsureLine();

if (!(renderer.IsLastInContainer && obj.Parent is MarkdownDocument))
{
renderer.EnsureLine();
}
}
}
}

0 comments on commit 033e023

Please sign in to comment.