Markdown is a lightweight markup language, like Creole, JsonML, or Texy!. The lightweight markup languages have a simple, intuitive syntax making them useful for various text editors and wikis.
Markdown was created by John Gruber and Aaron Swartz in 2004. It is widely used for annotating readme files and curating rich-text messages. Markdown is very useful for creating rich-text formatting using a normal, plain text editor.
In this post, we are going to take a look at some of the most useful and frequently used features of this language. This Markdown cheat sheet is going to come in handy for anybody dabbling in it.
One thing to note here is that some of the features listed here are not fully supported by Markdown and needs additional support from the editor. But any new editor should do a good job.
Here’s the list of what we cover in this article:
You can create a heading by using an adequate number of hashes (‘#’). You can control the size of the heading by reducing or increasing the number of hashes.
### Big Header
## Bigger Header
# Biggest Header
The bold effect can be achieved using either the double star (‘**’) or the double underscore (‘__’). You need to wrap the text in any one of the mentioned symbols.
**Bold text created using the double star.**
__Bold text created using the double underscore.__
Italicized text can be created by using either the single star (‘*’) or the single underscore (‘_’). Just like the bold, you need to wrap the text in any one of these characters.
*Italicised text created using the single star.*
_Italicised text created using the single underscore._
Note: You can create the bold and italics effects together also (in case you want a ‘bold italicized’ piece of text). Be sure to close them properly as it can get pretty messy.
Quotes are very useful for writing messages or emails. To create a quoted text, you use the forward angle bracket (‘>’). There is a useful feature that some editors support. In case you have a very long passage to quote, you can conveniently place each sentence in a new line starting with a forward angle bracket.
You could shove everything in a single looooooooong line as well, but that’s simply less useful. This makes the source file much cleaner and readable.
> This is the first line.
> This is the second line. They are going to be part of the same quote. Cool!
> This is a very, very, very long line. This is going to look the same as before, but it’s much better to break this line into multiple parts if possible.
Just like bold or italics, you need to wrap the text in the double tilde (‘~~’).
~~To create the strikethrough effect, use a double tilde.~~
There are some ambiguities as to how a horizontal rule could be created. The original Markdown required the use of a triple hyphen (—) for creating a horizontal rule. But many editors these days support some other syntaxes as well such as the triple asterisk (***) and triple underscore (___).
This text is before the horizontal rule.
***
This text is after the horizontal rule.
Often you would need to include a piece of code in your text. Markdown lets you include code very easily. In fact, you can include the code using two different methods.
The first way is to simply wrap the code inside single backticks (‘`’). This is the preferred way if you want an inline code i.e. any text in the same line before and after the code would be rendered in the same line.
This text is before the code. `This is a piece of code surrounded by backticks.` This text is after the code.
The second method is to use what is popularly known as ‘fenced code blocks’. A piece of code surrounded by triple backticks (‘“`’) would be rendered separately from the text preceding and following it.
“`
This is a piece of code surrounded by triple backticks.
“`
Note: While rendering codes is an inherent feature of Markdown, code highlighting is not. That being said, many modern editor support code highlighting anyway. You need to mention the language that you are using immediately after the opening triple backticks.
Lists are useful for creating numbered collections. There is, in fact, no special syntax for creating one. You simply write to them as you would have normally written, and the Markdown editor would take care of the rest.
Unordered lists are different from the ordered lists in that they don’t include the number, instead use a bullet symbol. The items can be specified using a hyphen (‘-‘), plus (‘+’), or asterisk (‘*’).
– The first item.
+ The second item.
* The third item.
Markdown inherently does not support tables, although most of the modern Markdown editors support them. The columns are denoted by pipes (‘|’) while hyphens (‘-‘) are used to separate the heading and the rest of the rows.
| Product | Quantity | Price |
| ——– | ——— | —– |
| Milk | 1 liter | $1 |
| Butter | 0.5 kg | $3 |
| Tuna | 1 kg | $30 |
There are many different ways to include an anchor or hyperlink in the document. You need to use the square brackets (‘[]’) for specifying the text while parentheses (‘()’) is used to specify the webpage (plus the optional description).
[This is a link without description.](https://www.google.com)
[This is a link with description.](https://www.google.com “Google knows everything!”)
Including an image in your document is somewhat similar to including a link. Here you need to specify an alternate text inside the square brackets (‘[]’) while the link to the image is specified inside the parentheses (‘()’). Just like links, you can also specify an optional description.
![alt text](https://s16458.pcdn.co/wp-content/uploads/2020/01/logo-1.png “ByteScout!!”)
Including videos is not very straightforward, and it is mostly up to the editors (rather than Markdown). Following is a way to attach a video, although it cannot be played directly (it simply redirects the user to where the video is located).
[![IMAGE ALT TEXT HERE](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png)](https://youtu.be/6A5EpqqDOdk)