Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a long "-" in Markdown, i.e. the character "–"?

Tags:

markdown

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?

like image 667
Shuzheng Avatar asked Sep 17 '18 16:09

Shuzheng


2 Answers

You have three options:

  1. Insert the Unicode character

  2. Use the HTML entity for the character.

  3. 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.

like image 85
Waylan Avatar answered Sep 22 '22 15:09

Waylan


Characters are characters—neither markup nor markdown.

Em dash —, in Windows, with the number keypad: Alt(hold)+0151

like image 28
Tom Blodget Avatar answered Sep 21 '22 15:09

Tom Blodget