How to make a long "-" in Markdown, i.e. the character "–"?
Solution 1:
You have three options:
Insert the Unicode character
Use the HTML entity for the character.
Use a tool like Smartypants to convert plain text to HTML entities.
Use Unicode Characters
You can copy the character from elsewhere and past it directly into your document. Of course this is tedious and not very convenient. However, as highlighted in other answers, you could learn the keyboard shortcuts for the system you use to insert the desired characters.
Use HTML Entities
Using HTML Entities is the officially supported method by Markdown. As the rules state:
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.
Therefore, simply insert the HTML entity directly into your document. You can find the various codes listed on many sites across the internet (such as here or here). A few related to dashes are:
En-Dash – –
Em-Dash — —
Minus Symbol − −
Use Smartypants
Of course, you may not want to memorize or look up the HTML entity codes every time you need to use them. It is easier to just use the basic characters on the keyboard. For this reason the creator of Markdown also created Smartpants, which is a Markdown postprocessor. It accepts the output of Markdown and converts plain character shortcuts to the appropriate HTML Entities for you.
As the documentation explains:
SmartyPants can perform the following transformations:
- Straight quotes ( " and ' ) into “curly” quote HTML entities
- Backticks-style quotes (``like this'') into “curly” quote HTML entities
- Dashes (“--” and “---”) into en- and em-dash entities
- Three consecutive dots (“...”) into an ellipsis entity
This means you can write, edit, and save your posts using plain old ASCII straight quotes, plain dashes, and plain dots, but your published posts (and final HTML output) will appear with smart quotes, em-dashes, and proper ellipses.
Of course, to make use of Smartpants, you need to either be using one of the programs which supports a Smartypants plugin or run your Markdown output through the command line program. Therefore it doesn't work everywhere. But it works great when you're in an environment where it is supported.
Solution 2:
Characters are characters—neither markup nor markdown.
Em dash —, in Windows, with the number keypad: Alt(hold)+0151
Solution 3:
You could try the HTML entity if it allows you —
or —
.
https://daringfireball.net/projects/markdown/syntax
Solution 4:
As I known, Option(alt)
+ -
is –
for Mac.
Solution 5:
You may also be able to input this as a Unicode character using your keyboard. Most Markdown processors that I've used handle this just fine.
For example, I have a compose key configured. With my fairly standard configuration, Compose--- gives an em dash and Compose--. give an en dash.