safe-mdx 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/safe-mdx.d.ts.map +1 -1
- package/dist/safe-mdx.js +8 -2
- package/dist/safe-mdx.js.map +1 -1
- package/dist/safe-mdx.test.js +170 -21
- package/dist/safe-mdx.test.js.map +1 -1
- package/package.json +6 -2
- package/src/safe-mdx.test.tsx +172 -21
- package/src/safe-mdx.tsx +6 -2
package/dist/safe-mdx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-mdx.d.ts","sourceRoot":"","sources":["../src/safe-mdx.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGpC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAKzE,OAAO,EAAY,SAAS,EAAE,MAAM,OAAO,CAAA;AAE3C,KAAK,aAAa,GAAG,WAAW,GAAG,IAAI,CAAA;AASvC,wBAAgB,eAAe,CAAC,EAC5B,UAAU,EACV,IAAS,EACT,KAAmB,GACtB;;;;CAAA,OAIA;AAED,QAAA,MAAM,UAAU,qVA4CN,CAAA;AAEV,KAAK,aAAa,GAAG;KAAG,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG;CAAE,CAAA;AAEjE,qBAAa,UAAU;IACnB,KAAK,EAAE,aAAa,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAK;IACnB,CAAC,EAAE,aAAa,CAAA;IAChB,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAK;gBACtB,EACR,IAAS,EACT,KAAwB,EACxB,UAAgC,GACnC;;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OAAO,EAAE,MAAM,CAAA;CAAE,KAAK,IAAoB,mBAoE9D;AAcD,wBAAgB,QAAQ,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,KAAK,GAAG,SAiBpC"}
|
package/dist/safe-mdx.js
CHANGED
|
@@ -75,7 +75,10 @@ export class MdastToJsx {
|
|
|
75
75
|
var _a;
|
|
76
76
|
const res = (_a = node.children) === null || _a === void 0 ? void 0 : _a.flatMap((child) => this.mdastTransformer(child)).filter(Boolean);
|
|
77
77
|
if (Array.isArray(res)) {
|
|
78
|
-
if (res.length
|
|
78
|
+
if (!res.length) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
else if (res.length === 1) {
|
|
79
82
|
return res[0];
|
|
80
83
|
}
|
|
81
84
|
else {
|
|
@@ -88,7 +91,10 @@ export class MdastToJsx {
|
|
|
88
91
|
var _a;
|
|
89
92
|
const res = (_a = node.children) === null || _a === void 0 ? void 0 : _a.flatMap((child, i) => this.jsxTransformer(child)).filter(Boolean);
|
|
90
93
|
if (Array.isArray(res)) {
|
|
91
|
-
if (res.length
|
|
94
|
+
if (!res.length) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
else if (res.length === 1) {
|
|
92
98
|
return res[0];
|
|
93
99
|
}
|
|
94
100
|
else {
|
package/dist/safe-mdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-mdx.js","sourceRoot":"","sources":["../src/safe-mdx.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,OAAO,iBAAiB,MAAM,oBAAoB,CAAA;AAIlD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,SAAS,MAAM,YAAY,CAA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,IAAI,CAAC,CAAC,CAAC,CAAA;SACjB;QACD,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC7C,KAAK,CAAC,IAAI,CAAC,GAAI,IAAI,CAAC,QAAgB,CAAC,CAAA;SACxC;KACJ;IACD,OAAO,MAAM,CAAA;AACjB,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAC9B,IAAI;QACA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;KACzB;IAAC,OAAO,GAAG,EAAE;QACV,OAAO,IAAI,CAAA;KACd;AACL,CAAC"}
|
package/dist/safe-mdx.test.js
CHANGED
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import dedent from 'dedent';
|
|
4
4
|
import { test, expect } from 'vitest';
|
|
5
5
|
import { MdastToJsx } from './safe-mdx';
|
|
6
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
6
7
|
void React;
|
|
7
8
|
const components = {
|
|
8
9
|
Heading({ level, children }) {
|
|
@@ -12,8 +13,9 @@ const components = {
|
|
|
12
13
|
function render(code) {
|
|
13
14
|
const visitor = new MdastToJsx({ code, components });
|
|
14
15
|
const result = visitor.run();
|
|
16
|
+
const html = renderToStaticMarkup(result);
|
|
15
17
|
// console.log(JSON.stringify(result, null, 2))
|
|
16
|
-
return { result, errors: visitor.errors || [] };
|
|
18
|
+
return { result, errors: visitor.errors || [], html };
|
|
17
19
|
}
|
|
18
20
|
test('basic', () => {
|
|
19
21
|
expect(render(dedent `
|
|
@@ -23,6 +25,7 @@ test('basic', () => {
|
|
|
23
25
|
`)).toMatchInlineSnapshot(`
|
|
24
26
|
{
|
|
25
27
|
"errors": [],
|
|
28
|
+
"html": "<h1>Hello</h1><p>i am a paragraph</p>",
|
|
26
29
|
"result": <React.Fragment>
|
|
27
30
|
<h1>
|
|
28
31
|
Hello
|
|
@@ -45,6 +48,7 @@ test('table', () => {
|
|
|
45
48
|
`)).toMatchInlineSnapshot(`
|
|
46
49
|
{
|
|
47
50
|
"errors": [],
|
|
51
|
+
"html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr></tbody></table>",
|
|
48
52
|
"result": <React.Fragment>
|
|
49
53
|
<h1>
|
|
50
54
|
Hello
|
|
@@ -126,6 +130,7 @@ test('table, only head', () => {
|
|
|
126
130
|
`)).toMatchInlineSnapshot(`
|
|
127
131
|
{
|
|
128
132
|
"errors": [],
|
|
133
|
+
"html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead></table>",
|
|
129
134
|
"result": <React.Fragment>
|
|
130
135
|
<h1>
|
|
131
136
|
Hello
|
|
@@ -163,6 +168,7 @@ test('inline jsx', () => {
|
|
|
163
168
|
`)).toMatchInlineSnapshot(`
|
|
164
169
|
{
|
|
165
170
|
"errors": [],
|
|
171
|
+
"html": "<p><h1>hello</h1></p>",
|
|
166
172
|
"result": <React.Fragment>
|
|
167
173
|
<p>
|
|
168
174
|
<Heading
|
|
@@ -183,6 +189,7 @@ test('block jsx', () => {
|
|
|
183
189
|
`)).toMatchInlineSnapshot(`
|
|
184
190
|
{
|
|
185
191
|
"errors": [],
|
|
192
|
+
"html": "<h1><blockquote><p>hello</p></blockquote></h1>",
|
|
186
193
|
"result": <React.Fragment>
|
|
187
194
|
<Heading
|
|
188
195
|
level={2}
|
|
@@ -197,6 +204,30 @@ test('block jsx', () => {
|
|
|
197
204
|
}
|
|
198
205
|
`);
|
|
199
206
|
});
|
|
207
|
+
test('complex jsx, self closing tags', () => {
|
|
208
|
+
expect(render(dedent `
|
|
209
|
+
# hello <br />
|
|
210
|
+
|
|
211
|
+
<br />
|
|
212
|
+
|
|
213
|
+
content
|
|
214
|
+
`)).toMatchInlineSnapshot(`
|
|
215
|
+
{
|
|
216
|
+
"errors": [],
|
|
217
|
+
"html": "<h1>hello <br/></h1><br/><p>content</p>",
|
|
218
|
+
"result": <React.Fragment>
|
|
219
|
+
<h1>
|
|
220
|
+
hello
|
|
221
|
+
<br />
|
|
222
|
+
</h1>
|
|
223
|
+
<br />
|
|
224
|
+
<p>
|
|
225
|
+
content
|
|
226
|
+
</p>
|
|
227
|
+
</React.Fragment>,
|
|
228
|
+
}
|
|
229
|
+
`);
|
|
230
|
+
});
|
|
200
231
|
test('missing components are ignored', () => {
|
|
201
232
|
expect(render(dedent `
|
|
202
233
|
<MissingComponent level={2} />
|
|
@@ -207,6 +238,7 @@ test('missing components are ignored', () => {
|
|
|
207
238
|
"message": "Unsupported jsx component MissingComponent",
|
|
208
239
|
},
|
|
209
240
|
],
|
|
241
|
+
"html": "",
|
|
210
242
|
"result": <React.Fragment />,
|
|
211
243
|
}
|
|
212
244
|
`);
|
|
@@ -248,6 +280,7 @@ test('props parsing', () => {
|
|
|
248
280
|
"message": "Expressions in jsx props are not supported (...{ spread: true })",
|
|
249
281
|
},
|
|
250
282
|
],
|
|
283
|
+
"html": "<h1><p>hi</p></h1>",
|
|
251
284
|
"result": <React.Fragment>
|
|
252
285
|
<Heading
|
|
253
286
|
backTick="some \${expr} value"
|
|
@@ -278,6 +311,7 @@ test('breaks', () => {
|
|
|
278
311
|
`)).toMatchInlineSnapshot(`
|
|
279
312
|
{
|
|
280
313
|
"errors": [],
|
|
314
|
+
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
|
|
281
315
|
"result": <React.Fragment>
|
|
282
316
|
<p>
|
|
283
317
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
@@ -318,7 +352,7 @@ test('kitchen sink', () => {
|
|
|
318
352
|
|
|
319
353
|
## Headers
|
|
320
354
|
|
|
321
|
-
|
|
355
|
+
|
|
322
356
|
# H1
|
|
323
357
|
## H2
|
|
324
358
|
### H3
|
|
@@ -333,7 +367,7 @@ test('kitchen sink', () => {
|
|
|
333
367
|
|
|
334
368
|
Alt-H2
|
|
335
369
|
------
|
|
336
|
-
|
|
370
|
+
|
|
337
371
|
|
|
338
372
|
# H1
|
|
339
373
|
## H2
|
|
@@ -710,6 +744,112 @@ test('kitchen sink', () => {
|
|
|
710
744
|
"message": "Unsupported jsx component dl",
|
|
711
745
|
},
|
|
712
746
|
],
|
|
747
|
+
"html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it's styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber's original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that's what you're looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
748
|
+
|
|
749
|
+
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
750
|
+
|
|
751
|
+
Combined emphasis with **asterisks and _underscores_**.
|
|
752
|
+
|
|
753
|
+
Strikethrough uses two tildes. ~~Scratch this.~~</code></pre><p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p><p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p><p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p><p>Strikethrough uses two tildes. <del>Scratch this.</del></p><a name="lists"></a><h2>Lists</h2><p>(In this example, leading and trailing spaces are shown with with dots: ⋅)</p><pre><code>1. First ordered list item
|
|
754
|
+
2. Another item
|
|
755
|
+
⋅⋅* Unordered sub-list.
|
|
756
|
+
1. Actual numbers don't matter, just that it's a number
|
|
757
|
+
⋅⋅1. Ordered sub-list
|
|
758
|
+
4. And another item.
|
|
759
|
+
|
|
760
|
+
⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
|
|
761
|
+
|
|
762
|
+
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
|
|
763
|
+
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
|
|
764
|
+
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
765
|
+
|
|
766
|
+
* Unordered list can use asterisks
|
|
767
|
+
- Or minuses
|
|
768
|
+
+ Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don't matter, just that it's a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I'm an inline-style link](https://www.google.com)
|
|
769
|
+
|
|
770
|
+
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
771
|
+
|
|
772
|
+
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
773
|
+
|
|
774
|
+
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
775
|
+
|
|
776
|
+
[You can use numbers for reference-style link definitions][1]
|
|
777
|
+
|
|
778
|
+
Or leave it empty and use the [link text itself].
|
|
779
|
+
|
|
780
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
781
|
+
http://www.example.com and sometimes
|
|
782
|
+
example.com (but not on Github, for example).
|
|
783
|
+
|
|
784
|
+
Some text to show that the reference links can follow later.
|
|
785
|
+
|
|
786
|
+
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
787
|
+
[1]: http://slashdot.org
|
|
788
|
+
[link text itself]: http://www.reddit.com</code></pre><p><a href="https://www.google.com" title="">I'm an inline-style link</a></p><p><a href="https://www.google.com" title="Google's Homepage">I'm an inline-style link with title</a></p><p><a href="https://www.mozilla.org">I'm a reference-style link</a></p><p><a href="../blob/master/LICENSE" title="">I'm a relative reference to a repository file</a></p><p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p><p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p><p>URLs and URLs in angle brackets will automatically get turned into links.
|
|
789
|
+
<a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
|
|
790
|
+
example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here's our logo (hover to see the title text):
|
|
791
|
+
|
|
792
|
+
Inline-style:
|
|
793
|
+

|
|
794
|
+
|
|
795
|
+
Reference-style:
|
|
796
|
+
![alt text][logo]
|
|
797
|
+
|
|
798
|
+
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"</code></pre><p>Here's our logo (hover to see the title text):</p><p>Inline-style:
|
|
799
|
+
<img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p><p>Reference-style:
|
|
800
|
+
</p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.</p><pre><code>var s = "JavaScript syntax highlighting";
|
|
801
|
+
alert(s);</code></pre><pre><code>s = "Python syntax highlighting"
|
|
802
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
803
|
+
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><pre><code>var s = "JavaScript syntax highlighting";
|
|
804
|
+
alert(s);</code></pre><pre><code>s = "Python syntax highlighting"
|
|
805
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
806
|
+
But let's throw in a <b>tag</b>.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren't part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
|
|
807
|
+
|
|
808
|
+
| Tables | Are | Cool |
|
|
809
|
+
| ------------- |:-------------:| -----:|
|
|
810
|
+
| col 3 is | right-aligned | $1600 |
|
|
811
|
+
| col 2 is | centered | $12 |
|
|
812
|
+
| zebra stripes | are neat | $1 |
|
|
813
|
+
|
|
814
|
+
There must be at least 3 dashes separating each header cell.
|
|
815
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
816
|
+
raw Markdown line up prettily. You can also use inline Markdown.
|
|
817
|
+
|
|
818
|
+
Markdown | Less | Pretty
|
|
819
|
+
--- | --- | ---
|
|
820
|
+
*Still* | \`renders\` | **nicely**
|
|
821
|
+
1 | 2 | 3</code></pre><p>Colons can be used to align columns.</p><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr><tr class=""><td class="">zebra stripes</td><td class="">are neat</td><td class="">$1</td></tr></tbody></table><p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.</p><table><thead><tr class=""><td class="">Markdown</td><td class="">Less</td><td class="">Pretty</td></tr></thead><tbody><tr class=""><td class=""><em>Still</em></td><td class=""><code>renders</code></td><td class=""><strong>nicely</strong></td></tr><tr class=""><td class="">1</td><td class="">2</td><td class="">3</td></tr></tbody></table><a name="blockquotes"></a><h2>Blockquotes</h2><pre><code>> Blockquotes are very handy in email to emulate reply text.
|
|
822
|
+
> This line is part of the same quote.
|
|
823
|
+
|
|
824
|
+
Quote break.
|
|
825
|
+
|
|
826
|
+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
|
|
827
|
+
This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it'll mostly work pretty well.</p><pre><code><dl>
|
|
828
|
+
<dt>Definition list</dt>
|
|
829
|
+
<dd>Is something people use sometimes.</dd>
|
|
830
|
+
|
|
831
|
+
<dt>Markdown in HTML</dt>
|
|
832
|
+
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
833
|
+
</dl></code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
|
|
834
|
+
|
|
835
|
+
---
|
|
836
|
+
|
|
837
|
+
Hyphens
|
|
838
|
+
|
|
839
|
+
***
|
|
840
|
+
|
|
841
|
+
Asterisks
|
|
842
|
+
|
|
843
|
+
___
|
|
844
|
+
|
|
845
|
+
Underscores</code></pre><p>Three or more...</p><hr/><p>Hyphens</p><hr/><p>Asterisks</p><hr/><p>Underscores</p><a name="lines"></a><h2>Line Breaks</h2><p>My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.</p><p>Here are some things to try out:</p><pre><code>Here's a line for us to start with.
|
|
846
|
+
|
|
847
|
+
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
848
|
+
|
|
849
|
+
This line is also a separate paragraph, but...
|
|
850
|
+
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.</code></pre><p>Here's a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it's a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there's no need to use MD's two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can't be added directly but you can add an image with a link to the video like this:</p><pre><code><a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
851
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
852
|
+
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a></code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
|
|
713
853
|
"result": <React.Fragment>
|
|
714
854
|
<h1>
|
|
715
855
|
Markdown Kitchen Sink
|
|
@@ -866,24 +1006,33 @@ test('kitchen sink', () => {
|
|
|
866
1006
|
<h2>
|
|
867
1007
|
Headers
|
|
868
1008
|
</h2>
|
|
869
|
-
<
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
</
|
|
1009
|
+
<h1>
|
|
1010
|
+
H1
|
|
1011
|
+
</h1>
|
|
1012
|
+
<h2>
|
|
1013
|
+
H2
|
|
1014
|
+
</h2>
|
|
1015
|
+
<h3>
|
|
1016
|
+
H3
|
|
1017
|
+
</h3>
|
|
1018
|
+
<h4>
|
|
1019
|
+
H4
|
|
1020
|
+
</h4>
|
|
1021
|
+
<h5>
|
|
1022
|
+
H5
|
|
1023
|
+
</h5>
|
|
1024
|
+
<h6>
|
|
1025
|
+
H6
|
|
1026
|
+
</h6>
|
|
1027
|
+
<p>
|
|
1028
|
+
Alternatively, for H1 and H2, an underline-ish style:
|
|
1029
|
+
</p>
|
|
1030
|
+
<h1>
|
|
1031
|
+
Alt-H1
|
|
1032
|
+
</h1>
|
|
1033
|
+
<h2>
|
|
1034
|
+
Alt-H2
|
|
1035
|
+
</h2>
|
|
887
1036
|
<h1>
|
|
888
1037
|
H1
|
|
889
1038
|
</h1>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-mdx.test.js","sourceRoot":"","sources":["../src/safe-mdx.test.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,KAAK,KAAK,CAAA;AAEV,MAAM,UAAU,GAAG;IACf,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE;QACvB,OAAO,uBAAK,QAAQ,GAAM,CAAA;IAC9B,CAAC;CACG,CAAA;AAER,SAAS,MAAM,CAAC,IAAI;IAChB,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;IACpD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC5B,+CAA+C;IAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"safe-mdx.test.js","sourceRoot":"","sources":["../src/safe-mdx.test.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,I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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4hCvB,CAAC,CAAA;AACN,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "safe-mdx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Render MDX in React without eval",
|
|
6
6
|
"repository": "https://github.com/holocron-hq/safe-mdx",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"types": "./dist/safe-mdx.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./dist/safe-mdx.d.ts",
|
|
11
12
|
"default": "./dist/safe-mdx.js"
|
|
12
13
|
},
|
|
13
14
|
"./src/*": "./src/*.ts",
|
|
15
|
+
"./src": "./src/index.ts",
|
|
14
16
|
"./package.json": "./package.json"
|
|
15
17
|
},
|
|
16
18
|
"scripts": {
|
|
@@ -42,8 +44,10 @@
|
|
|
42
44
|
"@types/mdast": "^4.0.3",
|
|
43
45
|
"@types/node": "^20.10.0",
|
|
44
46
|
"@types/react": "18.2.15",
|
|
47
|
+
"@types/react-dom": "^18.2.18",
|
|
45
48
|
"dedent": "^1.2.0",
|
|
46
49
|
"mdast-util-mdx-jsx": "^3.0.0",
|
|
47
|
-
"react": "^18.2.0"
|
|
50
|
+
"react": "^18.2.0",
|
|
51
|
+
"react-dom": "^18.2.0"
|
|
48
52
|
}
|
|
49
53
|
}
|
package/src/safe-mdx.test.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import dedent from 'dedent'
|
|
3
3
|
import { test, expect } from 'vitest'
|
|
4
4
|
import { MdastToJsx } from './safe-mdx'
|
|
5
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
5
6
|
void React
|
|
6
7
|
|
|
7
8
|
const components = {
|
|
@@ -13,8 +14,9 @@ const components = {
|
|
|
13
14
|
function render(code) {
|
|
14
15
|
const visitor = new MdastToJsx({ code, components })
|
|
15
16
|
const result = visitor.run()
|
|
17
|
+
const html = renderToStaticMarkup(result)
|
|
16
18
|
// console.log(JSON.stringify(result, null, 2))
|
|
17
|
-
return { result, errors: visitor.errors || [] }
|
|
19
|
+
return { result, errors: visitor.errors || [], html }
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
test('basic', () => {
|
|
@@ -27,6 +29,7 @@ test('basic', () => {
|
|
|
27
29
|
).toMatchInlineSnapshot(`
|
|
28
30
|
{
|
|
29
31
|
"errors": [],
|
|
32
|
+
"html": "<h1>Hello</h1><p>i am a paragraph</p>",
|
|
30
33
|
"result": <React.Fragment>
|
|
31
34
|
<h1>
|
|
32
35
|
Hello
|
|
@@ -51,6 +54,7 @@ test('table', () => {
|
|
|
51
54
|
).toMatchInlineSnapshot(`
|
|
52
55
|
{
|
|
53
56
|
"errors": [],
|
|
57
|
+
"html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr></tbody></table>",
|
|
54
58
|
"result": <React.Fragment>
|
|
55
59
|
<h1>
|
|
56
60
|
Hello
|
|
@@ -134,6 +138,7 @@ test('table, only head', () => {
|
|
|
134
138
|
).toMatchInlineSnapshot(`
|
|
135
139
|
{
|
|
136
140
|
"errors": [],
|
|
141
|
+
"html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead></table>",
|
|
137
142
|
"result": <React.Fragment>
|
|
138
143
|
<h1>
|
|
139
144
|
Hello
|
|
@@ -174,6 +179,7 @@ test('inline jsx', () => {
|
|
|
174
179
|
).toMatchInlineSnapshot(`
|
|
175
180
|
{
|
|
176
181
|
"errors": [],
|
|
182
|
+
"html": "<p><h1>hello</h1></p>",
|
|
177
183
|
"result": <React.Fragment>
|
|
178
184
|
<p>
|
|
179
185
|
<Heading
|
|
@@ -197,6 +203,7 @@ test('block jsx', () => {
|
|
|
197
203
|
).toMatchInlineSnapshot(`
|
|
198
204
|
{
|
|
199
205
|
"errors": [],
|
|
206
|
+
"html": "<h1><blockquote><p>hello</p></blockquote></h1>",
|
|
200
207
|
"result": <React.Fragment>
|
|
201
208
|
<Heading
|
|
202
209
|
level={2}
|
|
@@ -211,6 +218,32 @@ test('block jsx', () => {
|
|
|
211
218
|
}
|
|
212
219
|
`)
|
|
213
220
|
})
|
|
221
|
+
test('complex jsx, self closing tags', () => {
|
|
222
|
+
expect(
|
|
223
|
+
render(dedent`
|
|
224
|
+
# hello <br />
|
|
225
|
+
|
|
226
|
+
<br />
|
|
227
|
+
|
|
228
|
+
content
|
|
229
|
+
`),
|
|
230
|
+
).toMatchInlineSnapshot(`
|
|
231
|
+
{
|
|
232
|
+
"errors": [],
|
|
233
|
+
"html": "<h1>hello <br/></h1><br/><p>content</p>",
|
|
234
|
+
"result": <React.Fragment>
|
|
235
|
+
<h1>
|
|
236
|
+
hello
|
|
237
|
+
<br />
|
|
238
|
+
</h1>
|
|
239
|
+
<br />
|
|
240
|
+
<p>
|
|
241
|
+
content
|
|
242
|
+
</p>
|
|
243
|
+
</React.Fragment>,
|
|
244
|
+
}
|
|
245
|
+
`)
|
|
246
|
+
})
|
|
214
247
|
|
|
215
248
|
test('missing components are ignored', () => {
|
|
216
249
|
expect(
|
|
@@ -224,6 +257,7 @@ test('missing components are ignored', () => {
|
|
|
224
257
|
"message": "Unsupported jsx component MissingComponent",
|
|
225
258
|
},
|
|
226
259
|
],
|
|
260
|
+
"html": "",
|
|
227
261
|
"result": <React.Fragment />,
|
|
228
262
|
}
|
|
229
263
|
`)
|
|
@@ -268,6 +302,7 @@ test('props parsing', () => {
|
|
|
268
302
|
"message": "Expressions in jsx props are not supported (...{ spread: true })",
|
|
269
303
|
},
|
|
270
304
|
],
|
|
305
|
+
"html": "<h1><p>hi</p></h1>",
|
|
271
306
|
"result": <React.Fragment>
|
|
272
307
|
<Heading
|
|
273
308
|
backTick="some \${expr} value"
|
|
@@ -300,6 +335,7 @@ test('breaks', () => {
|
|
|
300
335
|
).toMatchInlineSnapshot(`
|
|
301
336
|
{
|
|
302
337
|
"errors": [],
|
|
338
|
+
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
|
|
303
339
|
"result": <React.Fragment>
|
|
304
340
|
<p>
|
|
305
341
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
@@ -342,7 +378,7 @@ test('kitchen sink', () => {
|
|
|
342
378
|
|
|
343
379
|
## Headers
|
|
344
380
|
|
|
345
|
-
|
|
381
|
+
|
|
346
382
|
# H1
|
|
347
383
|
## H2
|
|
348
384
|
### H3
|
|
@@ -357,7 +393,7 @@ test('kitchen sink', () => {
|
|
|
357
393
|
|
|
358
394
|
Alt-H2
|
|
359
395
|
------
|
|
360
|
-
|
|
396
|
+
|
|
361
397
|
|
|
362
398
|
# H1
|
|
363
399
|
## H2
|
|
@@ -735,6 +771,112 @@ test('kitchen sink', () => {
|
|
|
735
771
|
"message": "Unsupported jsx component dl",
|
|
736
772
|
},
|
|
737
773
|
],
|
|
774
|
+
"html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it's styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber's original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that's what you're looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
775
|
+
|
|
776
|
+
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
777
|
+
|
|
778
|
+
Combined emphasis with **asterisks and _underscores_**.
|
|
779
|
+
|
|
780
|
+
Strikethrough uses two tildes. ~~Scratch this.~~</code></pre><p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p><p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p><p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p><p>Strikethrough uses two tildes. <del>Scratch this.</del></p><a name="lists"></a><h2>Lists</h2><p>(In this example, leading and trailing spaces are shown with with dots: ⋅)</p><pre><code>1. First ordered list item
|
|
781
|
+
2. Another item
|
|
782
|
+
⋅⋅* Unordered sub-list.
|
|
783
|
+
1. Actual numbers don't matter, just that it's a number
|
|
784
|
+
⋅⋅1. Ordered sub-list
|
|
785
|
+
4. And another item.
|
|
786
|
+
|
|
787
|
+
⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).
|
|
788
|
+
|
|
789
|
+
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
|
|
790
|
+
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
|
|
791
|
+
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
792
|
+
|
|
793
|
+
* Unordered list can use asterisks
|
|
794
|
+
- Or minuses
|
|
795
|
+
+ Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don't matter, just that it's a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I'm an inline-style link](https://www.google.com)
|
|
796
|
+
|
|
797
|
+
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
798
|
+
|
|
799
|
+
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
800
|
+
|
|
801
|
+
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
802
|
+
|
|
803
|
+
[You can use numbers for reference-style link definitions][1]
|
|
804
|
+
|
|
805
|
+
Or leave it empty and use the [link text itself].
|
|
806
|
+
|
|
807
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
808
|
+
http://www.example.com and sometimes
|
|
809
|
+
example.com (but not on Github, for example).
|
|
810
|
+
|
|
811
|
+
Some text to show that the reference links can follow later.
|
|
812
|
+
|
|
813
|
+
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
814
|
+
[1]: http://slashdot.org
|
|
815
|
+
[link text itself]: http://www.reddit.com</code></pre><p><a href="https://www.google.com" title="">I'm an inline-style link</a></p><p><a href="https://www.google.com" title="Google's Homepage">I'm an inline-style link with title</a></p><p><a href="https://www.mozilla.org">I'm a reference-style link</a></p><p><a href="../blob/master/LICENSE" title="">I'm a relative reference to a repository file</a></p><p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p><p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p><p>URLs and URLs in angle brackets will automatically get turned into links.
|
|
816
|
+
<a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
|
|
817
|
+
example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here's our logo (hover to see the title text):
|
|
818
|
+
|
|
819
|
+
Inline-style:
|
|
820
|
+

|
|
821
|
+
|
|
822
|
+
Reference-style:
|
|
823
|
+
![alt text][logo]
|
|
824
|
+
|
|
825
|
+
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"</code></pre><p>Here's our logo (hover to see the title text):</p><p>Inline-style:
|
|
826
|
+
<img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p><p>Reference-style:
|
|
827
|
+
</p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.</p><pre><code>var s = "JavaScript syntax highlighting";
|
|
828
|
+
alert(s);</code></pre><pre><code>s = "Python syntax highlighting"
|
|
829
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
830
|
+
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><pre><code>var s = "JavaScript syntax highlighting";
|
|
831
|
+
alert(s);</code></pre><pre><code>s = "Python syntax highlighting"
|
|
832
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
833
|
+
But let's throw in a <b>tag</b>.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren't part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
|
|
834
|
+
|
|
835
|
+
| Tables | Are | Cool |
|
|
836
|
+
| ------------- |:-------------:| -----:|
|
|
837
|
+
| col 3 is | right-aligned | $1600 |
|
|
838
|
+
| col 2 is | centered | $12 |
|
|
839
|
+
| zebra stripes | are neat | $1 |
|
|
840
|
+
|
|
841
|
+
There must be at least 3 dashes separating each header cell.
|
|
842
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
843
|
+
raw Markdown line up prettily. You can also use inline Markdown.
|
|
844
|
+
|
|
845
|
+
Markdown | Less | Pretty
|
|
846
|
+
--- | --- | ---
|
|
847
|
+
*Still* | \`renders\` | **nicely**
|
|
848
|
+
1 | 2 | 3</code></pre><p>Colons can be used to align columns.</p><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr><tr class=""><td class="">zebra stripes</td><td class="">are neat</td><td class="">$1</td></tr></tbody></table><p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.</p><table><thead><tr class=""><td class="">Markdown</td><td class="">Less</td><td class="">Pretty</td></tr></thead><tbody><tr class=""><td class=""><em>Still</em></td><td class=""><code>renders</code></td><td class=""><strong>nicely</strong></td></tr><tr class=""><td class="">1</td><td class="">2</td><td class="">3</td></tr></tbody></table><a name="blockquotes"></a><h2>Blockquotes</h2><pre><code>> Blockquotes are very handy in email to emulate reply text.
|
|
849
|
+
> This line is part of the same quote.
|
|
850
|
+
|
|
851
|
+
Quote break.
|
|
852
|
+
|
|
853
|
+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
|
|
854
|
+
This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it'll mostly work pretty well.</p><pre><code><dl>
|
|
855
|
+
<dt>Definition list</dt>
|
|
856
|
+
<dd>Is something people use sometimes.</dd>
|
|
857
|
+
|
|
858
|
+
<dt>Markdown in HTML</dt>
|
|
859
|
+
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
860
|
+
</dl></code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
|
|
861
|
+
|
|
862
|
+
---
|
|
863
|
+
|
|
864
|
+
Hyphens
|
|
865
|
+
|
|
866
|
+
***
|
|
867
|
+
|
|
868
|
+
Asterisks
|
|
869
|
+
|
|
870
|
+
___
|
|
871
|
+
|
|
872
|
+
Underscores</code></pre><p>Three or more...</p><hr/><p>Hyphens</p><hr/><p>Asterisks</p><hr/><p>Underscores</p><a name="lines"></a><h2>Line Breaks</h2><p>My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.</p><p>Here are some things to try out:</p><pre><code>Here's a line for us to start with.
|
|
873
|
+
|
|
874
|
+
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
875
|
+
|
|
876
|
+
This line is also a separate paragraph, but...
|
|
877
|
+
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.</code></pre><p>Here's a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it's a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there's no need to use MD's two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can't be added directly but you can add an image with a link to the video like this:</p><pre><code><a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
878
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
879
|
+
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a></code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
|
|
738
880
|
"result": <React.Fragment>
|
|
739
881
|
<h1>
|
|
740
882
|
Markdown Kitchen Sink
|
|
@@ -891,24 +1033,33 @@ test('kitchen sink', () => {
|
|
|
891
1033
|
<h2>
|
|
892
1034
|
Headers
|
|
893
1035
|
</h2>
|
|
894
|
-
<
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
</
|
|
1036
|
+
<h1>
|
|
1037
|
+
H1
|
|
1038
|
+
</h1>
|
|
1039
|
+
<h2>
|
|
1040
|
+
H2
|
|
1041
|
+
</h2>
|
|
1042
|
+
<h3>
|
|
1043
|
+
H3
|
|
1044
|
+
</h3>
|
|
1045
|
+
<h4>
|
|
1046
|
+
H4
|
|
1047
|
+
</h4>
|
|
1048
|
+
<h5>
|
|
1049
|
+
H5
|
|
1050
|
+
</h5>
|
|
1051
|
+
<h6>
|
|
1052
|
+
H6
|
|
1053
|
+
</h6>
|
|
1054
|
+
<p>
|
|
1055
|
+
Alternatively, for H1 and H2, an underline-ish style:
|
|
1056
|
+
</p>
|
|
1057
|
+
<h1>
|
|
1058
|
+
Alt-H1
|
|
1059
|
+
</h1>
|
|
1060
|
+
<h2>
|
|
1061
|
+
Alt-H2
|
|
1062
|
+
</h2>
|
|
912
1063
|
<h1>
|
|
913
1064
|
H1
|
|
914
1065
|
</h1>
|
package/src/safe-mdx.tsx
CHANGED
|
@@ -105,7 +105,9 @@ export class MdastToJsx {
|
|
|
105
105
|
?.flatMap((child) => this.mdastTransformer(child))
|
|
106
106
|
.filter(Boolean)
|
|
107
107
|
if (Array.isArray(res)) {
|
|
108
|
-
if (res.length
|
|
108
|
+
if (!res.length) {
|
|
109
|
+
return null
|
|
110
|
+
} else if (res.length === 1) {
|
|
109
111
|
return res[0]
|
|
110
112
|
} else {
|
|
111
113
|
return res.map((x, i) =>
|
|
@@ -120,7 +122,9 @@ export class MdastToJsx {
|
|
|
120
122
|
?.flatMap((child, i) => this.jsxTransformer(child))
|
|
121
123
|
.filter(Boolean)
|
|
122
124
|
if (Array.isArray(res)) {
|
|
123
|
-
if (res.length
|
|
125
|
+
if (!res.length) {
|
|
126
|
+
return null
|
|
127
|
+
} else if (res.length === 1) {
|
|
124
128
|
return res[0]
|
|
125
129
|
} else {
|
|
126
130
|
return res.map((x, i) =>
|