I want to create a long "-", normally used between adjacent (sub)sentences, in Markdown.
Here I've copied the particular character from another site: –.
How can I create such "–" in Markdown?
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.
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.
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 − −
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.
Characters are characters—neither markup nor markdown.
Em dash —, in Windows, with the number keypad: Alt(hold)+0151
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With