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

Code blocks not rendered correctly #279

Closed
bkcsoft opened this issue Jul 11, 2016 · 5 comments
Closed

Code blocks not rendered correctly #279

bkcsoft opened this issue Jul 11, 2016 · 5 comments
Assignees

Comments

@bkcsoft
Copy link

bkcsoft commented Jul 11, 2016

cross-issue from gogs/gogs#3171

Using the characters []: breaks a code block and renders the entire line and sometimes the next line blank.

Test-case: https://gist.github.com/bkcsoft/dce1a2e16db28b46e1ce4c8df18caaba

@dmitshur
Copy link
Collaborator

I can reproduce, this is a valid issue in blackfriday, thanks for reporting.

@dmitshur dmitshur self-assigned this Jul 15, 2016
@dmitshur
Copy link
Collaborator

dmitshur commented Jul 15, 2016

Found where the bug is. It's inside firstPass. It erroneously tries to extract "extract references" inside fenced code blocks. We need to suppress that, just like we suppress tab expansion inside fenced code blocks.

This should be (relatively) easy to fix now.

@dmitshur
Copy link
Collaborator

It turned out to be more challenging because I discovered incidental issues that needed to be resolved first, and fixing this issue naively can cause a regression for performance (see 148) but there are no benchmarks to test for that.

I'll have a PR soon that fixes this, along with some other changes.

dmitshur added a commit that referenced this issue Jul 15, 2016
In first pass, there may not be a trailing newline after a fenced code
block yet. Make newline optional in isFenceLine when calling
fencedCodeBlock to detect the fenced code block it anyway. This is more
complex, but it avoids creating temporary buffers or modifying input in
order to maintain performance (see #148).

Document and rename fencedCode to fencedCodeBlock.

Add regression tests.

Fixes #279.
@rtfb rtfb closed this as completed in a5812bb Jul 15, 2016
dmitshur added a commit that referenced this issue Jul 15, 2016
@rain-1
Copy link

rain-1 commented Jul 17, 2016

Thanks for fixing this! I had the same problem.

If you don't mind me asking how do you use this "v2" branch? Do you add /v2 somewhere in the import line of the .go file?

@dmitshur
Copy link
Collaborator

dmitshur commented Jul 17, 2016

@rain-1 No problem.

To use v2, use the import path "gopkg.in/russross/blackfriday.v2". See its documentation at https://godoc.org/gopkg.in/russross/blackfriday.v2. The API is mostly the same/backwards compatible. Learn more about it in #218.

Ambrevar pushed a commit to Ambrevar/blackfriday that referenced this issue Aug 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants