Markdown

A simplified syntax to create formatted documents

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 ResultHTML syntaxMarkdown syntax
  • Thing one
  • Thing two
  • Thing three
<ul>
  <li>Thing one</li>
  <li>Thing two</li>
  <li>Thing three</li>
</ul>
* Thing one
* Thing two
* Thing three

Or the difference between the syntax for hyperlinks:

Desired Result

Visit UC Santa Barbara

HTML syntax
Visit <a href="https://www.ucsb.edu">UC Santa Barbara</a>
Markdown syntax
Visit [UC Santa Barbara](https://www.ucsb.edu)

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 &lt;&lt; &quot;Hello, World&quot; &lt;&lt; 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.)