Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backticks are not escaped with the escape character (\) #363

Closed
zspencer opened this issue Sep 13, 2014 · 21 comments
Closed

Backticks are not escaped with the escape character (\) #363

zspencer opened this issue Sep 13, 2014 · 21 comments

Comments

@zspencer
Copy link

zspencer commented Sep 13, 2014

I believe the following code:

`\``

should render:

<p><code>`</code></p>

as specified in the markdown syntax reference

A "kinda workaround" is to use &#96; in place of the backtick (`) character; however this doesn't work inside of backticks: &#96;

Interestingly enough, the github basics of markdown documentation itself does have backticks inside of a code block.

Also interesting is almost no processor seems to get this right.

Is 9:30AM to early to start drinking?

@zspencer
Copy link
Author

zspencer commented Sep 13, 2014

Never mind; it appears the proper syntax for inserting backticks inside of codeblocks is to use more backticks: `

Edit with example: ``console.log(`Now this is ${excitingAdventureWhichIsLegallyDistinctButNotDissimilarToPodracing}`) ``

@amm-catapult
Copy link

amm-catapult commented Mar 23, 2016

Here are more examples:

  • CTRL+` gives: `CTRL+``
  • `` CTRL+` `` gives: CTRL+`

Just keep using more and more contiguous leading (and hence trailing) backticks with spaces inside them, per the pattern above, to go as crazy as you like :) For example:

`Oh you want FIVE backticks? ````` You'll need SIX to lead/trail, then :)`
...becomes...

Oh you want FIVE backticks? ````` You'll need SIX to lead/trail, then :)

@psharma9145
Copy link

psharma9145 commented Aug 24, 2018

<p>test<p>

@pyzae
Copy link

pyzae commented Dec 30, 2018

ive found that in triple-backtick code blocks, following any backticks with zero-width spaces allows any number of backticks in a row without breaking out of the code block

@matthiasstock
Copy link

matthiasstock commented Mar 11, 2019

@pyzae I just want to mention that everyone who copy-pastes these zero-width spaces can have a hard time depending on his context... We should not release them into the wild.

@pyzae
Copy link

pyzae commented Mar 12, 2019

@matthiasstock what do you mean a hard time depending on his context?
do you mean people copy-pasting out of the code blocks not realizing there are invisible characters there?

@matthiasstock
Copy link

matthiasstock commented Mar 12, 2019

@pyzae Yes, I just wanted to point out to later readers that there can be problems with these zero-width spaces in code examples. A code interpreter (in my context) generated a hard to understand error message.

@fireattack
Copy link

fireattack commented May 11, 2019

I'm very confused by the examples in #363 (comment), did something change?

@mbrowne
Copy link

mbrowne commented Sep 19, 2019

It seems that this only works with blocks of code starting on a new line, not inline code blocks.

@masaeedu
Copy link

masaeedu commented Feb 18, 2020

I wrote the following commit message:

    Remove unnecessary wrapping

    Made the classic error when testing of assuming that this: ``-1 `mod` 3``

    parses as this: ``(-1) `mod` 3``

    when it actually parses as this: ``-(1 `mod` 3)`

But the way this is rendered in Github is kind of wonky:

image

Am I misunderstanding the Markdown specification?

EDIT: Just noticed I have a typo on the last line (I'm missing a closing backtick), but this doesn't seem to work on the other lines either.

@fireattack
Copy link

fireattack commented Feb 18, 2020

Seems to work fine here in the comments? See: -1 `mod` 3

arantius added a commit to arantius/kernel-wasm that referenced this issue Feb 28, 2020
To escape backticks-in-backticks, switch the outer/container backticks to double-backticks.  (See: github/markup#363 (comment) .)
laughinghan added a commit to laughinghan/mechanical that referenced this issue Apr 8, 2020
github/markup#363 (comment)

Also, fix code block that shouldn't have been dedented
@magni-
Copy link

magni- commented May 8, 2020

Seems to work fine here in the comments? See: -1 `mod` 3

That does not work if the inner backticks are at the start/end of the inline code: ``kill `pgrep -f rspec```

@thegiantbeast
Copy link

thegiantbeast commented Nov 9, 2020

@magni- you can try:

`` `the-text-between-backtick` ``

You need to basically have a double backtick with a space (before and after). So in your case if you put a space after the first backtick at the end, it will work, ex: kill `pgrep -f rspec`

tomByrer added a commit to tomByrer/vscode-bracket-select that referenced this issue Jan 23, 2021
Secret method
github/markup#363 (comment)
Explains why `<>` are not matched.
@hepcat72
Copy link

hepcat72 commented Mar 18, 2021

Do you have to have spaces on both ends to avoid a space?

  1. No spaces, no code: ``git grep ">pre(@" `git rev-list --all```
  2. 1 space, code with extra space: git grep ">pre(@" `git rev-list --all`
  3. flanking spaces (we'll see): git grep ">pre(@" `git rev-list --all`

@hepcat72
Copy link

hepcat72 commented Mar 18, 2021

Huh... That's really strange. No trailing ending space in case 2, but the same markdown in a comment on an issue in our (private) repo shows a trailing space inside the in-line code. Why would that be? Let me try the whole sentence:

According to git grep ">pre(@" `git rev-list --all` , that line in joblog.pl is the only call of pre with an array argument in the entire history of the repo. And the blame claims it has been that way since laurie's initial checkin 17 months ago.

@hepcat72
Copy link

hepcat72 commented Mar 18, 2021

Yep. Why the differing behaviors? Is it because the line ends with git grep ">pre(@" `git rev-list --all`

hmmm...

@hepcat72
Copy link

hepcat72 commented Mar 18, 2021

Perhaps.

@gennaro-tedesco
Copy link

gennaro-tedesco commented Jul 24, 2021

It seems that this only works with blocks of code starting on a new line, not inline code blocks.

I confirm that with inline code blocks none of the examples above works unless the backticks are in the middle of the sentence and not at the boundaries.

@arencambre
Copy link

arencambre commented Jan 13, 2022

EDIT: Per the next comment, it is documented.

Since three backticks has special meaning to Github, the following needs to be made clear in Github's documentation: If you need to show three backticks in your code block, then surround the code block with four-backtick delimiters.

@pixelstuermer
Copy link

pixelstuermer commented Jan 31, 2022

Since three backticks has special meaning to Github, the following needs to be made clear in Github's documentation: If you need to show three backticks in your code block, then surround the code block with four-backtick delimiters.

I guess they do so:
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks

@shmup
Copy link

shmup commented Aug 5, 2022

How might I do render: "<CR> where the " is a backtick?

Ok I got it, phew. Just use a <code> block.. though I still have to escape the <CR>, heh.

<code>`\<CR\></code>

Ala.. `<CR>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests