Markdown Markup Language
- 5 minutes read - 853 wordsIn this blog post we will cover the markdown markup language. Markdown makes writing the text on web faster and easier and is a good choice for variety of tasks like writing the code related documentation, blog posts, emails etc.
What is Markdown?
Straight from wikipedia - Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz. Markdown is a text to html converter and often used to format readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.
Many flavors of markdown exist out of which following 2 are the most commonly used:
- CommonMark markdown specification.
- GitHub-Flavored Markdown, which is based on CommonMark, adds extensions like tables, task lists, automatic links etc.
I use “Visual Studio Code” for many reasons and out of the box support for markdown is one of them. “Visual Studio Code” targets the CommonMark markdown specification.
Lets look into some of the most commonly used Markdown syntaxes.
Headings
A heading can be created by using # symbols. More number of # symbols means smaller heading size.
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
will result into
Paragraphs
A paragraph is consecutive lines of text. Use\
to have a line break inside a paragraph.
A paragraph is consecutive lines of text. Use (2 blank spaces)
to have a line break inside a paragraph.
To add a new paragraph add one or 2 blank lines between them as added above this paragraph.
will result into
A paragraph is consecutive lines of text. Use
to have a line break inside a paragraph.
A paragraph is consecutive lines of text. Use (2 blank spaces)
to have a line break inside a paragraph.
To add a new paragraph add one or 2 blank lines between them as added above this paragraph.
Emphasis
Bold or Italic texts can be created by wrapping the text inside asterisks * or underscores _.
This is the demo for the *Italic* text.
This is also the demo for the _Italic_ text.
This is the demo for the **Bold** text.
This is also the demo for the __Bold__ text.
This is the demo for both **Bold and _Italic_** text.
will result into
This is the demo for the Italic text.
This is also the demo for the Italic text.
This is the demo for the Bold text.
This is also the demo for the Bold text.
This is the demo for both Bold and Italic text.
Blockquotes
Blockquotes can be created by starting the line with > sign followed by optional space.
> This is a blockquote.
> This is a blockquote.
> > This is a nested blockquote.
This is a blockquote.
This is a blockquote.
This is a nested blockquote.
Links
Links can be created inline with the text or at the bottom of the text with references.
Link to google is <https://google.com>
[Google](https://google.com) is a search engine.
[Google][1] is a search engine.
[Google][1] is a search engine.
[1]: https://google.com
will result into
Link to google is https://google.com
Google is a search engine.
Google is a search engine. Google is a search engine.
Lists
Unordered lists can be created by using * or - markers.
Ordered lists can be created by using number followed by . or ).
Car companies:
- Ferrari
- BMW
- Mercedes
Car companies:
1. Ferrari
2. BMW
3. Mercedes
will result into
Car companies:
- Ferrari
- BMW
- Mercedes
Car companies:
- Ferrari
- BMW
- Mercedes
Images
Images can be created by starting with ! followed exactly by the way the links are created.
![Blog](/images/blog-banner-1.jpg)
OR
![Blog][1]
[1]:/images/blog-banner-1.jpg
will result into
OR
Code
Code block can be created by wrapping the code inside backticks ```. Also, the code formatting can be applied by adding the supported language at the end of the backticks.
Following shows the code in csharp language formatted code
var sum = 0;
for (var cnt = 1; cnt <= 10; cnt++)
{
sum = sum + cnt;
}
Following shows the json formatted content
{
"one": 2,
"three": {
"point_1": "point_2",
"point_3": 3.4
},
"list": ["one", "two", "three"]
}
Tables
Tables comprises of header, rows and columns. A cell is created by wrapping the content inside the |. Also, the header is created by adding a follow up row with 3 or more —.
|Name|Age|
|----|---|
|John|20|
|Adam|30|
Also, the alignment of text can be specified by adding **:** on left, both sides or right of ---.
|Order Item|Ordered By|Quantity |Price per Item|
|:---------|:---------|:----------:|-------------:|
|Apple |John |2 |$1 |
|Left Align|Left Align|Middle Align|Right align |
will result into
Name | Age |
---|---|
John | 20 |
Adam | 30 |
Also, the alignment of text can be specified by adding : as shown below.
Order Item | Ordered By | Quantity | Price per Item |
---|---|---|---|
Apple | John | 2 | $1 |
Left Align | Left Align | Middle Align | Right align |
References
Conclusion
Markdown was designed for web and is a fast way to create content for websites, blog posts, taking notes, emails, technical documentation etc.