Markdown: Basics (快速入门)(2)

参考形式的链接让你可以为链接定一个名称,之后你可以在文件的其他地方定义该链接的内容:

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

输出 HTML 为:

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

title 属性是选择性的,链接名称可以用字母、数字和空格,但是不分大小写:

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

输出 HTML 为:

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

图片的语法和链接很像。

行内形式(title 是选择性的):

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

参考形式:

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

上面两种方法都会输出 HTML 为:

<img src="https://www.linuxidc.com/path/to/img.jpg" alt="alt text" title="Title" /> 代码

在一般的段落文字中,你可以使用反引号 ` 来标记代码区段,区段内的 &、< 和 > 都会被自动的转换成 HTML 实体,这项特性让你可以很容易的在代码区段内插入 HTML 码:

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

输出 HTML 为:

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

如果要建立一个已经格式化好的代码区块,只要每行都缩进 4 个空格或是一个 tab 就可以了,而 &、< 和 > 也一样会自动转成 HTML 实体。

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>

输出 HTML 为:

<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; </code></pre>

本文永久更新链接地址

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/17067.html