简体   繁体   中英

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 .

However, inside Markdown code spans and blocks, angle brackets and ampersands are always encoded automatically.

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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