简体   繁体   English

如何在代码/预块中添加 Markdown 格式?

[英]How do I add Markdown formatting in a code / pre block?

This may seem to defeat the purpose of a code block, but I'd like to be able to bold something within a code block.这似乎违背了代码块的目的,但我希望能够在代码块中加粗某些内容。 For example, if I wanted to bold the return line:例如,如果我想加粗返回行:

int main(void) {
    **return 0;**
}

You would have to do this in HTML, by design .根据设计,您必须在 HTML 中执行此操作。

However, inside Markdown code spans and blocks, angle brackets and ampersands are always encoded automatically.但是,在 Markdown 代码范围和块内,尖括号和符号始终自动编码。

<pre>
int main(void) {
    <b>return 0;</b>
}
</pre>

This syntax should solve your problem:此语法应该可以解决您的问题:

    ```
    int main(void) {
       **return 0;**
    }
    ```

Just type three backticks in the beginning of the code block and it's should work.只需在代码块的开头键入三个反引号,它就应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM