This repository was archived by the owner on Aug 24, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
packages/h2x-plugin-jsx/src Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,9 @@ const formatElementOpen = jsxElement => {
2020const formatElementClose = jsxElement => `</${ jsxElement . name } >`
2121
2222const formatComment = jsxComment =>
23- `{/*${ jsxComment . text . replace ( '*/' , '* /' ) } */}`
23+ `{/*${ jsxComment . text . replace ( / \* \/ / g , '* /' ) } */}`
2424
25- const formatText = jsxText => jsxText . text
25+ const formatText = jsxText => jsxText . text . replace ( / ` / g , '\\`' )
2626
2727export default {
2828 JSXElement : {
@@ -44,7 +44,7 @@ export default {
4444 JSXText : {
4545 enter ( path , generator ) {
4646 const trimmedText = path . node . text . trim ( )
47- if ( trimmedText ) generator . writeLine ( formatText ( path . node ) )
47+ if ( trimmedText ) generator . writeLine ( `{\` ${ formatText ( path . node ) } \`}` )
4848 } ,
4949 } ,
5050}
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ describe('transformJsx', () => {
77 <?xml version="1.0" encoding="UTF-8"?>
88 <svg width="88px" height="88px" viewBox="0 0 88 88" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
99 <!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
10+ <style>
11+ .test {
12+ fill: red;
13+ }
14+ </style>
1015 <title>Dismiss</title>
1116 <desc>Created with Sketch.</desc>
1217 <defs>
@@ -57,11 +62,16 @@ describe('transformJsx', () => {
5762 . toBe ( `{/*?xml version="1.0" encoding="UTF-8"?*/}
5863<svg width="88px" height="88px" viewBox="0 0 88 88" version={1.1} xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink">
5964 {/*Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch*/}
65+ <style>
66+ {\`.test {
67+ fill: red;
68+ }\`}
69+ </style>
6070 <title>
61- Dismiss
71+ {\` Dismiss\`}
6272 </title>
6373 <desc>
64- Created with Sketch.
74+ {\` Created with Sketch.\`}
6575 </desc>
6676 <defs>
6777 <linearGradient id="a" x1="50%" x2="50%" y1="0%" y2="100%">
You can’t perform that action at this time.
0 commit comments