What do y’all use more often? Please, explain why in a comment below. If y’all use a mix of both, comment below what do you use each method for?
- Tilde
- Backtick
- Both
What do y’all use more often? Please, explain why in a comment below. If y’all use a mix of both, comment below what do you use each method for?
What is the tilde syntax you’re referring to? I’m only familiar with triple backticks or four-space indenting for code blocks.
You can use the tilde character for fenced code blocks the exact same way you can use the backtick character. The first Markdown variant to use tildes for fenced code blocks is PHP Markdown Extra.
CommonMark Spec 0.31.2 Section 4.5 Fenced code blocks
A code fence is a sequence of at least three consecutive backtick characters (```) or tildes (
~
). (Tildes and backticks cannot be mixed.) A fenced code block begins with a code fence, preceded by up to three spaces of indentation.
Oh right, yeah it seems that Discourse supports it:
foobar
On many keyboard layouts, `
is input with a dead key, i.e. it expects a letter to be put on as a diacritic mark (grave accent), but if something else follows, it will appear, so you either input them in pairs or you need to hit the space bar. On the other hand, ~
usually is not a dead key but altars immediately.
On soft keyboards on touchscreens, e.g. Apple’s on iOS, the backtick is accessed by holding down the ’
key and selecting it from the popup, thereafter the alphabet keyboard reappears and one needs to select the numeric/punctuation level again, whereas the tilde has a key of its own on the second punctuation level.
In conclusion, tilde is often simply easier and quicker to input than backtick.
From a semantic point of view, it might appear that backtick makes more sense because inline code markup uses the same character, but we don’t have that for other markup either: *
is inline emphasis or block list item or horizontal divider, for instance.
If we had opt-in different behavior for code blocks with either `
or ~
, I’d say backtick fenced blocks would be for normal syntax-highlighted code and tilde fenced blocks would be for parsed code if possible (including math and diagrams).