本文档规定 WordPress 文档编写中应遵循的 Markdown 语法规范,统一标题、强调、链接、列表、表格与代码示例等常用元素的写法,帮助开发者产出结构一致、便于解析和渲染的文档内容。
# 到 ###### 表示 h1–h6;其中 h1–h4 会自动加入目录(Table of Contents)。_italic_,双星号表示加粗 **bold**,双波浪线表示删除线 ~~text~~。[WordPress](https://wordpress.org/)。>,使用双层 >> 表示进一步缩进的引用。-,子项缩进两个空格;有序列表使用数字加 .。---;表格使用管道符 | 与分隔行构建。行内代码:`inline code`
围栏代码块(JavaScript):
```javascript
var foo = function (bar) {
return bar++;
};
console.log(foo(5));
```
围栏代码块(PHP):
```php
$array = array(
"foo" => "bar",
"bar" => "foo",
);
```
围栏代码块(JSON):
```json
{
"firstName": "John",
"lastName": "Smith"
}
``` # Heading h1
## Heading h2
### Heading h3
#### Heading h4
##### Heading h5
###### Heading h6
Note: h1 – h4 items will be automatically added to the Table of Contents.
Wrap text with a single _ for Italic text:
This is _italic text_.
Wrap text with double ** for Bold text:
This is **bold text**.
Wrap text with double ~~ for strikethrough text:
This is ~~strikethrough~~ text.
Wrap the title in square brackets [title] immediately followed by the URL in (https://example.com):
[WordPress](https://wordpress.org/)
Use > for blockquotes, double >> to further indent:
> Blockquote
>> Indented Blockquote
Use - for unordered lists, and intent two spaces for list subitems:
- List
- List
- List
- List
Use numbered items followed by a .:
1. One
2. Two
3. Three
Use --- for a horizontal rules:
---
| A | B |
| ----- | ----- |
| Alpha | Bravo |
Wrap inline code with single ``` backticks:
```
This is `inline code` wrapped with backticks
```
When documenting an example, use the markdown ``` code block to demarcate the beginning and end of the code sample:
```javascript
var foo = function (bar) {
return bar++;
};
console.log(foo(5));
```
```json
{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
```
```css
foo {
padding: 5px;
margin-right: 3px;
}
.bar {
background-color: #f00;
}
```
```scss
foo {
padding: 5px;
margin-right: 3px;
}
.bar {
background-color: #f00;
}
```
```html
<span class="my-class">Example</span>
```
```php
$array = array(
"foo" => "bar",
"bar" => "foo",
);
```
```md
This is _italic text_. This is **bold text**.
```