50

basic grammar

code

If you only want to highlight a certain function name or keyword in the statement, you can use backticks `function_name()` achieve this.

Usually the editor adapts the appropriate highlighting method according to the code fragment, but you can also ` and specify a language, for example:

```javascript
$(document).ready(function () {
    alert('hello world');
});
```

You can also use a 4-space indent and paste the code to achieve the same effect:

····def g(x):
····    yield from range(x, 0, -1)
····yield from range(x)

If you don't need code highlighting, you can disable it with:

```nohighlight
// 代码内容
```

title

When the content of the article is large, you can use the title to segment:

## 大标题

### 中标题

#### 小标题

bold, italic

**粗体文本**

*斜体文本*

***粗斜体文本***

Link

Most used link:

文字链接 [SegmentFault](https://segmentfault.com)
网址链接 <https://segmentfault.com>

Advanced Links:

这个链接用 1 作为网址变量 [Google][1]
这个链接用 yahoo 作为网址变量 [Yahoo][yahoo]
然后在文档的结尾为变量赋值(网址)

[1]: http://www.google.com
[yahoo]: http://www.yahoo.com

list

unordered list

* 列表文本前使用 `星号 + 空格`
+ 列表文本前使用 `加号 + 空格`
- 列表文本前使用 `减号 + 空格`

ordered list

1. 列表前使用 `数字 + . + 空格`
2. 我们会自动帮你添加数字
7. 不用担心数字不对,显示的时候我们会自动把这行的 7 纠正为 3

List nesting

1. 列出所有元素:

···- 无序列表元素 A
······1. 元素 A 的有序子列表
······2. 元素 A 的有序子列表
···- 前面加三个空格

2. 列表里的多段换行:

···新的一个段落
···这样换行,整体的格式不会乱

3. 列表里引用:

···> 引用内容
···> 引用内容

4. 列表里代码段:

···```
···前面三个空格,之后用三个反引号形成代码块
···```

·······或者直接空七个,引入代码块

quote

common citation

> 引用文本前使用 `大于号 + 空格`
> 折行可以不加,新起一行都要加上哦

nested references

> 最外层引用
> > 第二层引用
> > > 可以嵌套很多层

Nested Lists in References

> - 这是引用里嵌套的一个列表
> - 还可以有子列表
> ··- 子列表
> ··- 子列表

Nested code blocks in quotes

> ····同样的,在前面加四个空格形成代码块
>  
> ```
> 或者使用三个反引号形成代码块
> ```

picture

The difference from the link method is that an exclamation mark ! is added in front. Does this make it easier to remember?

![图片名称](http://图片网址)

Of course, you can also use variables for image URLs like URLs

这个链接用 1 作为网址变量 [Google][1].
然后在文档的结尾位变量赋值(网址)

[1]: http://www.google.com/logo.png

newline

To start a new line, just add 2 spaces at the end of the current line:

在当前行的结尾加 2 个空格··
这行就会新起一行

If you want to start a new paragraph, just leave a line blank.

delimiter

If you have the habit of writing dividing lines, you can start a new line and enter three minus signs - . When there are paragraphs before and after, please leave a line:

前面的段落

---

后面的段落

Advanced Tips

Inline HTML elements

Currently only supports HTML element effects in some paragraphs, including <kdb> <b> <i> <em> <sup> <sub> <br> :

key display

使用 <kbd>Enter</kbd> 键换行

code block

使用 <pre></pre> 元素同样可以形成代码块

bold italic

<b>Markdown 在此处同样适用,如 **加粗**</b>

symbol escape

If you need to use markdown symbols in your description, such as _ , # , * etc., but you don't want it to be escaped, you can add a backslash before these symbols, such as \_ , \# , \* to avoid it.

\*不想这里的文本变斜体\*
\*\*不想这里的文本被加粗\*\*

expand

Support jsfiddle , gist , codepen , fill in the URL directly, after which a preview will be automatically added. Click to expand the relevant content:

https://jsfiddle.net/{{ name }}/{{ id }}/
https://gist.github.com/{{ name }}/{{ id }}
https://codepen.io/{{ name }}/pen/{{ id }}

footnote

Markdown[^1] 可以提高排版效率,并将文本转换为 HTML[^html]

[^1]: Markdown 是一种纯文本标记语言
[^html]: HyperText Markup Language 超文本标记语言

formula

When you need to insert a mathematical formula in the editor, you can use two dollar $$ wrap the mathematical formula in TeX or LaTeX format. Once submitted, the Q&A and Article pages will load Mathjax as needed to render the math. like:

$$ E=mc^2 $$

$$
E=mc^2
$$

If you want to use an inline formula, you can wrap it \\( and \\)

\\( E=mc^2 \\)

fenbox
6.8k 声望933 粉丝

主业设计,副业写代码