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 => {
20
20
const formatElementClose = jsxElement => `</${ jsxElement . name } >`
21
21
22
22
const formatComment = jsxComment =>
23
- `{/*${ jsxComment . text . replace ( '*/' , '* /' ) } */}`
23
+ `{/*${ jsxComment . text . replace ( / \* \/ / g , '* /' ) } */}`
24
24
25
- const formatText = jsxText => jsxText . text
25
+ const formatText = jsxText => jsxText . text . replace ( / ` / g , '\\`' )
26
26
27
27
export default {
28
28
JSXElement : {
@@ -44,7 +44,7 @@ export default {
44
44
JSXText : {
45
45
enter ( path , generator ) {
46
46
const trimmedText = path . node . text . trim ( )
47
- if ( trimmedText ) generator . writeLine ( formatText ( path . node ) )
47
+ if ( trimmedText ) generator . writeLine ( `{\` ${ formatText ( path . node ) } \`}` )
48
48
} ,
49
49
} ,
50
50
}
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ describe('transformJsx', () => {
7
7
<?xml version="1.0" encoding="UTF-8"?>
8
8
<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">
9
9
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
10
+ <style>
11
+ .test {
12
+ fill: red;
13
+ }
14
+ </style>
10
15
<title>Dismiss</title>
11
16
<desc>Created with Sketch.</desc>
12
17
<defs>
@@ -57,11 +62,16 @@ describe('transformJsx', () => {
57
62
. toBe ( `{/*?xml version="1.0" encoding="UTF-8"?*/}
58
63
<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">
59
64
{/*Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch*/}
65
+ <style>
66
+ {\`.test {
67
+ fill: red;
68
+ }\`}
69
+ </style>
60
70
<title>
61
- Dismiss
71
+ {\` Dismiss\`}
62
72
</title>
63
73
<desc>
64
- Created with Sketch.
74
+ {\` Created with Sketch.\`}
65
75
</desc>
66
76
<defs>
67
77
<linearGradient id="a" x1="50%" x2="50%" y1="0%" y2="100%">
You can’t perform that action at this time.
0 commit comments