markdownhexo

How do I escape three backticks surrounded by a codeblock in Markdown?


First, I'd like to say that I've read some recommended questions that may seem to answer my question, but they're all about escape single backtick in markdown. I've tried but none of them seem to work.

Here's what I've tried.

  1. Double backtick - single space - three backticks.

    To avoid any problems, I use image to discribe.

    and it seems to be good in my markdown editor except missing the breakline. But bad luck, it seems terrible on Hexo blog.

    Then I test in Github for luck. And, difference shows:

    Shown in github.

  2. Use backslash.

Unfortunately, it shows directly instead of escape the backtick.

Now, my question is, it works well here in Stack Overflow, but not in my blog. What else I should try except using html tag, or is it the only way I should go? Is it the issue with my usage or my blog theme?


Solution

  • In addition to nesting a fenced block inside an indented block (as demonstrated in another answer), you can also nest one fenced block inside another fenced block by using a different number of backticks (as you have tried). However, you must keep each set of deliminators on a separate line. And most implementations require three or more backticks (your use of 2 is another failure point). For example, notice that in the following example the outer block uses four backticks whereas the inner block uses three backticks:

    ````
    ```
    UIBarButtonItem *search = [[UIBarButtonItem alloc]
    ```
    ````
    

    In many implementations that will render as:

    ```
    UIBarButtonItem *search = [[UIBarButtonItem alloc]
    ```
    

    You may find this is not supported properly with some implementations however.

    As an alternative, if the implementation you are using also supports tildes (~) as fenced code block deliminators, you can use those instead:

    ~~~
    ```
    UIBarButtonItem *search = [[UIBarButtonItem alloc]
    ```
    ~~~
    

    Again, never use less that three deliminator characters in a group and always include each group on a separate line by itself.