-
Notifications
You must be signed in to change notification settings - Fork 526
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
Unable to escape code fences #208
Comments
Use four leading spaces or leading tabs:
Achieved with:
|
Although I am very grateful for the workaround, there's still a bug here. |
I understand your point of view yet humbly disagree that this is a bug. I think there's an opportunity here to better document how the |
I just ran into this same bug... it would be much nicer if redcarpet let you wrap code blocks that contain sets of 3 backticks by using sets of 4 backticks (like marked supports), just like how you wrap inline code that contains a backtick with 2 backticks on each side, rather than just one. |
I’m currently working on documenting the LivingStyleGuide Gem where I have to write a lot of Markdown examples within Markdown which is almost impossibe. Problem: If you open a code block with ``` it will also be closed by ~~~ and vice versa. Solution: Only close code blocks with the same 3 characters they have been opened. @mattr- I agree that this might not be a bug. But I can’t think of any use case where opening and closing code blocks with different characters would make sense. Do you have any? Example: This should create one big code block:
<p>Look at this Markdown example:</p>
<pre><code class="markdown">Text
</code></pre>
<p>code
```</p>
<ul>
<li>List</li>
<li>List
~~~</li>
</ul>
<p>Great example, isn’t it?</p> Also @slang800’s idea with the amount of backticks is nice. But I guess checking the character (and using existing syntax) should work in all use cases. The idea of using the indented code blocks instead of backticks/tildes is:
|
Any comments on this? This fix would be a big enhancement for my daily work, especially the documentation of my open-source projects :) |
In my case, i am trying to write an example of how to use fenced code blocks.. so, my markdown looks something like this (which does not render correctly):
if i indent the nested code block, i get this.. it renders but it breaks my example (there is no need to indent a code block, as shown) /**
A simple example
@example
```js
var result = one();
```
*/
function one() {} |
👍 to @hagenburger's suggestion |
One cool trick: use Zero Width Space |
I'm using your solution @solidsnack, thanks! |
Yep, for documentation about documentation, readme generators and readme example testing modules, it will be helpful to be a bit more flexible. For example like @slang800 suggested, escaping with more backticks. Thanks. |
The easiest way I've found to get the Zero Width Space is from a web browser developer console
|
There's some Markdown weirdness around display nesting '```' code fences. The current README's example with a nested block doesn't terminate correctly for some reason and was including the next section's markdown escaped in it. Rather than wrapping with number-of-wrapped-backticks+1 this uses [this idea])vmg/redcarpet#208 (comment)) and prefixes the nested instances with zero-width spaces, thanks @solidsnack
@robin850 I believe I've resolved it, any chance to get it in 3.5.x? |
In case anyone is lazy like me, you can copy the zero width space from here https://unicode-table.com/en/200B/. Paste that infront of your code fence and you are good to go. |
I need to write an example of markdown with code fencing, so I assumed that adding a backslash before the 3 backticks would work, but it doesn't (compare output with RAW: https://gist.github.com/jordanryanmoore/5136446).
The text was updated successfully, but these errors were encountered: