Markdown语法 段落内代码

3040次阅读  |  发布于5年以前

如果要标记一小段行内代码,你可以用反引号把它包起来(\'\'),例如:

Use the `printf()` function.

会产生:

<p>Use the <code>printf()</code> function.</p>

如果要在代码区段内插入反引号,你可以用多个反引号来开启和结束代码区段:

``There is a literal backtick (`) here.``

这段语法会产生:

<p><code>There is a literal backtick (`) here.</code></p>

代码区段的起始和结束端都可以放入一个空白,起始端后面一个,结束端前面一个,这样你就可以在区段的一开始就插入反引号:

A single backtick in a code span: `` ` ``

A backtick-delimited string in a code span: `` `foo` ``

会产生:

<p>A single backtick in a code span: <code>`</code></p>

<p>A backtick-delimited string in a code span: <code>`foo`</code></p>

在代码区段内,& 和方括号都会被转成 HTML 实体,这样会比较容易插入 HTML 原始码,Markdown 会把下面这段:

Please don't use any `<blink>` tags.

转为:

<p>Please don't use any <code><blink></code> tags.</p>

你也可以这样写:

`—` is the decimal-encoded equivalent of `—`.

以产生:

<p><code>&#8212;</code> is the decimal-encoded
equivalent of <code>&mdash;</code>.</p>

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8