1

Background
I realize that markup is implementation without a specification but it basically is just a tiny little node stemming from SGML and the like. On GitHub I always use the ` symbol with a closed back tic to indicate code when it's inline with a sentence. This often happens with bash/shell scripting in this particular scenario.

Example #1 - Block Code
If you are looking for oracle's creg ini file you would know that on Oracle Cloud you can view it using view /var/opt/oracle/creg/ORCL.ini. However, this assumes you used the recommended settings for simple DBaaS provision. If you named your database MFG the command would be view /var/opt/oracle/creg/MFG.ini. Thankfully there is an environment variable that holds the database name. And if I were writing a simple bash script it would look like:

#!/bin/bash

cd /var/opt/oracle/creg/`printenv ORACLE_SID`.ini

So that prints fine in a block.

Exampe #2 - Inline
So if I simply want to tell a user to 'cd /var/opt/oracle/creg/printenv ORACLE_SID.ini' I shouldn't have to make a block.

Question
IS there an escape character in GitHub's markup implementation? I want the entire thing to show just like a normal line of code. It's better on StackOverflow on GitHub it basically breaks the page.

2 Answers 2

2

GitHub uses Markdown (specifically a custom 'flavour' thereof), and in Markdown you can escape backticks in code by using double backticks: https://github.com/mattcone/markdown-guide/blob/master/_basic-syntax/code.md#escaping-backticks

If the word or phrase you want to denote as code includes one or more backticks, you can escape it by enclosing the word or phrase in double backticks (``).

2
  • right after creating the post I attempted to escape using ('') however it gave me a 500 error. Then when I navigated to the markdown gist it showed incorrectly (it showed all as code, but with two open and two close backticks ). You can see my history here. There is a thread on github about it now. Somehow it magically fixed itself with no revision change so someone at github definitely took notice Commented Nov 14, 2019 at 2:57
  • What if I'd like to escape triple backticks? Commented Mar 19, 2023 at 17:05
1

For both a single backtick and triple backtick, it seems that github (and stackexchange) support a backslash escape:

cd /var/opt/oracle/creg/\`printenv ORACLE_SID\`.ini

gives: cd /var/opt/oracle/creg/`printenv ORACLE_SID`.ini

and:

\```
stuff
\```

gives ``` stuff ``` on stackexchange, but github doesn't always wrap lines, so this stays as 3 lines.

Backslash also works for escaping underscore _ and asterisk * (otherwise italics, or bold when doubled).

For other markup, Markdown supports using html for things the regular syntax doesn't support. This is true for the GitHub flavored Markdown see Raw HTML.

It isn't as simple as a backslash escape, but using the HTML span element does work to escape special github characters such as hash # and at sign @.

e.g.:

install the <span>@</span>latest markdown package, it's <span>#</span>1

gives: install the @latest markdown package, it's #1

without creating a link to a (possibly non existent) github user or issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.