Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables not rendering after upgrade to 2.0.0 #394

Open
onlyafly opened this issue Sep 23, 2017 · 12 comments
Open

Tables not rendering after upgrade to 2.0.0 #394

onlyafly opened this issue Sep 23, 2017 · 12 comments
Labels

Comments

@onlyafly
Copy link

I upgraded my project from blackfriday 1.5.0 to 2.0.0, but when I run it on the following markdown, the table fails to render now:

| Column A | Column B |
| --------- | --------- |
| A1 | B1 |
| A2 | B2 |

This is how I am calling blackfriday in 2.0.0:

content := blackfriday.Run(
    []byte(input),
    blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.HardLineBreak|blackfriday.AutoHeadingIDs|blackfriday.Autolink),
)

Am I using the wrong options?

@rtfb
Copy link
Collaborator

rtfb commented Sep 25, 2017

No, you're using the right options (nit: you can omit Autolink since it's already in CommonExtensions), and looking at what you show here, this seems to be a bug, this needs to be looked at.

@rtfb
Copy link
Collaborator

rtfb commented Oct 7, 2017

Strange, I can't reproduce (ignore the funky import, it's my local clone of v2):

$ cat v2.go 
package main

import (
	"fmt"

	blackfriday "github.com/russross/blackfriday.v2"
)

const input = `
| Column A | Column B |
| --------- | --------- |
| A1 | B1 |
| A2 | B2 |
`

func main() {
	out := blackfriday.Run(
		[]byte(input),
		blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.HardLineBreak|blackfriday.AutoHeadingIDs|blackfriday.Autolink),
	)
	fmt.Println(string(out))
}
$ go run v2.go 
<table>
<thead>
<tr>
<th>Column A</th>
<th>Column B</th>
</tr>
</thead>

<tbody>
<tr>
<td>A1</td>
<td>B1</td>
</tr>

<tr>
<td>A2</td>
<td>B2</td>
</tr>
</tbody>
</table>

@Zeno-Code
Copy link

Zeno-Code commented Nov 2, 2017

It's \r\n and \n
blackfriday can't render \r\n

@gonboy
Copy link

gonboy commented Nov 11, 2017

It is highly recommended to fix it

@kirides
Copy link

kirides commented Mar 20, 2018

My workaround for this is to data = bytes.Replace(data, []byte("\r"), nil, -1).
Which removes all occurences of \r.

@rtfb
Copy link
Collaborator

rtfb commented Mar 20, 2018

I have a PR for this, #428, but it's insufficient. It doesn't break any existing tests, and addresses some of the cases with Windows-style newlines, but not all. When I try to exercise it well by replacing all newlines in all test cases before running them, I still get a ton of failures, so a complete fix is not ready yet.

Meanwhile, @kirides's workaround seems like a quick solution for those of you who need to live with this.

@exyzzy
Copy link

exyzzy commented Aug 13, 2018

This bug also hit me. @kirides workaround fixed it. You should really make a proper fix. On mac localhost.

@rtfb
Copy link
Collaborator

rtfb commented Aug 13, 2018

Yesterday I updated the #428 PR with what I hope to be a complete fix: it passes all the reference tests with EOLs replaced. Please give it a spin with your input.

@picoeric
Copy link

428PR still does not work for my input. Here is the input hex: 4e616d65202020207c204167650d0a2d2d2d2d2d2d2d2d7c2d2d2d2d2d2d0d0a426f6220202020207c2032370d0a416c6963652020207c203233

@exyzzy
Copy link

exyzzy commented Aug 14, 2018

Sorry last comment from work (picoeric) BTW, I am calling it thus:
post.Rendered = template.HTML(blackfriday.Run([]byte(post.Body), blackfriday.WithExtensions(blackfriday.HardLineBreak|blackfriday.CommonExtensions)))

post.Body is of type string, and contains the hex (as string) of last comment

@rtfb
Copy link
Collaborator

rtfb commented Aug 18, 2018

I have a fix for tables (including this particular test case), but in doing so I enabled double-testing for all the remaining tests with Windows-style newlines and that uncovered a bunch of failures that I haven't encountered yet. It will take some more time to squish them all. PR #428 is going to be large...

BTW, @exyzzy, a lovely solution to use hex.Encode to transfer a byte-exact test case! ;-)

@exyzzy
Copy link

exyzzy commented Aug 24, 2018

Thanks @rtfb, I'll pick this up when it hits master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants