Skip to content

Commit d674424

Browse files
committed
rebase to work with v1.0.0-alpha
1 parent 7491692 commit d674424

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Md } from './util'
2+
import ins from 'markdown-it-ins'
3+
import mark from 'markdown-it-mark'
4+
5+
const mdP = Md().use(ins).use(mark)
6+
// const mdP = Md().set({
7+
// markdown: {
8+
// plugins: ['ins', 'mark']
9+
// }
10+
// })
11+
12+
const asserts = {
13+
'Demo ++inserted++ text.': '<p>Demo <ins>inserted</ins> text.</p>\n',
14+
'Demo ==marked== text.': '<p>Demo <mark>marked</mark> text.</p>\n'
15+
}
16+
17+
describe('plugin', () => {
18+
test('should convert markdown w/ custom plugins', () => {
19+
for (const input in asserts) {
20+
const output = mdP.render(input)
21+
expect(output).toBe(asserts[input])
22+
}
23+
})
24+
})

packages/@vuepress/markdown/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ module.exports = (markdown = {}) => {
3232
toc,
3333
lineNumbers,
3434
beforeInstantiate,
35-
afterInstantiate
35+
afterInstantiate,
36+
plugins
3637
} = markdown
3738

3839
// allow user config slugify
@@ -117,6 +118,13 @@ module.exports = (markdown = {}) => {
117118

118119
module.exports.dataReturnable(md)
119120

121+
if (plugins) {
122+
markdown.plugins.forEach(function (plugin) {
123+
plugin = plugin.replace('markdown-it-', '')
124+
md.use(require(`markdown-it-${plugin}`))
125+
})
126+
}
127+
120128
// expose slugify
121129
md.slugify = slugify
122130

0 commit comments

Comments
 (0)