blackfriday icon indicating copy to clipboard operation
blackfriday copied to clipboard

v2 is not wrapping code tags with pre tags so newlines are stripped from html

Open jasin opened this issue 5 years ago • 2 comments

I used v1 with great results, but v2 seems broken with even the simplest of markdown

## Testing
```sh
line one
line two

Produces this...

sh line one line two 

html output

<p>
<code>sh
line one
line two
</code></p>

here is the code I used in go blackfriday.Run([]byte(args), blackfriday.WithExtensions(blackfriday.CommonExtensions))

I would expect code similar to this

<pre><code>line one
line two</code></pre>

jasin avatar Jun 17 '19 15:06 jasin

Also, the sh should be translated into a class:

<code class="language-sh>...</code>

I have the same problem. Were you able to figure out what's wrong ?

alaingilbert avatar Jun 29 '19 23:06 alaingilbert

I found out the issue. https://github.com/russross/blackfriday/blob/3e56bb68c8876389c631e9e318ce3c092a0906db/block.go#L660

The code is looking for the character \n explicitly. In my case, the file "line separator" was set to Windows (\r\n) so it found \r instead, and was returning. So the solution was to set the "line separator" to Unix & macOS (\n) OR remove all the \r in your file (with code)

alaingilbert avatar Jun 30 '19 02:06 alaingilbert