File tree Expand file tree Collapse file tree 5 files changed +35
-7
lines changed
Expand file tree Collapse file tree 5 files changed +35
-7
lines changed Original file line number Diff line number Diff line change 7474 "svgo" : " ^1.3.2" ,
7575 "svgo-loader" : " ^2.2.2" ,
7676 "vuepress" : " ^1.8.2" ,
77+ "vuepress-plugin-demo-container-v2" : " ^2.3.4" ,
7778 "vuepress-plugin-flowchart" : " ^1.4.3" ,
7879 "vuepress-plugin-redirect" : " ^1.2.5"
7980 }
Original file line number Diff line number Diff line change 11'use strict' ;
22
33module . exports = [
4- require ( './extends' ) ,
5- require ( './commands' ) ,
6- ] ;
4+ 'extends' ,
5+ 'commands' ,
6+ ] . map ( name => {
7+ const item = require ( `./${ name } ` ) ;
8+ if ( ! item . configuration ) {
9+ item . configuration = { } ;
10+ }
11+ if ( ! item . configuration . alias ) {
12+ item . configuration . alias = `${ name . replace ( / \/ / , '_' ) } ` ;
13+ }
14+ return item ;
15+ } ) ;
Original file line number Diff line number Diff line change 44// https://github.com/ravenq/markdown-it-vue/blob/master/src/markdown-it-plugin-echarts.js
55
66module . exports = md => {
7+
78 const fence = md . renderer . rules . fence . bind ( md . renderer . rules ) ;
89 md . renderer . rules . fence = ( ...args ) => {
9- const [ tokens , idx ] = args ;
10+ const [ tokens , idx ] = args ;
1011 const token = tokens [ idx ] ;
11- const rawCode = fence ( ...args ) ;
12- const lang = token . info . trim ( ) ;
1312 const code = token . content ;
13+
14+ const lang = token . info . trim ( ) ;
15+ // 判断该 fence 是否在 :::demo 内
16+ const prevToken = tokens [ idx - 1 ] ;
17+ const isInDemoContainer = prevToken && prevToken . nesting === 1 && prevToken . info . trim ( ) . match ( / ^ d e m o \s * ( .* ) $ / ) ;
18+
19+ const rawCode = fence ( ...args ) ;
1420 let mdMyCode = '' ;
15- if ( [ 'vue' , 'html' ] . includes ( lang ) ) {
21+ if ( [ 'vue' , 'html' ] . includes ( lang ) && ! isInDemoContainer ) {
1622 mdMyCode = `<CodeResult lang="${ lang } " code="${ encodeURIComponent ( code . trim ( ) ) } ">${ code . trim ( ) } </CodeResult>` ;
1723 } else {
1824 mdMyCode = `<CodeResult lang="${ lang } " code="${ encodeURIComponent ( code . trim ( ) ) } "></CodeResult>` ;
1925 }
26+
27+ if ( [ 'vue' , 'html' ] . includes ( lang ) && isInDemoContainer ) {
28+ mdMyCode = `<template slot="highlight">${ mdMyCode } }</template>` ;
29+ }
2030 return rawCode . replace ( '<!--beforeend-->' , `${ mdMyCode } <!--beforeend-->` ) ;
2131 } ;
2232} ;
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ function registerPlugins(ctx) {
4141 '/zh/' : '警告' ,
4242 } ,
4343 } ] ,
44+
45+ // vue-demo
46+ 'demo-container-v2' ,
4447 ] ;
4548
4649 const siteConfig = ctx . siteConfig || { } ;
Original file line number Diff line number Diff line change 1246212462 dependencies:
1246312463 "@vuepress/shared-utils" "^1.2.0"
1246412464
12465+ vuepress-plugin-demo-container-v2@^2.3.4:
12466+ version "2.3.4"
12467+ resolved "https://registry.yarnpkg.com/vuepress-plugin-demo-container-v2/-/vuepress-plugin-demo-container-v2-2.3.4.tgz#80daef15aca102666fb5429a41dadaf7a0d4fa79"
12468+ integrity sha512-xyPocP7U8J0BVlStj8fkeT9Z9c/ScUiPgARg+NyPMFrjxC9I3Ae1DfnHs6cJC4zFB1DeyVLzeWuIaP7Q2d9wng==
12469+
1246512470vuepress-plugin-disqus@^0.2.0:
1246612471 version "0.2.0"
1246712472 resolved "https://registry.yarnpkg.com/vuepress-plugin-disqus/-/vuepress-plugin-disqus-0.2.0.tgz#0a5bde424f81e0185eda36fba23d7ac4cae6ff07"
You can’t perform that action at this time.
0 commit comments