mysticmind / reversemarkdown-net

ReverseMarkdown.Net is a Html to Markdown converter library in C#. Conversion is very reliable since HtmlAgilityPack (HAP) library is used for traversing the Html DOM
MIT License
270 stars 62 forks source link

Imported Markdown Spacing Issues #30

Closed RickStrahl closed 5 years ago

RickStrahl commented 5 years ago

Nice work on the update for ReverseMarkdown! This looks very nice and much more usable than the previous version. Congratulations... I'm checking out reverse Markdown and it does an excellent job overall with capturing the most common things and dealing with unhandled HTML well which is awesome.

However I am running into some issues with White Space generation in the generated Markdown output.

Inlines strip Whitespace and Run into previous text

I notice that inlines that are imported are not spacing out correctly:

image

Any blocks imported are imported with 3 empty lines instead of 1

Here's what imports from a Github Readme look like:

image

I suspect this has to do with the spacing inside of the block tags that is preserved, but probably should be trimmed and then separated with a single empty line.

I realize this latter issue is legal and of course renders fine, but it wastes a bunch of space and likely requires manual fixup of the Markdown text when editing later.

RickStrahl commented 5 years ago

Following up with some more information and some details of what I'm actually doing. I'm using this inside of a markdown editor (Markdown Monster) where there's an option to Paste Markdown from HTML. The user can have either HTML text on the clipboard, or text from captured browser view which is HTML text,

The problem apparently comes from the HTML text that is fixed up by Chrome (in this case) and includes a ton of extra formatting. I can duplicate the run on inlines with this code:

 [Fact]
        public void WhenThereAreBTag_ThenConvertToMarkdownDoubleAsterisks2()
        {
            const string html =
                @"<span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"">Markdown Monster is an easy to use and extensible<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Markdown Editor</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"">,<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Viewer</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>and<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Weblog Publisher</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>for Windows. </span>";

var config = new ReverseMarkdown.Config
{
GithubFlavored = true,
UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.PassThrough, // Include the unknown tag completely in the result (default as well)
SmartHrefHandling = true // remove markdown output for links where appropriate
};
var converter = new ReverseMarkdown.Converter(config);
string markdown = converter.Convert(html);

Console.WriteLine(markdown);
        }

This produces the following output I showed earlier:

Markdown Monster is an easy to use and extensible**Markdown Editor**,**Viewer**and**Weblog Publisher**for Windows. 

...

I realize this is some gnarly HTML, but this is what comes out of a raw HTML block copied directly out of Chrome and then captured from the Clipboard as HTML text.

Here's the other issue with the triple-breaks:

[Fact]
public void WhenThereAreBreaksTimes3()
{

    const string html = @"<h3>Header</h3>
<p>
Some text goes here.
</p>

<h3>Header 2</h3>
<p>
Some more text goes here.
</p>

<h3>Header 3</h3>
<p>
Some more text goes here.
</p>
";
    var config = new ReverseMarkdown.Config
    {
        GithubFlavored = true,
        UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.PassThrough, // Include the unknown tag completely in the result (default as well)
        SmartHrefHandling = true // remove markdown output for links where appropriate
    };
    var converter = new ReverseMarkdown.Converter(config);
    string markdown = converter.Convert(html);

    Console.WriteLine(markdown);
}

This produces a lot of extra white space and <br> tags:


### Header

<br>Some text goes here.<br>

### Header 2

<br>Some more text goes here.<br>

### Header 3

<br>Some more text goes here.<br>
mysticmind commented 5 years ago

@RickStrahl Hey Rick, I will take a look at this by tomorrow and keep you posted.

mysticmind commented 5 years ago

@RickStrahl I ran a test on the spacing issue and I get the output as Markdown Monster is easy to use and extensible **Markdown Editor**, **Viewer** and **Weblog Publisher** for Windows.. This is spaced properly contrary to your results. Please check and re-confirm on this.

mysticmind commented 5 years ago

@RickStrahl with regard to :

I will make available the changes in v3.1.0.

Also if you want to quick check, you can get the latest code and run a check on the above use cases.

mysticmind commented 5 years ago

I also managed to add functionality to trim encompassing new lines within any block tags

mysticmind commented 5 years ago

@RickStrahl I went ahead and released v3.1.0. It should be available for you to access once NuGet catches up on it.

mysticmind commented 5 years ago

@RickStrahl did you get a chance to run through my comments and use the latest version?

RickStrahl commented 5 years ago

I'll take a look later today. Thank you for following up on this so quickly.

RickStrahl commented 5 years ago

I tried adding 3.20 to Markdown Monster and ran inside of the app there. Just for clarification here's the exact code I'm running (with 3.20)

var config = new ReverseMarkdown.Config {
     GithubFlavored = true,
     UnknownTags = ReverseMarkdown.Config.UnknownTagsOption.PassThrough, // Include the unknown tag completely in the result (default as well)
     SmartHrefHandling = true // remove markdown output for links where appropriate
};
var converter = new ReverseMarkdown.Converter(config);
string markdown = converter.Convert(html);

//            if (!string.IsNullOrEmpty(markdown))
//                markdown = markdown.Replace("\n\n", "\r\n").Replace("\r\n\r\n", "\r\n");
return markdown ?? html;

