Markdown语言的基础学习笔记。
Markdown这个词有两个概念:
1.一种格式化纯文本的语言.
2.一个软件工具,由Perl实现,将纯文本转化为HTML.
//Dingus 这个web 应用可以让你键入自己的Markdown格式文本,将其翻译为XHTML
段落,标题,引用
段落只是简单的由1行或多行连贯文本组成,被一个或多个空行分隔。空行可包含空格和tabs, 通常段落不应被空格或tabs缩进.
Markdown 提供两种风格的标题:Setext和atx.
Setext风格的标题<h1>
和<<h2>
分别由=和短横线-在文本下划实现。
例如
A First Level Header
====================
A Seconde Level Header
----------------------
效果为:
A First Level Header
A Seconde Level Header
atx风格的标题由在行前添加1-6个#来实现,#的个数代表了HTML结果中标题的层级
### Header 3
显示效果为
Header 3
斜体和加粗
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__.
Output:
<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.
输出一样的结果:
Candy.
Gum.
Booze.
有序列表使用数字和.作为标识
1.Red
2.Green
3.Blue
输出:
- Red
- Green
- Blue
链接
Markdown支持两种创建链接的方式:inline和reference
Inline
This is an [example link](http://example.com/).
Output:
<p>This is an <a href="http://example.com/">
example link</a>.</p>
可选的,你也可以在括号内加入标题属性
This is an [example link](http://example.com/ "With a Title").
输出:
<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"
输出:
<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>
标题属性是可选的,链接可包含字母,数字和空格,大小写不敏感
I start my morning with a cup of coffee and
[The New York Times][NY Times].
[ny times]: http://www.nytimes.com/
Output:
<p>I start my morning with a cup of coffee and
<a href="http://www.nytimes.com/">The New York Times</a>.</p>
图片
图片语法类似于链接
Inline-style(title可选):
![alt text](/path/to/img.jpg "Title")
Reference-style:
![alt text][id]
[id]: /path/to/img.jpg "Title"
以上两个例子生成同样的输出:
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
代码
在普通段落中,可用反引号包裹住代码引用。&, <和>会自动转义成HTML实体。
I strongly recommend against using any `<blink>` tags.
I wish SmartyPants used named entities like `—`
instead of decimal-encoded entites like `—`.
Output:
<p>I strongly recommend against using any
<code><blink></code> tags.</p>
<p>I wish SmartyPants used named entities like
<code>&mdash;</code> instead of decimal-encoded
entites like <code>&#8212;</code>.</p>
如果需要列举一整块预格式过的代码,将每行进行4个空格的缩进(一个tab)
Markdown:
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>
Output:
<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><blockquote>
<p>For example.</p>
</blockquote>
</code></pre>