Skip to content

Commit

Permalink
feat: disable pangu inline code by default (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffun authored Oct 25, 2020
1 parent a68847b commit b419bfe
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 12 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ remark().use(pangu).process(doc, (err, file) => {

### Options

可以通过指定部分选项为 `false` 以跳过部分节点的排版处理
可以通过设置 options 控制是否处理不同类型的 Markdown 节点。

e.g. 不处理 `inline code` 的内容
例如,此插件默认不处理 `inline code`,可以设置 `inlineCode: true` 开启处理:

```js
remark().use(pangu, {
inlineCode: false
inlineCode: true
})
```

Expand All @@ -47,7 +47,7 @@ remark().use(pangu, {
```js
{
text: true,
inlineCode: true,
inlineCode: false,
link: true,
image: true,
imageReference: true,
Expand Down
2 changes: 1 addition & 1 deletion defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = {
text: true,
inlineCode: true,
inlineCode: false,
link: true,
image: true,
imageReference: true,
Expand Down
38 changes: 35 additions & 3 deletions tests/inline-code/__snapshots__/run.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`inline-code.md with options: {"inlineCode":false}: inline-code.md 1`] = `
exports[`inline-code.md with options: {"inlineCode":true}: inline-code.md 1`] = `
\`abc123\`
\`我a我1\`
\`new Date().getDate()\`
\`JSON.stringify({'test': '值test'})\`
\`./新建文件夹/node_modules/remark-pangu/index.js\`
\`printf("a = %d, b = %d\\n", a, b); // 打印 a 和 b\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`abc123\`
\`我a我1\`
\`我 a 我 1\`
\`new Date().getDate()\`
\`JSON.stringify ({'test': ' 值 test'})\`
\`./ 新建文件夹 /node_modules/remark-pangu/index.js\`
\`printf ("a = % d, b = % d\\n", a, b); // 打印 a 和 b\`
`;

exports[`inline-code.md with options: undefined: inline-code.md 1`] = `
\`abc123\`
\`我a我1\`
\`new Date().getDate()\`
\`JSON.stringify({'test': '值test'})\`
\`./新建文件夹/node_modules/remark-pangu/index.js\`
\`printf("a = %d, b = %d\\n", a, b); // 打印 a 和 b\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`abc123\`
\`我 a 我 1\`
\`我a我1\`
\`new Date().getDate()\`
\`JSON.stringify({'test': '值test'})\`
\`./新建文件夹/node_modules/remark-pangu/index.js\`
\`printf("a = %d, b = %d\\n", a, b); // 打印 a 和 b\`
`;
8 changes: 8 additions & 0 deletions tests/inline-code/inline-code.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
`abc123`

`我a我1`

`new Date().getDate()`

`JSON.stringify({'test': '值test'})`

`./新建文件夹/node_modules/remark-pangu/index.js`

`printf("a = %d, b = %d\n", a, b); // 打印 a 和 b`
4 changes: 2 additions & 2 deletions tests/inline-code/run.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
runSpec(__dirname)
runSpec(__dirname, {
inlineCode: false
})
inlineCode: true
})
4 changes: 2 additions & 2 deletions tests/options/__snapshots__/run.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ baz: lol
段落 b**粗体 b 粗体**段落
段落\`行内 code block 代码段\`行内代码段
段落\`行内code block代码段\`行内代码段
段落~~删除 delete me 线~~段落
段落 c**粗体 b 粗体_强调 a 强调_粗体\`行内 code block 代码段\`~~删除 delete me 线~~**段落
段落 c**粗体 b 粗体_强调 a 强调_粗体\`行内code block代码段\`~~删除 delete me 线~~**段落
链接[关于 about me 我]\\(http:// 中文 some link 链接 "我的天 a 吧")
Expand Down

0 comments on commit b419bfe

Please sign in to comment.