3

This question already has an answer here:

I have a question about some Markdown code not displaying as expected that I would like to ask on Stack Overflow. If I add the code (which includes triple-back-ticks), it is obviously rendered as an HTML code block in the displayed question. I tried to escape the back-ticks with "\" so that they would display, which works, but I get an error message, "Your post appears to contain code that is not properly formatted as code. Please indent all code by four spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.".

The error message prevents me from posting the question. How can I include Markdown code in a question?

marked as duplicate by Rob, Pierre.Vriens, Robert Longson, Pika the Wizard of the Whales, Nathan Tuggy Mar 22 at 17:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Can you provide more details on what exactly you’ve tried to do? Have you read How do I format my code blocks?? – Sebastian Simon Mar 22 at 15:49
  • Have you considered using an online Markdown editor that would host your code? – avazula Mar 22 at 15:50
  • 2
    @avazula Using only CodePen would cause a different error and would otherwise quickly be closed as off-topic due to lack of a Minimal, Complete, and Verifiable example. – Sebastian Simon Mar 22 at 15:52
  • 1
    you could also start your markdown with a code fence by starting with three ``` on a line by itself and at the end of the markdown block three ``` on a line by itself. – rene Mar 22 at 15:56
  • 1
    @rene it sounds like the code they're trying to post includes triple back-ticks, which is the problem: "If I add the code (which includes triple-back-ticks), it is obviously rendered as an html code block" – scohe001 Mar 22 at 16:06
  • Welcome to Meta! This question will probably be closed as a duplicate soon. If the answers from the duplicates don't fully address your question please edit it to include why and flag this for re-opening. Thanks! – smileycreations15 Mar 22 at 16:19
  • 4
    Possible duplicate of How do I escape a backtick ` within in-line code in Markdown? --- This is also useful info: meta.stackexchange.com/questions/125148/… – Rob Mar 22 at 16:34
0

If your code contains triple backticks, you have a few options:

  • Use more than 3 backticks on your main code block.
  • Use 3 or more tildes (~) on your main code block
  • Indent all the code lines by 4 spaces.

Examples (view source to see how I did them):

This codeblock was made with 5 backticks instead of 3
```
and it works
```
This codeblock was made with 3 tildes
```
and it works
```
This codeblock is indented by 4 spaces
```
and it works
```
  • Perfect. Thank you! I put a 4 back-tick block around the 3 back-tick block which then displays the 3 back-ticks around the code. – Good Morning Data Mar 22 at 16:23

Not the answer you're looking for? Browse other questions tagged .