Markdown
Markdown is an alternative to HTML (Hypertext Markup Language) for producing formatted text, specially for web content.
The chief advantage of Markdown is the simplicity of it’s syntax. As an example, compare the syntax for bulleted lists between HTML and Markdown
Desired Result | HTML syntax | Markdown syntax |
---|---|---|
|
|
|
Or the difference between the syntax for hyperlinks:
Desired Result | Visit UC Santa Barbara |
---|---|
HTML syntax |
|
Markdown syntax |
|
A key advantage is for source code. Suppose you want the following C++ source code to appear on a web page:
cout << "Hello, World" << endl;
While the <pre>
tag can be used for source code (e.g. Java, C++, etc.), there is still the problem that many characters have to be escaped.
For example, the following is not legal HTML:
<pre>
cout << "Hello, World" << endl;
</pre>
The problems are highlighted here (by the automatic syntax highlighing of Markdown):
<pre>
cout << "Hello, World" << endl;
</pre>
To be strictly compliant HTML, this woudl have to be written as:
<pre>
cout << "Hello, World" << endl;
</pre>
That is obviously inconvenient. Instead, in Markdown, one can simply write:
```cpp cout << "Hello, World" << endl; ```
And get this
cout << "Hello, World" << endl;
(Note that many systems that support Markdown processing have built-in syntax highlighting.)