russross / blackfriday

Blackfriday: a markdown processor for Go
Other
5.45k stars 601 forks source link

Triple-backtick code blocks aren't processed properly on Windows #422

Open Southclaws opened 6 years ago

Southclaws commented 6 years ago

I built a Markdown to oldschool BBCode tool a few weeks back, worked great on my macbook however trying to use it on Windows recently resulted in some strange output. Upon inspecting the HTML that blackfriday.Run output, it seems it's trying to escape double-backticks as quotes first.

Here's an example of the Markdown I'm trying to process:

For example, this:

```markdown
The Swiss Army Knife of SA:MP - vital tools for any server owner or library
maintainer.

## Overview

Server management and configuration tools:

* Manage your server settings in JSON format (compiles to server.cfg)
* Run the server from `sampctl` and let it worry about automatic restarts
* Automatically download Windows/Linux server binaries when you need them
```

becomes this:

```json
The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.

[COLOR="RoyalBlue"][size="6"][B]Overview[/B][/size][/COLOR]

Server management and configuration tools:

[LIST]

[*]Manage your server settings in JSON format (compiles to server.cfg)
[*]Run the server from [FONT="courier new"]sampctl[/FONT] and let it worry about automatic restarts
[*]Automatically download Windows/Linux server binaries when you need them

[/LIST]
```

And this is the output of blackfriday.Run:

For example, this:

“`markdown
The Swiss Army Knife of SA:MP - vital tools for any server owner or library
maintainer.

</p>

<h2>Overview
</h2>

<p>
Server management and configuration tools:

* Manage your server settings in JSON format (compiles to server.cfg)
* Run the server from <code>sampctl</code> and let it worry about automatic restarts
* Automatically download Windows/Linux server binaries when you need them
<code>

becomes this:

</code>json
The Swiss Army Knife of SA:MP - vital tools for any server owner or library maintainer.

[COLOR=&ldquo;RoyalBlue&rdquo;][size=&ldquo;6&rdquo;][B]Overview[/B][/size][/COLOR]

Server management and configuration tools:

[LIST]

[<em>]Manage your server settings in JSON format (compiles to server.cfg)
[</em>]Run the server from [FONT=&ldquo;courier new&rdquo;]sampctl[/FONT] and let it worry about automatic restarts
[*]Automatically download Windows/Linux server binaries when you need them

[/LIST]
&ldquo;`

Notice the &ldquo; - I can't think why this only occurs on Windows, I tried to dig into it a bit but I'm not really sure what part of this library could even be platform dependent.

This is the tool if anyone wants to check the code or try and reproduce the possible bug: https://github.com/Southclaws/forumfmt

misterpickypants commented 5 years ago

This is probably a CRLF vs LF bug.