码迷,mamicode.com
首页 > 其他好文 > 详细

Markdown基础

时间:2015-06-09 16:51:28      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

Markdown基础

本文介绍了Markdown的概貌和感觉。 Markdown语法才是Markdown的详细文档,但是Markdown应该很容易就用起来,只要看几个例子就够了。 本文中的每个例子都给出了Markdown的写法,及其转换后的HTML代码。

如果只是想简单地尝试一下Markdown,Dingus是一个不错的去处。

段落,标题,引文

若干连续的行(之间没有空白行分开)构成一个段落,段落之间由若干空白行分开。 (空白行指的是空行,或者只有空白字符的行,比如空格符,跳格符等)一个正常的段落不应该用空格或跳格进行缩进。

Markdown有两种风格的标题:Setext和atx。 Setext风格把等号(=)和连字号(-)当“下划线”用,分别表示<h1><h2>。 atx风格把1-6个井号(#)放在行首——井号的数目表示相应的HTML标题级别。

引文模仿email的‘>‘风格。

Markdown:

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

HTML:

<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>

强调

Markdown用星号(*)和下划线(_)标示要强调的文本。

Markdown:

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__.

HTML:

<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>

列表

无序号列表使用星号(*),加号(+),和连字符(-)。效果是一样的;所以

这样:

* Candy.
* Gum.
* Booze.

这样:

+ Candy.
+ Gum.
+ Booze.

还有这样:

- Candy.
- Gum.
- Booze.

都会生成:

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

有序号列表直接用数字加点号(.)

Markdown:

1. Red
2. Green
3. Blue

HTML:

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

你可以在列表项之间插入空白行,把列表项文本放入<p>标签。你可以用缩进(4个空格符或一个跳格符)编写多段落的列表项。

Markdown:

* A list item.

    With multiple paragraphs.

* Another item in the list.

HTML:

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

链接

Markdown支持两种风格的链接:inline和reference。在两种风格下,你都需要用方括号([ ])来标示要转化为链接的文本。

inline风格使用紧跟在链接文本后面的圆括号(( ))。例如:

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

HTML:

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

另外,你还可以在圆括号中提供标题属性:

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

HTML:

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

reference风格可以用名字引用链接,然后在别处定义该链接:

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"

HTML:

<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>

Markdown基础

标签:

原文地址:http://www.cnblogs.com/whgcompt/p/4563514.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!