Markdown

Markdown

What is Markdown?

Markdown is a simple markup language developed by John Gruber and Aaron Swartz in 2004. It is a plain text formatting syntax that can be converted to HTML. Markdown is widely used in blogging, instant messaging, online forums, collaborative software, documentation pages, and readme files.

It is very popular language because of its simplicity and readability.

How to use Markdown?

As mentioned above, Markdown is a plain text formatting syntax, so you can use any text editor to write Markdown. Markdown files have the extension .md or .markdown.

For better editing experience, you can use a Markdown editor. There are many Markdown editors available, but I prefer Typora. It is a cross-platform Markdown editor that is available for Windows, macOS, and Linux. It has a live preview feature that makes it easy to write Markdown. You can also use StackEdit if you want to write Markdown in the browser.

Markdown Syntax

Here are some of the most commonly used Markdown syntaxes that you should know.

Headings

In Markdown if you start a line with # it is considered a heading. The number of # represents the depth of the heading, for example: # Heading is same as <h1>Heading</h1> and #### Heading is <h4>Heading</h4>.

For example:

# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6

You can also use = and - to create headings, but it is not used much.

Heading 1
=========

Heading 2
---------

Paragraph

In Markdown, a paragraph is just a block of text separated by one or more blank lines. You can also use <br> to create a line break.

For example:

This is a paragraph.

This is another paragraph.

This is a line break.<br>
This is another line break.

Text Styles

Basic text styling is easy with Markdown.

Want to make some text bold? Just wrap it with ** or __.

However the ** syntax is recommended.

**This is bold text.** 

__This is also bold text.__

Similarly, you can make text italic by wrapping it with * or _.

*This is italic text.*

_This is also italic text._

To make a text strikethrough, wrap it with ~~.

~~This is strikethrough text.~~

You can also combine these styles by nesting them.

**This is _bold and italic_ ~~string~~ text.**

Lists

Markdown supports both ordered and unordered lists.

To create an unordered list, start a line with *, +, or -.

* Item 1
* Item 2
  * Item 2a
  * Item 2b

To create an ordered list, start the line with a number followed by a period. The numbers don't have to be in sequence.

1. Item 1
1. Item 2
1. Item 3
   1. Item 3a
   1. Item 3b

You can also nest lists by indenting them.

1. Item 1
   * Item 1a
   * Item 1b
1. Item 2

To create a link inside a paragraph, wrap the link text in square brackets [] and the URL in parentheses () like this: [link text](url). You can optionally add a title for the link by adding a space between the URL and the title in quotes.

I am a [link](https://opu.rocks) inside a paragraph.

[I am also a link](/i-am-internal-link)

[This link has a title](https://opu.rocks "Opu's Blog")

Images

Adding images is similar to adding links. Just add an exclamation mark ! before the square brackets [] and the URL in parentheses () like this: ![alt text](url). Again you can add a title for the image by adding a space between the URL and the title in quotes.

![This is an image](https://opu.rocks/images/og-image.png)

![This image has a title](https://opu.rocks/images/og-image.png "Opu's Blog")

Blockquotes

To create a blockquote, start a line with >.

> This is a blockquote.

> This is another
> multiline blockquote.

You can also nest blockquotes by indenting them.

> This is a blockquote.
>
> > This is a nested blockquote.

Code

In Markdown you can create inline code and code blocks.

To create inline code, wrap the code in backticks `.

You can create inline code like this: `console.log('Hello World')`.

To create a code block, start a line with three backticks ``` and end it with three backticks ```.

You can also specify the language of the code block by adding the language name after the first three backticks. This helps to add syntax highlighting.


```c
#include <stdio.h>

int main() {
    printf("Hello World");
    return 0;
}
```

Horizontal Rule

To create a horizontal rule, start a line with three or more asterisks ***, dashes ---, or underscores ___.

---

***

___

Tables

To create a table, start a line with | and separate columns with |. You can optionally add a header row by adding a second line with | and separating columns with | and -.

| First Header | Second Header |
| ------------ | ------------- |
| Content 1    | Content 2     |
| Content 3    | Content 4     |

Markdown Extensions

Markdown is a simple and easy to use syntax, but it is not enough for many use cases. So there are many Markdown extensions that add more features to Markdown. Some of the most popular extensions are:

References

Conclusion

Reading this article, you should have a good understanding of Markdown. You can use Markdown to write your blog posts, notes, and other documents.

If you have any questions or suggestions, please leave a comment below.