您的位置:首页 > 其它

Markdown 基本用法说明

2017-09-25 16:32 357 查看

Markdown 基本用法说明

标题Header

两种表现形式:

1. #,一个#就是一级标题即h1,######就是h6[atx]

2. 在文本下加===,—,前为一级,后者为二级[Setext]

A First Level Header

A Second Level Header

Header 3

输出为HTML:

<h1>A First Level Header</h1>
<h2>A Second Level Header</h2>

<h3>Header 3</h3>


段落

一个段落是由一个以上的连接的行句组成,而一个以上的空行则会划分出不同的段落(空行的定义是显示上看起来像是空行,就被视为空行,例如有一行只有空白和 tab,那该行也会被视为空行),一般的段落不需要用空白或换行缩进。

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.

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


区块引用

使用’ > ’ 尖角号表示区块引用。

This is a blockquote.

This is the second paragraph in the blockquote.

This is an H2 in a blockquote

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


修辞和强调

一个*或者_表示斜体

两个**或者两个__表示粗体

三个* 或者_表示粗斜体

~~表示删除线

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.

And this is the strikethrough.

<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>
<p>And this is the <s>strikethrough</s></p>


超链接

Markdown 支持两种形式的链接语法: 行内式和参考式,两种都是使用中括号来把文字转成链接,行内式一般使用较多。

行内式

行内形式是直接在后面用括号直接接上链接

This is an example link.

This is an example link.

输出为HTML

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


语法说明:

* []里写链接文字

* ()里写链接地址, 里面的 “” 可以为链接指定title属性

* “title” 与链接地址间有空格

参考式

参考形式为链接定一个名称,之后在文件的其他地方定义该链接的内容,这种形式一般用在学术论文上面,它可以对链接进行统一方便的管理。

I get 10 times more traffic from Google than fromYahoo or MSN.

输出为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>


语法说明:

* 参考式链接分为两部分

* 文中的写法 [链接文字][链接标记]

* 文本的任意位置添加[链接标记]:linkaddr “title”

* 链接地址与链接标题前有一个空格

* 也可以写成[链接文字][],即链接文字本身做为链接标记

* [链接文字]:链接地址的形式,见代码的最后一行。

短链接

http://example.com/;

address@example.com;

输出为HTML

<http://example.com/>;
<address@example.com>;


语法说明:

Markdown 支持以比较简短的自动链接形式来处理网址和电子邮件信箱,只要是用<>包起来, Markdown 就会自动把它转成链接。一般网址的链接文字就和链接地址一样

锚点

网页中,锚点其实就是页内超链接,也就是链接本文档内部的某些元素,实现当前页面中的跳转。比如我这里写下一个锚点,点击回到目录,就能跳转到目录。 在目录中点击这一节,就能跳过来。还有下一节的注脚。这些根本上都是用锚点来实现的。

注意:

1. Markdown Extra 只支持在标题后插入锚点,其它地方无效。

2. Leanote 编辑器右侧显示效果区域暂时不支持锚点跳转,所以点来点去发现没有跳转不必惊慌,但是你发布成笔记或博文后是支持跳转的。

语法描述:

