Skip to content

Commit fef7990

Browse files
committed
Escape backticks
1 parent 3e503bc commit fef7990

File tree

3 files changed

+109
-9
lines changed

3 files changed

+109
-9
lines changed

fixtures/example.md

Lines changed: 107 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,113 @@
1-
# h1
1+
# Header 1
22

3-
## h2
3+
## Header 2
44

5-
### h3
5+
### Header 3 ### (Hashes on right are optional)
66

7-
#### h4
7+
## Markdown plus h2 with a custom ID ## {#id-goes-here}
88

9-
##### h5
9+
[Link back to H2](#id-goes-here)
1010

11-
###### h6
11+
```js
12+
var x = "string";
13+
function f() {
14+
return x;
15+
}
16+
```
1217

13-
Hello.
18+
<!-- html madness -->
19+
<div class="custom-class" markdown="1">
20+
<div>
21+
nested div
22+
</div>
23+
<script type='text/x-koka'>
24+
function( x: int ) { return x*x; }
25+
</script>
26+
This is a div _with_ underscores
27+
and a & <b class="bold">bold</b> element.
28+
<style>
29+
body { font: "Consolas" }
30+
</style>
31+
</div>
32+
33+
- Bullet lists are easy too
34+
35+
* Another one
36+
37+
- Another one
38+
39+
This is a paragraph, which is text surrounded by
40+
whitespace. Paragraphs can be on one
41+
line (or many), and can drone on for hours.
42+
43+
Now some inline markup like _italics_, **bold**,
44+
and `code()`. Note that underscores
45+
in_words_are ignored.
46+
47+
```application/json
48+
{ value: ["or with a mime type"] }
49+
```
50+
51+
> Blockquotes are like quoted text in email replies
52+
>
53+
> > And, they can be nested
54+
55+
1. A numbered list
56+
2. Which is numbered
57+
3. With periods and a space
58+
59+
And now some code:
60+
61+
// Code is just text indented a bit
62+
which(is_easy) to_remember();
63+
64+
And a block
65+
66+
```
67+
// Markdown extra adds un-indented code blocks too
68+
69+
if (this_is_more_code == true && !indented) {
70+
// tild wrapped code blocks, also not indented
71+
}
72+
```
73+
74+
Text with
75+
two trailing spaces
76+
(on the right)
77+
can be used
78+
for things like poems
79+
80+
### Horizontal rules
81+
82+
---
83+
84+
---
85+
86+
---
87+
88+
![picture alt](/images/photo.jpeg "Title is optional")
89+
90+
## Markdown plus tables
91+
92+
| Header | Header | Right |
93+
| ------ | ------ | ----: |
94+
| Cell | Cell | $10 |
95+
| Cell | Cell | $20 |
96+
97+
- Outer pipes on tables are optional
98+
- Colon used for alignment (right versus left)
99+
100+
## Markdown plus definition lists
101+
102+
Bottled water
103+
: $ 1.25
104+
: $ 1.55 (Large)
105+
106+
Milk
107+
Pop
108+
: $ 1.75
109+
110+
- Multiple definitions and terms are possible
111+
- Definitions can include multiple paragraphs too
112+
113+
\*[ABBR]: Markdown plus abbreviations (produces an <abbr> tag)

src/plugin/__snapshots__/metro.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ __d(function(g,r,i,a,m,e,d){'use strict';var t=r(d[0]),n=r(d[1]),l=r(d[2]);funct
117117
__d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},9,[10]);
118118
__d(function(g,r,i,a,m,e,d){'use strict';var n,t,o,l,u;if(\\"undefined\\"==typeof window||\\"function\\"!=typeof MessageChannel){var s=null,c=null,f=function n(){if(null!==s)try{var t=e.unstable_now();s(!0,t),s=null}catch(t){throw setTimeout(n,0),t}},b=Date.now();e.unstable_now=function(){return Date.now()-b},n=function(t){null!==s?setTimeout(n,0,t):(s=t,setTimeout(f,0))},t=function(n,t){c=setTimeout(n,t)},o=function(){clearTimeout(c)},l=function(){return!1},u=e.unstable_forceFrameRate=function(){}}else{var p=window.performance,v=window.Date,w=window.setTimeout,y=window.clearTimeout;if(\\"undefined\\"!=typeof console){var _=window.cancelAnimationFrame;\\"function\\"!=typeof window.requestAnimationFrame&&console.error(\\"This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\\"),\\"function\\"!=typeof _&&console.error(\\"This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills\\")}if(\\"object\\"==typeof p&&\\"function\\"==typeof p.now)e.unstable_now=function(){return p.now()};else{var h=v.now();e.unstable_now=function(){return v.now()-h}}var k=!1,T=null,x=-1,P=5,F=0;l=function(){return e.unstable_now()>=F},u=function(){},e.unstable_forceFrameRate=function(n){0>n||125<n?console.error(\\"forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported\\"):P=0<n?Math.floor(1e3/n):5};var I=new MessageChannel,M=I.port2;I.port1.onmessage=function(){if(null!==T){var n=e.unstable_now();F=n+P;try{T(!0,n)?M.postMessage(null):(k=!1,T=null)}catch(n){throw M.postMessage(null),n}}else k=!1},n=function(n){T=n,k||(k=!0,M.postMessage(null))},t=function(n,t){x=w(function(){n(e.unstable_now())},t)},o=function(){y(x),x=-1}}function C(n,t){var o=n.length;n.push(t);n:for(;;){var l=o-1>>>1,u=n[l];if(!(void 0!==u&&0<q(u,t)))break n;n[l]=t,n[o]=u,o=l}}function A(n){return void 0===(n=n[0])?null:n}function L(n){var t=n[0];if(void 0!==t){var o=n.pop();if(o!==t){n[0]=o;n:for(var l=0,u=n.length;l<u;){var s=2*(l+1)-1,c=n[s],f=s+1,b=n[f];if(void 0!==c&&0>q(c,o))void 0!==b&&0>q(b,c)?(n[l]=b,n[f]=o,l=f):(n[l]=c,n[s]=o,l=s);else{if(!(void 0!==b&&0>q(b,o)))break n;n[l]=b,n[f]=o,l=f}}}return t}return null}function q(n,t){var o=n.sortIndex-t.sortIndex;return 0!==o?o:n.id-t.id}var D=[],R=[],j=1,E=null,N=3,B=!1,U=!1,W=!1;function Y(n){for(var t=A(R);null!==t;){if(null===t.callback)L(R);else{if(!(t.startTime<=n))break;L(R),t.sortIndex=t.expirationTime,C(D,t)}t=A(R)}}function z(o){if(W=!1,Y(o),!U)if(null!==A(D))U=!0,n(G);else{var l=A(R);null!==l&&t(z,l.startTime-o)}}function G(n,u){U=!1,W&&(W=!1,o()),B=!0;var s=N;try{for(Y(u),E=A(D);null!==E&&(!(E.expirationTime>u)||n&&!l());){var c=E.callback;if(null!==c){E.callback=null,N=E.priorityLevel;var f=c(E.expirationTime<=u);u=e.unstable_now(),\\"function\\"==typeof f?E.callback=f:E===A(D)&&L(D),Y(u)}else L(D);E=A(D)}if(null!==E)var b=!0;else{var p=A(R);null!==p&&t(z,p.startTime-u),b=!1}return b}finally{E=null,N=s,B=!1}}function H(n){switch(n){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var J=u;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(n){n.callback=null},e.unstable_continueExecution=function(){U||B||(U=!0,n(G))},e.unstable_getCurrentPriorityLevel=function(){return N},e.unstable_getFirstCallbackNode=function(){return A(D)},e.unstable_next=function(n){switch(N){case 1:case 2:case 3:var t=3;break;default:t=N}var o=N;N=t;try{return n()}finally{N=o}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=J,e.unstable_runWithPriority=function(n,t){switch(n){case 1:case 2:case 3:case 4:case 5:break;default:n=3}var o=N;N=n;try{return t()}finally{N=o}},e.unstable_scheduleCallback=function(l,u,s){var c=e.unstable_now();if(\\"object\\"==typeof s&&null!==s){var f=s.delay;f=\\"number\\"==typeof f&&0<f?c+f:c,s=\\"number\\"==typeof s.timeout?s.timeout:H(l)}else s=H(l),f=c;return l={id:j++,callback:u,priorityLevel:l,startTime:f,expirationTime:s=f+s,sortIndex:-1},f>c?(l.sortIndex=f,C(R,l),null===A(D)&&l===A(R)&&(W?o():W=!0,t(z,f-c))):(l.sortIndex=s,C(D,l),U||B||(U=!0,n(G))),l},e.unstable_shouldYield=function(){var n=e.unstable_now();Y(n);var t=A(D);return t!==E&&null!==E&&null!==t&&null!==t.callback&&t.startTime<=n&&t.expirationTime<E.expirationTime||l()},e.unstable_wrapCallback=function(n){var t=N;return function(){var o=N;N=t;try{return n.apply(this,arguments)}finally{N=o}}}},10,[]);
119119
__d(function(g,r,i,a,m,e,d){\\"use strict\\";var t=r(d[0]);Object.defineProperty(e,\\"__esModule\\",{value:!0}),e.default=void 0;var u=t(r(d[1]));e.default=function(){return u.default.createElement(\\"div\\",{style:{background:'red',width:'100vw',height:'100vh'}},\\"hoge\\")}},11,[1,2]);
120-
__d(function(g,r,i,a,m,e,d){\\"use strict\\";var n=r(d[0]);Object.defineProperty(e,\\"__esModule\\",{value:!0}),e.default=void 0;var t=n(r(d[1]));function u(){var n=(0,t.default)([\\"# h1\\\\n\\\\n## h2\\\\n\\\\n### h3\\\\n\\\\n#### h4\\\\n\\\\n##### h5\\\\n\\\\n###### h6\\\\n\\\\nHello.\\\\n\\"]);return u=function(){return n},n}var f=String.raw(u());e.default=f},12,[1,13]);
120+
__d(function(g,r,i,a,m,e,d){\\"use strict\\";var n=r(d[0]);Object.defineProperty(e,\\"__esModule\\",{value:!0}),e.default=void 0;var t=n(r(d[1]));function o(){var n=(0,t.default)([\\"# Header 1\\\\n\\\\n## Header 2\\\\n\\\\n### Header 3 ### (Hashes on right are optional)\\\\n\\\\n## Markdown plus h2 with a custom ID ## {#id-goes-here}\\\\n\\\\n[Link back to H2](#id-goes-here)\\\\n\\\\n\`\`\`js\\\\nvar x = \\\\\\"string\\\\\\";\\\\nfunction f() {\\\\n return x;\\\\n}\\\\n\`\`\`\\\\n\\\\n\\\\x3c!-- html madness --\\\\x3e\\\\n<div class=\\\\\\"custom-class\\\\\\" markdown=\\\\\\"1\\\\\\">\\\\n <div>\\\\n nested div\\\\n </div>\\\\n <script type='text/x-koka'>\\\\n function( x: int ) { return x*x; }\\\\n <\\\\/script>\\\\n This is a div _with_ underscores\\\\n and a & <b class=\\\\\\"bold\\\\\\">bold</b> element.\\\\n <style>\\\\n body { font: \\\\\\"Consolas\\\\\\" }\\\\n </style>\\\\n</div>\\\\n\\\\n- Bullet lists are easy too\\\\n\\\\n* Another one\\\\n\\\\n- Another one\\\\n\\\\nThis is a paragraph, which is text surrounded by\\\\nwhitespace. Paragraphs can be on one\\\\nline (or many), and can drone on for hours.\\\\n\\\\nNow some inline markup like _italics_, **bold**,\\\\nand \`code()\`. Note that underscores\\\\nin_words_are ignored.\\\\n\\\\n\`\`\`application/json\\\\n { value: [\\\\\\"or with a mime type\\\\\\"] }\\\\n\`\`\`\\\\n\\\\n> Blockquotes are like quoted text in email replies\\\\n>\\\\n> > And, they can be nested\\\\n\\\\n1. A numbered list\\\\n2. Which is numbered\\\\n3. With periods and a space\\\\n\\\\nAnd now some code:\\\\n\\\\n // Code is just text indented a bit\\\\n which(is_easy) to_remember();\\\\n\\\\nAnd a block\\\\n\\\\n\`\`\`\\\\n// Markdown extra adds un-indented code blocks too\\\\n\\\\nif (this_is_more_code == true && !indented) {\\\\n // tild wrapped code blocks, also not indented\\\\n}\\\\n\`\`\`\\\\n\\\\nText with\\\\ntwo trailing spaces\\\\n(on the right)\\\\ncan be used\\\\nfor things like poems\\\\n\\\\n### Horizontal rules\\\\n\\\\n---\\\\n\\\\n---\\\\n\\\\n---\\\\n\\\\n![picture alt](/images/photo.jpeg \\\\\\"Title is optional\\\\\\")\\\\n\\\\n## Markdown plus tables\\\\n\\\\n| Header | Header | Right |\\\\n| ------ | ------ | ----: |\\\\n| Cell | Cell | $10 |\\\\n| Cell | Cell | $20 |\\\\n\\\\n- Outer pipes on tables are optional\\\\n- Colon used for alignment (right versus left)\\\\n\\\\n## Markdown plus definition lists\\\\n\\\\nBottled water\\\\n: $ 1.25\\\\n: $ 1.55 (Large)\\\\n\\\\nMilk\\\\nPop\\\\n: $ 1.75\\\\n\\\\n- Multiple definitions and terms are possible\\\\n- Definitions can include multiple paragraphs too\\\\n\\\\n*[ABBR]: Markdown plus abbreviations (produces an <abbr> tag)\\\\n\\"],[\\"# Header 1\\\\n\\\\n## Header 2\\\\n\\\\n### Header 3 ### (Hashes on right are optional)\\\\n\\\\n## Markdown plus h2 with a custom ID ## {#id-goes-here}\\\\n\\\\n[Link back to H2](#id-goes-here)\\\\n\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`js\\\\nvar x = \\\\\\"string\\\\\\";\\\\nfunction f() {\\\\n return x;\\\\n}\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`\\\\n\\\\n\\\\x3c!-- html madness --\\\\x3e\\\\n<div class=\\\\\\"custom-class\\\\\\" markdown=\\\\\\"1\\\\\\">\\\\n <div>\\\\n nested div\\\\n </div>\\\\n <script type='text/x-koka'>\\\\n function( x: int ) { return x*x; }\\\\n <\\\\/script>\\\\n This is a div _with_ underscores\\\\n and a & <b class=\\\\\\"bold\\\\\\">bold</b> element.\\\\n <style>\\\\n body { font: \\\\\\"Consolas\\\\\\" }\\\\n </style>\\\\n</div>\\\\n\\\\n- Bullet lists are easy too\\\\n\\\\n* Another one\\\\n\\\\n- Another one\\\\n\\\\nThis is a paragraph, which is text surrounded by\\\\nwhitespace. Paragraphs can be on one\\\\nline (or many), and can drone on for hours.\\\\n\\\\nNow some inline markup like _italics_, **bold**,\\\\nand \\\\\\\\\`code()\\\\\\\\\`. Note that underscores\\\\nin_words_are ignored.\\\\n\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`application/json\\\\n { value: [\\\\\\"or with a mime type\\\\\\"] }\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`\\\\n\\\\n> Blockquotes are like quoted text in email replies\\\\n>\\\\n> > And, they can be nested\\\\n\\\\n1. A numbered list\\\\n2. Which is numbered\\\\n3. With periods and a space\\\\n\\\\nAnd now some code:\\\\n\\\\n // Code is just text indented a bit\\\\n which(is_easy) to_remember();\\\\n\\\\nAnd a block\\\\n\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`\\\\n// Markdown extra adds un-indented code blocks too\\\\n\\\\nif (this_is_more_code == true && !indented) {\\\\n // tild wrapped code blocks, also not indented\\\\n}\\\\n\\\\\\\\\`\\\\\\\\\`\\\\\\\\\`\\\\n\\\\nText with\\\\ntwo trailing spaces\\\\n(on the right)\\\\ncan be used\\\\nfor things like poems\\\\n\\\\n### Horizontal rules\\\\n\\\\n---\\\\n\\\\n---\\\\n\\\\n---\\\\n\\\\n![picture alt](/images/photo.jpeg \\\\\\"Title is optional\\\\\\")\\\\n\\\\n## Markdown plus tables\\\\n\\\\n| Header | Header | Right |\\\\n| ------ | ------ | ----: |\\\\n| Cell | Cell | $10 |\\\\n| Cell | Cell | $20 |\\\\n\\\\n- Outer pipes on tables are optional\\\\n- Colon used for alignment (right versus left)\\\\n\\\\n## Markdown plus definition lists\\\\n\\\\nBottled water\\\\n: $ 1.25\\\\n: $ 1.55 (Large)\\\\n\\\\nMilk\\\\nPop\\\\n: $ 1.75\\\\n\\\\n- Multiple definitions and terms are possible\\\\n- Definitions can include multiple paragraphs too\\\\n\\\\n\\\\\\\\*[ABBR]: Markdown plus abbreviations (produces an <abbr> tag)\\\\n\\"]);return o=function(){return n},n}var s=String.raw(o());e.default=s},12,[1,13]);
121121
__d(function(g,r,i,a,m,e,d){m.exports=function(n,t){return t||(t=n.slice(0)),n.raw=t,n}},13,[]);
122122
__r(0);"
123123
`;

src/plugin/transformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ module.exports.transform = async (args) => {
6363
};
6464

6565
const injectString = (src) => {
66-
return `export default String.raw\`${src}\``;
66+
return `export default String.raw\`${src.replace(/`/g, "\\`")}\``;
6767
};
6868

6969
const injectCss = (src) => `

0 commit comments

Comments
 (0)