Reputation:
Use case: Describing a programming language that uses backticks for comments. What should I write?
Comments are entered with a
whattoputhere
character.
So I need an inline code block that only contains a backtick. How to enter this?
I read this question and its answers: How does one escape backticks in markdown?
But it doesn't seem to solve the problem. Apparently, to be able to put a single backtick in an inline code block I need to enclose it with doublebackticks, rather than single backticks, producing something like this:
``I can use a backtick ` here ``
I can use a backtick ` here
But in my use case this degeneraters to this:
`````
Which renders like this: `````
Is there any way to enter an inline code block that only contains a single backtick character in Markdown?
Upvotes: 53
Views: 20196
Reputation: 16594
No one answer worked for me using github wiki.
The pre tag worked for me.
https://github.com/jrichardsz-software-architect-tools/t-rext/wiki/Complex-features
Upvotes: 0
Reputation: 53255
Reference: just looking at the accepted answer (over the course of a year or so :)) helped me figure the below pattern out:
Use a double backtick (``) at the start and end of a code block to allow a single backtick within it:
`` ` ``
produces: `
Use a triple backtick (```) at the start and end of a code block to allow a double backtick within it:
``` `` ```
produces: ``
Use a quadruple backtick (````) at the start and end of a code block to allow a triple backtick within it:
```` ``` ````
produces: ```
Use a quintuple backtick (`````) at the start and end of a code block to allow a quadruple backtick within it:
````` ```` `````
produces: ````
Etc.
A normal multi-line code block begins with a code fence which uses 3 backticks:
``` <-- starting code fence
code goes here
``` <-- ending code fence
So this C code block:
```c
void main(int argc, char* argv[])
{
// your code goes here
return 0;
}
```
produces this:
void main(int argc, char* argv[])
{
// your code goes here
return 0;
}
But, it turns out you can have code fences within your code blocks so long as your outer code blocks use code fences with more backticks, same as we saw previously in the single-line code block examples above.
So this:
````
```c
// some comment
```
````
produces this:
```c
// some comment
```
And this:
`````c
````
```
// some comment
```
````
`````
produces this:
````
```
// some comment
```
````
To insert backticks into markdown not formatted as code blocks, just use a backslash in front of the backticks.
Ex:
\`\`\`
produces this: ```\`\`\`
is like this: `` \`\`\` ``
. (Now guess how I even typed up that into this markdown answer!--3 backticks added to the beginning and end of that, of course! 😀)To add clarity to the accepted answer, here is an example:
To produce this, which has a single backtick near the end, but in code format:
syntax error near unexpected token `|'
Do this. Notice the double-backtick (``) at the beginning and end, in order to allow a single backtick (`) anywhere in between the two:
``syntax error near unexpected token `|'``
...which produces this: syntax error near unexpected token `|'
, which is what I want!
This is from my question here where I was trying to quote a bash error: Bash: how to print and run a cmd array which has the pipe operator, |, in it
Upvotes: 56
Reputation: 2853
If you want to use backticks to surround a word that you do not want formatted as code (for example, `sql_columns`), there are three approaches that I'm aware of:
`
which will produce a backtick from StackOverflow's Markdown engine,\`
HTML entity which produces `\
as an escape for the backtick: typing \`text\` produces `text`.Upvotes: 1
Reputation: 3332
This one is actually given as an example by John Gruber himself.
You can see from the Markdown documentation that you should write `` ` ``
to get `
.
Upvotes: 60