在你准备跳转到的指定标题后插入锚点{#标记},然后在文档的其它地方写上连接到锚点的链接。

代码:

## 0. 目录{#index}

跳转到[目录](#index)


显示效果:

跳转到目录

图片

图片的语法和链接很像,也有两种写法:行内式和参考式。

行内形式:



参考形式:



HTML输出均为:

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


语法说明:

* alt 和 title 都不是必须的,可以省略,但建议写上。

* 文档要插入图片的地方![图片Alt][标记]与后面地址间要有空行或其他字符隔开

代码

在一般的段落文字中,你可以使用反引号 ` 来标记代码区段,区段内的 & 、 < 和 > 都会被自动的转换成 HTML 实体,而三个“`包围起来的区域在可以将HTML代码原样输出(前面的代码块也是这么实现的):

I strongly recommend against using any
<blink>
tags.

I wish SmartyPants used named entities like


instead of decimal-encoded entites like
.

输出HTML为:

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


列表

无序列表

Markdown使用 * + - 表示无序列表。

* Red     + Red    - Red
* Green   + Green  - Green
* Blue    + Blue   - Blue


上面这三种方式其表现结果都一样

有序列表

Markdown使用数字接着一个英文句点(.)来表示有序列表。

书写顺序        展示结果为
1. Bird         1.Bird
2. McHale       2.McHale
3. Parish       3.Parish
6. Jack         4.Jack
5. Tom          5.Tom
4. Jerry        6.Jerry


列表标记上使用的数字并不会影响输出的 HTML 结果,最终还是按书写顺序来排序;

HTML输出为:

<ol>
<li>Bird</li>
<li>McHale</li>
<li>Parish</li>
<li>Jack</li>
<li>Tom</li>
<li>Jerry</li>
</ol>


列表缩进

列表项目标记通常是放在最左边,但是其实也可以缩进,最多 3 个空格,项目标记后面则一定要接着至少一个空格或制表符。

要让列表看起来更漂亮,可以把内容用固定的缩进整理好:

* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,

viverra nec, fringilla in, laoreet vitae, risus.

* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.

Suspendisse id sem consectetuer libero luctus adipiscing

这样在编写段看起来整齐多了,当然下面这这段显示也是一样的:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,

viverra nec, fringilla in, laoreet vitae, risus.

Donec sit amet nisl. Aliquam semper ipsum sit amet velit.

Suspendisse id sem consectetuer libero luctus adipiscing.

包含段落的列表

列表项目可以包含多个段落,每个项目下的段落都必须缩进 4 个空格或是 1 个制表符

1. This is a list item with two paragraphs. Lorem ipsum dolor

sit amet, consectetuer adipiscing elit. Aliquam hendrerit

mi posuere lectus.

Vestibulum enim wisi, viverra nec, fringilla in, laoreet

vitae, risus. Donec sit amet nisl. Aliquam semper ipsum

sit amet velit.

2. Suspendisse id sem consectetuer libero luctus adipiscing

同样的不这么对编写时不这么对齐,显示时也是一样的

包含引用的列表

如果要在列表项目内放进引用,那 > 就需要缩进:

A list item with a blockquote:

This is a blockquote

inside a list item.

输出为HTML

包含引用代码区块的列表

如果要放代码区块的话,该区块就需要缩进两次,也就是 8 个空格或是 2 个制表符:

一列表项包含一个列表区块:

<代码写在这>


输出HTML为:

<p>这是一个普通段落:</p>
<pre><code>这是一个代码区块。
</code></pre>


特殊情况

如行首出现数字-句点-空白,这样会被认为是一个列表(实际上不是),比如:

1986. What a great season.


输出为HTML为:

1986. What a great season.

为避免这样的情况出现,可以在句点前面加上反斜杠(转义):

1986. What a great season.

分隔线

在一行中用三个以上的星号、减号、底线来建立一个分隔线,行内不能有其他东西。你也可以在星号或是减号中间插入空格。下面每种写法都可以建立分隔线:

输出为HTML

<hr>
<hr>
<hr>
<hr>
<hr>


表格

使用HTML表格代码编写

使用分割符: | 来分开各列; 自然行的分为行

表头与表主题间以: -|- 分开

分割行还可以为不同的列指定对齐方向,默认为左对齐,在-右边加上:就右对齐

学号姓名分数
小明75
小红79
小陆92
学号姓名分数
小明75
小红79
小陆92
产品价格
Leanote 高级账号60元/年
Leanote 超级账号120元/年
输出为HTML

<table>
<thead>
<tr>
<th>学号</th><th>姓名</th><th>分数</th>
</tr>
</thead>
<tbody>
<tr>
<td>小明</td><td>男</td><td>75</td>
</tr>
<tr>
<td>小红</td><td>女</td><td>79</td>
</tr>
<tr>
<td>小陆</td><td>男</td><td>92</td>
</tr>
</tbody>
</table>

<table>
<thead>
<tr>
<th>产品</th><th style="text-align:right">价格</th>
</tr>
</thead>
<tbody>
<tr>
<td>Leanote 高级账号</td><td style=
a8c0
"text-align:right">60元/年</td>
</tr>
<tr>
<td>Leanote 超级账号</td><td style="text-align:right">120元/年</td>
</tr>
</tbody>
</table>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  markdown 编辑器