@@ -33,7 +33,7 @@ const processor = unified()
33
33
// add `v-pre` for code blocks
34
34
. use (
35
35
( ) =>
36
- function transformer ( tree ) {
36
+ function transformer ( tree ) {
37
37
const pres = select ( tree , 'element[tagName=pre]' )
38
38
pres . forEach ( pre => {
39
39
const { children, properties } = pre
@@ -55,25 +55,29 @@ const processor = unified()
55
55
const compileTemplate = require ( './compileTemplate' )
56
56
const styleInjectFile = join ( __dirname , 'styleInject.js' )
57
57
58
- module . exports = function process ( path , option , callback ) {
58
+ module . exports = function process ( path , option , callback ) {
59
59
if ( typeof option === 'function' ) {
60
60
callback = option
61
61
}
62
62
63
63
const file = vfile . readSync ( path )
64
64
file . userOption = option
65
65
// 与 vuepress-plugin-playground 整合
66
- file . contents = file . contents . toString ( ) . replace ( / ` ` ` ( h t m l | v u e ) \s + @ ( p l a y g r o u n d | d e m o ) \s / g, m => {
67
- return m . replace ( / @ ( p l a y g r o u n d | d e m o ) / , '' )
68
- } )
69
- processor . process ( file , function ( err , file ) {
66
+ file . contents = file . contents
67
+ . toString ( )
68
+ . replace ( / ` ` ` ( h t m l | v u e ) \s + @ ( p l a y g r o u n d | d e m o ) \s / g, m => {
69
+ return m . replace ( / @ ( p l a y g r o u n d | d e m o ) / , '' )
70
+ } )
71
+ processor . process ( file , function ( err , file ) {
70
72
if ( err ) {
71
73
return callback ( err )
72
74
}
73
75
74
76
if ( file ) {
75
77
const { components, styles } = file . data
76
- const content = `<article class="markdown-body">${ file . contents } </article>`
78
+ const content = `<article class="markdown-body">${
79
+ file . contents
80
+ } </article>`
77
81
const { render, staticRenderFns } = compileTemplate ( content )
78
82
79
83
file . extname = '.js'
0 commit comments