-
Notifications
You must be signed in to change notification settings - Fork 604
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
Fenced code block with list fails #239
Comments
I encountered this issue with Jenkins console output, which contains xtrace lines (i.e. shell commands are logged to stdout prefixed by Notably, the
|
Confirmed, this is a bug. |
I encountered this problem today due to a line in a code section that starts with ": ". Disclaimer: this morning I knew nothing about the go programming language.
It seems to happen during secondPass, when parsing out lists. I think due to the "list-like" start of the line, it considers the line starting with the offending symbol as another list item. What then happens is that data.len is set in such a way, that
in |
I faced this issue today. The issue occurs specifically when there is Markdown list syntax in a fenced code block within a Markdown list. The parser tries to interpret the hyphens in the code fence to list in HTML. Looking forward to the fix. |
1) If a code block is in a list, and 2) If a line in that code block begins with the regular dash (HYPHEN-MINUS) character or a PLUS SIGN (0x2b), replace that character with the HYPHEN character (which looks like HYPHEN-MINUS, but has a different binary code.. 0x2010 instead of 0x2d). That is enough to fool Blackfriday to get around this bug.
1) If a code block is in a list, and 2) If a line in that code block begins with the regular dash (HYPHEN-MINUS) character or a PLUS SIGN (0x2b), replace that character with the HYPHEN character (which looks like HYPHEN-MINUS, but has a different binary code.. 0x2010 instead of 0x2d). That is enough to fool Blackfriday to get around this bug.
This is very frustrating when trying to display YAML files in code blocks inside of numbered lists. Our use case is Lab steps which require sequential numbers, code blocks, and to display YAML files. Workaround I found in other bugs which reference this issue is to use 8 spaces instead of code fences. This issue was reported almost 2 years ago; Is there a plan to fix this? |
I hit this too, here's a minimal repro:
Both code fences are indented by 4 spaces. The first YAML block under "First item" renders just fine, however the one under "Second item" doesn't, and just prints the raw code fence syntax (picture below). I was able to determine that it's happening when the code block contains an array like above. |
There is an issue with ordered lists in the Creating HA clusters with kubeadm setup tutorial. All list items are labeled 1. This is because the underlying markdown processor for Hugo, blackfriday, requires list items with multiple paragraphs to have four space indentation. See (russross/blackfriday#244) This commit adds an extra space before paragraphs in lists so they are correctly interpreted as multi-paragraph lists. However, this exposes a bug in blackfriday where lines beginning with `-` in codefenced code blocks inside lists are parsed as sub-lists. This means code fenced code blocks inside lists that contain yaml are malformed. (See russross/blackfriday#239) So this commit mitigates this bug in two situations. It uses a 4-space indented code block in one situation. In another situation where a list only contained one element, it is no longer a list.
There is an issue with ordered lists in the Creating HA clusters with kubeadm setup tutorial. All list items are labeled 1. This is because the underlying markdown processor for Hugo, blackfriday, requires list items with multiple paragraphs to have four space indentation. See (russross/blackfriday#244) This commit adds an extra space before paragraphs in lists so they are correctly interpreted as multi-paragraph lists. However, this exposes a bug in blackfriday where lines beginning with `-` in codefenced code blocks inside lists are parsed as sub-lists. This means code fenced code blocks inside lists that contain yaml are malformed. (See russross/blackfriday#239) So this commit mitigates this bug in two situations. It uses a 4-space indented code block in one situation. In another situation where a list only contained one element, it is no longer a list.
@client9 thanks for the update. I'm happy to take a stab at it. |
There is an issue with ordered lists in the Creating HA clusters with kubeadm setup tutorial. All list items are labeled 1. This is because the underlying markdown processor for Hugo, blackfriday, requires list items with multiple paragraphs to have four space indentation. See (russross/blackfriday#244) This commit adds an extra space before paragraphs in lists so they are correctly interpreted as multi-paragraph lists. However, this exposes a bug in blackfriday where lines beginning with `-` in codefenced code blocks inside lists are parsed as sub-lists. This means code fenced code blocks inside lists that contain yaml are malformed. (See russross/blackfriday#239) So this commit mitigates this bug in two situations. It uses a 4-space indented code block in one situation. In another situation where a list only contained one element, it is no longer a list.
this should be fixed... can @ahmetb @tfogo @moorereason @bryfry @kaushalmodi confirm? regards, n |
@client9 Thanks for the work. I won't be able to test it though, till Hugo moves to Blackfriday v2. |
Oh good point this could be backported to v1 |
Yeah a backport to v1 would be great for Hugo. I'm happy to put together a PR for it today unless you would like to do it @client9 |
@tfogo made a start of it on https://github.com/client9/blackfriday I get some failures in the tests, but this might mean the test just need adjusting. V1 might work differently. existing test still pass -- only the new tests have some failures.
|
Hi @client9 - sorry for the late reply. I looked into this. Looks like I believe this input:
should produce this output: <ul>
<li><p>Foo</p>
<pre><code>Hello
</code></pre></li>
</ul> However it is producing this: <ul>
<li>Foo
<code>
Hello
</code></li>
</ul> It looks like this is because the I've opened a PR to your repo to set the As for the |
PR here: https://github.com/client9/blackfriday/pull/2 @client9 if it looks good to you, I think we should submit it to @rtfb for approval. There may be some edge case I'm not thinking of here where this isn't the solution we want. Also, we probably want to add this test case and fix to v2. This test fails on v2. But I'll wait to hear from you and @rtfb if you think this is the right fix. |
This should now be fixed in both v1 and v2. |
Just a quick check on what you meant by "should": are we good to close it, or should we still doublecheck whether it helped? |
I've confirmed that it's fixed in master and v2. 🎉 |
Awesome! Thanks for everyone involved! |
This fixes the same issue, but in this code base. Patching was done manual, but with minimal effort. Signed-off-by: Miek Gieben <miek@miek.nl> full details: ~~~ % wget https://patch-diff.githubusercontent.com/raw/russross/blackfriday/pull/372.patch ... Saving to: ‘372.patch’ ~~~ Edit `372.patch` to fix the path nams -> a/block.go -> a/parser/block.go etc. ~~~ % patch -p1 --dry-run < 372.patch checking file block_test.go Hunk #1 succeeded at 1513 with fuzz 2 (offset 55 lines). checking file parser/block.go Hunk #1 succeeded at 1571 (offset 325 lines). Hunk gomarkdown#2 succeeded at 1605 (offset 325 lines). checking file parser/block.go Hunk #1 FAILED at 1293. 1 out of 1 hunk FAILED checking file parser/block.go Hunk #1 FAILED at 1280. 1 out of 1 hunk FAILED checking file block_test.go Hunk #1 succeeded at 1513 with fuzz 2 (offset 44 lines). ~~~ looks promising. Let's do this for real and manual fix. ~~~ % patch -p1 --merge < 372.patch patching file block_test.go Hunk #1 merged at 1516-1526. patching file parser/block.go patching file parser/block.go patching file parser/block.go patching file block_test.go Hunk #1 merged at 1527-1553. ~~~
Given the following fenced code block,
blackfriday renders:
I expect it to render:
It appears to occur when the first line of the code block matches a list item pattern (ie.
-
,+
,*
, or1.
). If there's a blank line or any non-list item patterned content on the first line, the code fencing works properly.Here's a test case for
TestFenceCodeBlockWithinList
:I haven't been able to figure out where it's breaking down.
The text was updated successfully, but these errors were encountered: