diff --git a/README.md b/README.md index 3efe053..1180211 100644 --- a/README.md +++ b/README.md @@ -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 }) ``` @@ -47,7 +47,7 @@ remark().use(pangu, { ```js { text: true, - inlineCode: true, + inlineCode: false, link: true, image: true, imageReference: true, diff --git a/defaults.js b/defaults.js index 37aaa93..5971125 100644 --- a/defaults.js +++ b/defaults.js @@ -2,7 +2,7 @@ module.exports = { text: true, - inlineCode: true, + inlineCode: false, link: true, image: true, imageReference: true, diff --git a/tests/inline-code/__snapshots__/run.spec.js.snap b/tests/inline-code/__snapshots__/run.spec.js.snap index 867a0a9..7a2a587 100644 --- a/tests/inline-code/__snapshots__/run.spec.js.snap +++ b/tests/inline-code/__snapshots__/run.spec.js.snap @@ -1,13 +1,29 @@ // 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\` `; @@ -15,9 +31,25 @@ 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\` `; diff --git a/tests/inline-code/inline-code.md b/tests/inline-code/inline-code.md index 07d54ef..9fe3729 100644 --- a/tests/inline-code/inline-code.md +++ b/tests/inline-code/inline-code.md @@ -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` diff --git a/tests/inline-code/run.spec.js b/tests/inline-code/run.spec.js index c56df4c..ce226db 100644 --- a/tests/inline-code/run.spec.js +++ b/tests/inline-code/run.spec.js @@ -1,4 +1,4 @@ runSpec(__dirname) runSpec(__dirname, { - inlineCode: false -}) \ No newline at end of file + inlineCode: true +}) diff --git a/tests/options/__snapshots__/run.spec.js.snap b/tests/options/__snapshots__/run.spec.js.snap index 6580c3d..26ba032 100644 --- a/tests/options/__snapshots__/run.spec.js.snap +++ b/tests/options/__snapshots__/run.spec.js.snap @@ -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 吧")