Input string:

<span style="color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Markdown Monster is an easy to use and extensible<span> </span></span><strong style="box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">Markdown Editor</strong><span style="color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">,<span> </span></span><strong style="box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">Viewer</strong><span style="color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>and<span> </span></span><strong style="box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">Weblog Publisher</strong><span style="color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>for Windows. Our goal is to provide the best Markdown specific editor for Windows and make it as easy as possible to create Markdown documents. We provide a core editor and previewer, and a number of non-intrusive helpers to help embed content like images, links, tables, code and more into your documents with minimal effort.</span>

As mentioned this (ugly, ugly) HTML is a copy of some HTML text from Chrome, then imported from the clipboard as HTML. Chrome apparently is the full stylesheet to each element not inherited in the fragment.

Output Markdown:

Markdown Monster is an easy to use and extensible**Markdown Editor**,**Viewer**and**Weblog Publisher**for Windows. Our goal is to provide the best Markdown specific editor for Windows and make it as easy as possible to create Markdown documents. We provide a core editor and previewer, and a number of non-intrusive helpers to help embed content like images, links, tables, code and more into your documents with minimal effort.

If I had to guess I'd say it's because of the nested <span> elements which have </span> </span>more text at the end. Normal HTML probably would handle that as </span></span> More text which does render right.

I'll take another look at your test with the source code. Apparently the code I was testing and what you were must have been different because I saw the same behavior when I last checked running the tests I posted. I'll try again with the latest changes and see what we get.

RickStrahl commented 5 years ago

So took a look with your latest code from your tests and added the following test which fails for me:

  [Fact]
public void TestConversionWithPastedHtml()
{

    var html =  @"<span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"">Markdown Monster is an easy to use and extensible<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Markdown Editor</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"">,<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Viewer</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>and<span> </span></span><strong style=""box-sizing: border-box; font-weight: 600; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;"">Weblog Publisher</strong><span style=""color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;""><span> </span>for Windows. Our goal is to provide the best Markdown specific editor for Windows and make it as easy as possible to create Markdown documents. We provide a core editor and previewer, and a number of non-intrusive helpers to help embed content like images, links, tables, code and more into your documents with minimal effort.</span>";

    var config = new ReverseMarkdown.Config
    {
        GithubFlavored = true,
        UnknownTags =
            ReverseMarkdown.Config.UnknownTagsOption
                .PassThrough, // Include the unknown tag completely in the result (default as well)
        SmartHrefHandling = true // remove markdown output for links where appropriate
    };
    var converter = new ReverseMarkdown.Converter(config);
    string markdown = converter.Convert(html);

    Console.WriteLine(markdown);

    Assert.Contains("and **Weblog Publisher** for Windows", markdown);

}

I think it's important that the HTML string is not re-formatted when you paste - I had that happen to me earlier where your code worked for me and the same code in the app did not. Only when I explicitly repasted the text did it work. Should work with the code snippet above though as the string formatting is already in place I hope.

mysticmind commented 5 years ago

@RickStrahl I included your unit test above with name TestConversionWithPastedHtmlContainingNestedSpans and committed the changes. If you inspect the recent CI builds, they are all green.

I have logged the converted output, see screenshot below from Appveyor CI log image

You can check and inspect the log entry for ReverseMarkdown.Test.ConverterTests.TestConversionWithPastedHtmlContainingNestedSpans https://ci.appveyor.com/project/BabuAnnamalai/reversemarkdown-net/builds/23413642/tests

In summary, everything is working as expected. It is a bit puzzling why you are getting a different result.

RickStrahl commented 5 years ago

Can't be the MM logic because it's the test that is failing for me inside of this project. When I added the PR the CI build was failing also - the log showed the test as failed, so something has changed when you moved the test perhaps? I think you have to be careful when the text gets copied because something might be reformatting it, which changes the behavior.

If you can take a look at the original PR without making any changes and run that test since that's what's failing on my end.

mysticmind commented 5 years ago

My bad didn't notice the PR which you submitted. I will take a look at the PR.

RickStrahl commented 5 years ago

No worries - I know this is kind of an edge case and plenty weird :-) Appreciate you taking a look at this.

That said, weird as it its, this is definitely a use case I need to get working as in MM that will be the primary input of HTML coming in for conversion.

BTW, let me know if you'd like to get a license for MM and I'll forward to you.

mysticmind commented 5 years ago

@RickStrahl mystery resolved. The space chars were Unicode space chars in the source HTML which looks to be removed when it gets loaded in HtmlAgilityPack. I have added implementation to normalize Unicode space and non-breaking space chars to normal space chars. Your test works fine now.

I went ahead and released v3.3.0 with the fix, please check and confirm on the same.

Thanks for offering a license to Markdown Monster, happy to use the same :-)

RickStrahl commented 5 years ago

Looks like that did the trick!

Both the inline spaces and the paragraph spacing now work just fine.

Found another issue with inline code, but I'll open another issue for that. Thanks so much.

For the license for MM either contact me on Twitter (\@RickStrahl) or fill out the form here Get a license for Contribution.

Thanks.