diff --git a/packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap b/packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap index 562cc6c467..9c8d44c49d 100644 --- a/packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap +++ b/packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap @@ -1,5 +1,15 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`preWrapper should wrap code with double quotation marks 1`] = ` + +
+
new Vue()
+
+ +
+ +`; + exports[`preWrapper should wrap code with quadruple space 1`] = `
diff --git a/packages/@vuepress/markdown/__tests__/fragments/code-prewrapper-with-double-quotation-marks.md b/packages/@vuepress/markdown/__tests__/fragments/code-prewrapper-with-double-quotation-marks.md new file mode 100644 index 0000000000..212a8d56a0 --- /dev/null +++ b/packages/@vuepress/markdown/__tests__/fragments/code-prewrapper-with-double-quotation-marks.md @@ -0,0 +1,3 @@ +``` js name="marks" +new Vue() +``` diff --git a/packages/@vuepress/markdown/__tests__/preWrapper.spec.js b/packages/@vuepress/markdown/__tests__/preWrapper.spec.js index 9ba0c482a4..37c0f9364c 100644 --- a/packages/@vuepress/markdown/__tests__/preWrapper.spec.js +++ b/packages/@vuepress/markdown/__tests__/preWrapper.spec.js @@ -21,4 +21,10 @@ describe('preWrapper', () => { expect(output1 === output2).toBe(false) expect(output2).toMatchSnapshot() }) + + test('should wrap code with double quotation marks', () => { + const input = getFragment(__dirname, 'code-prewrapper-with-double-quotation-marks.md') + const output2 = mdP.render(input) + expect(output2).toMatchSnapshot() + }) }) diff --git a/packages/@vuepress/markdown/lib/preWrapper.js b/packages/@vuepress/markdown/lib/preWrapper.js index 4190fe11a1..7e5af312c3 100644 --- a/packages/@vuepress/markdown/lib/preWrapper.js +++ b/packages/@vuepress/markdown/lib/preWrapper.js @@ -12,7 +12,8 @@ module.exports = md => { const [tokens, idx] = args const token = tokens[idx] const rawCode = wrapped(...args) - return `
` + const tokenInfo = token.info.trim().replace(/\"/g, '\'') + return `
` + `${rawCode}
` } const { fence, code_block: codeBlock } = md.renderer.rules