File tree Expand file tree Collapse file tree 3 files changed +7773
-3
lines changed Expand file tree Collapse file tree 3 files changed +7773
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ Vuepress-live allows you to make your examples more interactive automatically. F
6
6
7
7
Writing this in your markdown...
8
8
9
- ````
9
+ ```` md
10
10
```vue live
11
11
<button>example</button>
12
12
```
@@ -57,3 +57,46 @@ _.each(anu, a => {
57
57
value: {{ newArray .join (" , " ) }}
58
58
< / div>
59
59
```
60
+
61
+ ## Enable jsx with the jsx flag
62
+
63
+ If your examples are jsx vue components, use an extra jsx flag
64
+
65
+ ```` md
66
+ ```jsx jsx live
67
+ export default {
68
+ render(){
69
+ return <vue-slider
70
+ value={37}
71
+ />
72
+ }
73
+ }
74
+ ```
75
+ ````
76
+
77
+ > ** NOTE** : The jsx flag should always be second after the language. If you use just ` jsx live ` as a flag it will use the standard vue parser.
78
+ > JSX syntax highlighting in markdown is better than vue. You can still use jsx with your normal examples.
79
+
80
+ Without the second jsx flag, vue-live would pick up on the beginnig of the jsx expression and stop parsing there.
81
+ The script would be incomplete.
82
+
83
+ ``` jsx jsx live
84
+ export default {
85
+ data (){
86
+ return {
87
+ value: 37
88
+ }
89
+ },
90
+ render (){
91
+ return (
92
+ < div>
93
+ < vue- slider
94
+ style= {{margin: " 20px 0" }}
95
+ value= {this .value }
96
+ order= {false }
97
+ / >
98
+ < / div>
99
+ )
100
+ }
101
+ }
102
+ ```
Original file line number Diff line number Diff line change @@ -32,8 +32,10 @@ const addVueLive = md => {
32
32
// add this as a prop
33
33
const scr = getScript ( code ) ;
34
34
const requires = getImports ( scr ) . map ( mod => `'${ mod } ': require('${ mod } ')` ) ;
35
- const langClean = lang . split ( " " ) [ 0 ] ;
36
- return `<vue-live :layoutProps="{lang:'${ langClean } '}" :code="\`${ md . utils
35
+ const langArray = lang . split ( " " ) ;
36
+ const langClean = langArray [ 0 ] ;
37
+ const jsx = langArray . length > 2 && langArray [ 1 ] === "jsx" ? "jsx " : "" ; // to enable jsx, we want ```vue jsx live or ```jsx jsx live
38
+ return `<vue-live ${ jsx } :layoutProps="{lang:'${ langClean } '}" :code="\`${ md . utils
37
39
. escapeHtml ( code )
38
40
. replace ( / \` / g, "\\`" )
39
41
. replace ( / \$ / g, "\\$" ) } \`" :requires="{${ requires . join ( "," ) } }"/>`;
You can’t perform that action at this time.
0 commit comments