I posted this answer using text from this python docs page.
I tried using block quotes for the text, but if I indent the code, it breaks the block quote, and if I don't indent it, it doesn't display as code.
I posted this answer using text from this python docs page.
I tried using block quotes for the text, but if I indent the code, it breaks the block quote, and if I don't indent it, it doesn't display as code.
The blockquote Markdown syntax allows for an optional space after >
, so in order to have code formatted inside a blockquote, you will need a >
followed by five spaces instead of the usual four, to give the code formatting the four spaces it needs and let the blockquote formatting eat up its optional space.
To illustrate:
> Some code:
>
> // code goes here
renders as
Some code:
// code goes here
Apparently this also works:
> Some code:
>
> ```lang-js
> const a = 0
> ```
Demo:
Some code:
const a = 0
Useful because the accepted answer doesn't work on Github or on my Jekyll blog.
You can also add syntax highlighting when you use blockquotes:
Code:
> Some code:
>
> <!-- language: lang-js -->
>
> const a = 0
Demo:
Some code:
const a = 0