Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit cef64e6

Browse 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

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
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">
Lines changed: 3 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /