Markdown: Basics (Quick Start)

Getting the Gist of Markdown's Formatting Syntax

This page provides simple concepts of Markdown, and the  syntax description  page provides full and detailed documentation explaining each feature. But Markdown is actually very easy to get started, this page of documentation provides some examples, and each example will provide the output HTML results.

In fact, it is also a very good method to try it directly.  Dingus  is a web application, you can convert your own Markdown documents into XHTML.

Paragraph, heading, block code

A paragraph is composed of more than one connected line sentence, and more than one blank line will divide different paragraphs (the definition of a blank line is that it looks like a blank line on the display, it is regarded as a blank line, for example, there are A line only has blanks and tabs, then the line will also be regarded as a blank line), and general paragraphs do not need to be indented with blanks or newlines.

Markdown supports two syntaxes for headings, Setext  and  atx  . The Setext form is the form with the bottom line, using  = (the highest order heading) and  - (the second order heading), the Atx form inserts 1 to 6 at the beginning of  the line # , corresponding to the headings 1 to 6 orders.

Blockquotes use ' >' angle brackets in the form of email.

Markdown syntax:

A First Level Header
====================
A Second Level Header
---------------------

Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.

The quick brown fox jumped over the lazy
dog's back.
### Header 3

> This is a blockquote.
> 
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote

The output HTML is:

<h1>A First Level Header</h1>
<h2>A Second Level Header</h2>
<p>Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.</p>
<p>The quick brown fox jumped over the lazy
dog's back.</p>
<h3>Header 3</h3>
<blockquote>
<p>This is a blockquote.</p>
<p>This is the second paragraph in the blockquote.</p>
<h2>This is an H2 in a blockquote</h2>
</blockquote>

Rhetoric and Emphasis

Markdown uses asterisks and underscores to mark sections that need emphasis.

Markdown syntax:

Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.

The output HTML is:

<p>Some of these words <em>are emphasized</em>.
Some of these words <em>are emphasized also</em>.</p>
<p>Use two asterisks for <strong>strong emphasis</strong>.
Or, if you prefer, <strong>use two underscores instead</strong>.</p>

list

Unordered lists use asterisks, plus signs, and minus signs to mark the items of the list. All of these symbols can be used. Use the asterisk:

* Candy.
* Gum.
* Booze.

plus:

+ Candy.
+ Gum.
+ Booze.

and minus sign

- Candy.
- Gum.
- Booze.

will output HTML as:

<ul>
<li>Candy.</li>
<li>Gum.</li>
<li>Booze.</li>
</ul>

Ordered lists use regular numbers followed by a period as item markers:

1. Red
2. Green
3. Blue

The output HTML is:

<ol>
<li>Red</li>
<li>Green</li>
<li>Blue</li>
</ol>

If you insert a blank line between items, the content of the item will be  <p> wrapped, you can also put multiple paragraphs in one item, as long as it is indented by 4 spaces or 1 tab before it.

* A list item.
With multiple paragraphs.

* Another item in the list.

The output HTML is:

<ul>
<li><p>A list item.</p>
<p>With multiple paragraphs.</p></li>
<li><p>Another item in the list.</p></li>
</ul>

Link

Markdown supports two forms of link syntax:  inline  and  reference  , both of which use angle brackets to turn text into links.

The inline form is to directly follow the link with parentheses:

This is an [example link](http://example.com/).

The output HTML is:

<p>This is an <a href="http://example.com/">
example link</a>.</p>

You can also optionally add the title attribute:

This is an [example link](http://example.com/ "With a Title").

The output HTML is:

<p>This is an <a href="http://example.com/" title="With a Title">
example link</a>.</p>

Links in reference form allow you to give the link a name, and then you can define the content of the link elsewhere in the file:

I get 10 times more traffic from [Google][1] than from
[Yahoo][2] or [MSN][3].

[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"

The output HTML is:

<p>I get 10 times more traffic from <a href="http://google.com/"
title="Google">Google</a> than from <a href="http://search.yahoo.com/"
title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
title="MSN Search">MSN</a>.</p>

The title attribute is optional, the link name can use letters, numbers and spaces, but is not case sensitive:

I start my morning with a cup of coffee and
[The New York Times][NY Times].

[ny times]: http://www.nytimes.com/

The output HTML is:

<p>I start my morning with a cup of coffee and
<a href="http://www.nytimes.com/">The New York Times</a>.</p>

picture

The syntax for images is similar to links.

Inline form (title is optional):

![alt text](/path/to/img.jpg "Title")

Reference form:

![alt text][id]

[id]: /path/to/img.jpg "Title"

Both methods above will output HTML as:

<img src="/path/to/img.jpg" alt="alt text" title="Title" />

code

In normal paragraph text, you can use backticks  ` to mark code sections. The  &, < and  , in the section > are automatically converted to HTML entities. This feature allows you to easily insert HTML code into the code section. :

I strongly recommend against using any `<blink>` tags.

I wish SmartyPants used named entities like `&mdash;`
instead of decimal-encoded entites like `&#8212;`.

The output HTML is:

<p>I strongly recommend against using any
<code>&lt;blink&gt;</code> tags.</p>
<p>I wish SmartyPants used named entities like
<code>&amp;mdash;</code> instead of decimal-encoded
entites like <code>&amp;#8212;</code>.</p>

If you want to create a formatted block of code, just indent each line by 4 spaces or a tab, and  &, < and  > will be automatically converted to HTML entities.

Markdown syntax:

If you want your page to validate under XHTML 1.0 Strict,
you've got to put paragraph tags in your blockquotes:

<blockquote>
<p>For example.</p>
</blockquote>

The output HTML is:

<p>If you want your page to validate under XHTML 1.0 Strict,
you've got to put paragraph tags in your blockquotes:</p>
<pre><code>&lt;blockquote&gt;
&lt;p&gt;For example.&lt;/p&gt;
&lt;/blockquote&gt; 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326197584&siteId=291194637