Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cef64e6

Browse filesBrowse files
spencerHTxuze
and
xuze
authored
fix(markdown): replace double quotation marks in classname(fix #3152) (#3154)
Co-authored-by: xuze <xuze@bytedance.com>
1 parent 9044f14 commit cef64e6
Copy full SHA for cef64e6

File tree

4 files changed

+21
-1
lines changed
Filter options

4 files changed

+21
-1
lines changed

‎packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap

Copy file name to clipboardExpand all lines: packages/@vuepress/markdown/__tests__/__snapshots__/preWrapper.spec.js.snap
+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`preWrapper should wrap code with double quotation marks 1`] = `
4+
<!--beforebegin-->
5+
<div class="language-js name='marks' extra-class">
6+
<!--afterbegin--><pre><code class="language-js">new Vue()
7+
</code></pre>
8+
<!--beforeend-->
9+
</div>
10+
<!--afterend-->
11+
`;
12+
313
exports[`preWrapper should wrap code with quadruple space 1`] = `
414
<!--beforebegin-->
515
<div class="language- extra-class">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``` js name="marks"
2+
new Vue()
3+
```

‎packages/@vuepress/markdown/__tests__/preWrapper.spec.js

Copy file name to clipboardExpand all lines: packages/@vuepress/markdown/__tests__/preWrapper.spec.js
+6
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@ describe('preWrapper', () => {
2121
expect(output1 === output2).toBe(false)
2222
expect(output2).toMatchSnapshot()
2323
})
24+
25+
test('should wrap code with double quotation marks', () => {
26+
const input = getFragment(__dirname, 'code-prewrapper-with-double-quotation-marks.md')
27+
const output2 = mdP.render(input)
28+
expect(output2).toMatchSnapshot()
29+
})
2430
})

‎packages/@vuepress/markdown/lib/preWrapper.js

Copy file name to clipboardExpand all lines: packages/@vuepress/markdown/lib/preWrapper.js
+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = md => {
1212
const [tokens, idx] = args
1313
const token = tokens[idx]
1414
const rawCode = wrapped(...args)
15-
return `<!--beforebegin--><div class="language-${token.info.trim()} extra-class">`
15+
const tokenInfo = token.info.trim().replace(/\"/g, '\'')
16+
return `<!--beforebegin--><div class="language-${tokenInfo} extra-class">`
1617
+ `<!--afterbegin-->${rawCode}<!--beforeend--></div><!--afterend-->`
1718
}
1819
const { fence, code_block: codeBlock } = md.renderer.rules

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.