File tree 2 files changed +33
-1
lines changed
packages/@vuepress/markdown
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change
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
+ } )
Original file line number Diff line number Diff line change @@ -32,7 +32,8 @@ module.exports = (markdown = {}) => {
32
32
toc,
33
33
lineNumbers,
34
34
beforeInstantiate,
35
- afterInstantiate
35
+ afterInstantiate,
36
+ plugins
36
37
} = markdown
37
38
38
39
// allow user config slugify
@@ -117,6 +118,13 @@ module.exports = (markdown = {}) => {
117
118
118
119
module . exports . dataReturnable ( md )
119
120
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
+
120
128
// expose slugify
121
129
md . slugify = slugify
122
130
You can’t perform that action at this time.
0 commit comments