safe-mdx 0.0.0 → 0.0.1

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.
@@ -0,0 +1,1551 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = __importDefault(require("react"));
8
+ const dedent_1 = __importDefault(require("dedent"));
9
+ const vitest_1 = require("vitest");
10
+ const safe_mdx_1 = require("./safe-mdx");
11
+ void react_1.default;
12
+ const components = {
13
+ Heading({ level, children }) {
14
+ return (0, jsx_runtime_1.jsx)("h1", { children: children });
15
+ },
16
+ };
17
+ function render(code) {
18
+ const visitor = new safe_mdx_1.MdastToJsx({ code, components });
19
+ const result = visitor.run();
20
+ // console.log(JSON.stringify(result, null, 2))
21
+ return { result, errors: visitor.errors || [] };
22
+ }
23
+ (0, vitest_1.test)('basic', () => {
24
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
25
+ # Hello
26
+
27
+ i am a paragraph
28
+ `)).toMatchInlineSnapshot(`
29
+ {
30
+ "errors": [],
31
+ "result": <React.Fragment>
32
+ <h1>
33
+ Hello
34
+ </h1>
35
+ <p>
36
+ i am a paragraph
37
+ </p>
38
+ </React.Fragment>,
39
+ }
40
+ `);
41
+ });
42
+ (0, vitest_1.test)('inline jsx', () => {
43
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
44
+ <Heading level={2}>hello</Heading>
45
+ `)).toMatchInlineSnapshot(`
46
+ {
47
+ "errors": [],
48
+ "result": <React.Fragment>
49
+ <p>
50
+ <Heading
51
+ level={2}
52
+ >
53
+ hello
54
+ </Heading>
55
+ </p>
56
+ </React.Fragment>,
57
+ }
58
+ `);
59
+ });
60
+ (0, vitest_1.test)('block jsx', () => {
61
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
62
+ <Heading level={2}>
63
+ > hello
64
+ </Heading>
65
+ `)).toMatchInlineSnapshot(`
66
+ {
67
+ "errors": [],
68
+ "result": <React.Fragment>
69
+ <Heading
70
+ level={2}
71
+ >
72
+ <blockquote>
73
+ <p>
74
+ hello
75
+ </p>
76
+ </blockquote>
77
+ </Heading>
78
+ </React.Fragment>,
79
+ }
80
+ `);
81
+ });
82
+ (0, vitest_1.test)('missing components are ignored', () => {
83
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
84
+ <MissingComponent level={2} />
85
+ `)).toMatchInlineSnapshot(`
86
+ {
87
+ "errors": [
88
+ {
89
+ "message": "Unsupported jsx component MissingComponent",
90
+ },
91
+ ],
92
+ "result": <React.Fragment />,
93
+ }
94
+ `);
95
+ });
96
+ (0, vitest_1.test)('props parsing', () => {
97
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
98
+ <Heading
99
+ num={2}
100
+ doublequote={"a \" string"}
101
+ quote={'a \' string'}
102
+ backTick={\`some ${'${expr}'} value\`}
103
+ boolean={false}
104
+ expression1={1 + 3}
105
+ expression2={Boolean(1)}
106
+ jsx={<SomeComponent />}
107
+ undef={undefined}
108
+ null={null}
109
+ {...{
110
+ spread: true
111
+ }}
112
+ >
113
+ hi
114
+ </Heading>
115
+
116
+ `)).toMatchInlineSnapshot(`
117
+ {
118
+ "errors": [
119
+ {
120
+ "message": "Expressions in jsx props are not supported (expression1={1 + 3})",
121
+ },
122
+ {
123
+ "message": "Expressions in jsx props are not supported (expression2={Boolean(1)})",
124
+ },
125
+ {
126
+ "message": "Expressions in jsx props are not supported (jsx={<SomeComponent />})",
127
+ },
128
+ {
129
+ "message": "Expressions in jsx props are not supported (...{ spread: true })",
130
+ },
131
+ ],
132
+ "result": <React.Fragment>
133
+ <Heading
134
+ backTick="some \${expr} value"
135
+ boolean={false}
136
+ doublequote="a \\" string"
137
+ null={null}
138
+ num={2}
139
+ quote="a \\" string"
140
+ >
141
+ <p>
142
+ hi
143
+ </p>
144
+ </Heading>
145
+ </React.Fragment>,
146
+ }
147
+ `);
148
+ });
149
+ (0, vitest_1.test)('breaks', () => {
150
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
151
+ To have a line break without a paragraph, you will need to use two trailing spaces.
152
+ Note that this line is separate, but within the same paragraph.
153
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
154
+ `)).toMatchInlineSnapshot(`
155
+ {
156
+ "errors": [],
157
+ "result": <React.Fragment>
158
+ <p>
159
+ To have a line break without a paragraph, you will need to use two trailing spaces.
160
+ <br />
161
+ Note that this line is separate, but within the same paragraph.
162
+ <br />
163
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
164
+ </p>
165
+ </React.Fragment>,
166
+ }
167
+ `);
168
+ });
169
+ // https://github.com/obedm503/markdown-kitchen-sink/blob/master/README.md?plain=1
170
+ (0, vitest_1.test)('kitchen sink', () => {
171
+ (0, vitest_1.expect)(render((0, dedent_1.default) `
172
+ # Markdown Kitchen Sink
173
+ This file is https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet plus a few fixes and additions. Used by [obedm503/bootmark](https://github.com/obedm503/bootmark) to [demonstrate](https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html) it's styling features.
174
+
175
+ This is intended as a quick reference and showcase. For more complete info, see [John Gruber's original spec](http://daringfireball.net/projects/markdown/) and the [Github-flavored Markdown info page](http://github.github.com/github-flavored-markdown/).
176
+
177
+ Note that there is also a [Cheatsheet specific to Markdown Here](./Markdown-Here-Cheatsheet) if that's what you're looking for. You can also check out [more Markdown tools](./Other-Markdown-Tools).
178
+
179
+ ##### Table of Contents
180
+ [Headers](#headers)
181
+ [Emphasis](#emphasis)
182
+ [Lists](#lists)
183
+ [Links](#links)
184
+ [Images](#images)
185
+ [Code and Syntax Highlighting](#code)
186
+ [Tables](#tables)
187
+ [Blockquotes](#blockquotes)
188
+ [Inline HTML](#html)
189
+ [Horizontal Rule](#hr)
190
+ [Line Breaks](#lines)
191
+ [YouTube Videos](#videos)
192
+
193
+ <a name="headers"></a>
194
+
195
+ ## Headers
196
+
197
+ \`\`\`no-highlight
198
+ # H1
199
+ ## H2
200
+ ### H3
201
+ #### H4
202
+ ##### H5
203
+ ###### H6
204
+
205
+ Alternatively, for H1 and H2, an underline-ish style:
206
+
207
+ Alt-H1
208
+ ======
209
+
210
+ Alt-H2
211
+ ------
212
+ \`\`\`
213
+
214
+ # H1
215
+ ## H2
216
+ ### H3
217
+ #### H4
218
+ ##### H5
219
+ ###### H6
220
+
221
+ Alternatively, for H1 and H2, an underline-ish style:
222
+
223
+ Alt-H1
224
+ ======
225
+
226
+ Alt-H2
227
+ ------
228
+
229
+ <a name="emphasis"></a>
230
+
231
+ ## Emphasis
232
+
233
+ \`\`\`no-highlight
234
+ Emphasis, aka italics, with *asterisks* or _underscores_.
235
+
236
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
237
+
238
+ Combined emphasis with **asterisks and _underscores_**.
239
+
240
+ Strikethrough uses two tildes. ~~Scratch this.~~
241
+ \`\`\`
242
+
243
+ Emphasis, aka italics, with *asterisks* or _underscores_.
244
+
245
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
246
+
247
+ Combined emphasis with **asterisks and _underscores_**.
248
+
249
+ Strikethrough uses two tildes. ~~Scratch this.~~
250
+
251
+
252
+ <a name="lists"></a>
253
+
254
+ ## Lists
255
+
256
+ (In this example, leading and trailing spaces are shown with with dots: ⋅)
257
+
258
+ \`\`\`no-highlight
259
+ 1. First ordered list item
260
+ 2. Another item
261
+ ⋅⋅* Unordered sub-list.
262
+ 1. Actual numbers don't matter, just that it's a number
263
+ ⋅⋅1. Ordered sub-list
264
+ 4. And another item.
265
+
266
+ ⋅⋅⋅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).
267
+
268
+ ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
269
+ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
270
+ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
271
+
272
+ * Unordered list can use asterisks
273
+ - Or minuses
274
+ + Or pluses
275
+ \`\`\`
276
+
277
+ 1. First ordered list item
278
+ 2. Another item
279
+ * Unordered sub-list.
280
+ 1. Actual numbers don't matter, just that it's a number
281
+ 1. Ordered sub-list
282
+ 4. And another item.
283
+
284
+ 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).
285
+
286
+ To have a line break without a paragraph, you will need to use two trailing spaces.
287
+ Note that this line is separate, but within the same paragraph.
288
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
289
+
290
+ * Unordered list can use asterisks
291
+ - Or minuses
292
+ + Or pluses
293
+
294
+ <a name="links"></a>
295
+
296
+ ## Links
297
+
298
+ There are two ways to create links.
299
+
300
+ \`\`\`no-highlight
301
+ [I'm an inline-style link](https://www.google.com)
302
+
303
+ [I'm an inline-style link with title](https://www.google.com "Google's Homepage")
304
+
305
+ [I'm a reference-style link][Arbitrary case-insensitive reference text]
306
+
307
+ [I'm a relative reference to a repository file](../blob/master/LICENSE)
308
+
309
+ [You can use numbers for reference-style link definitions][1]
310
+
311
+ Or leave it empty and use the [link text itself].
312
+
313
+ URLs and URLs in angle brackets will automatically get turned into links.
314
+ http://www.example.com and sometimes
315
+ example.com (but not on Github, for example).
316
+
317
+ Some text to show that the reference links can follow later.
318
+
319
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
320
+ [1]: http://slashdot.org
321
+ [link text itself]: http://www.reddit.com
322
+ \`\`\`
323
+
324
+ [I'm an inline-style link](https://www.google.com)
325
+
326
+ [I'm an inline-style link with title](https://www.google.com "Google's Homepage")
327
+
328
+ [I'm a reference-style link][Arbitrary case-insensitive reference text]
329
+
330
+ [I'm a relative reference to a repository file](../blob/master/LICENSE)
331
+
332
+ [You can use numbers for reference-style link definitions][1]
333
+
334
+ Or leave it empty and use the [link text itself].
335
+
336
+ URLs and URLs in angle brackets will automatically get turned into links.
337
+ http://www.example.com and sometimes
338
+ example.com (but not on Github, for example).
339
+
340
+ Some text to show that the reference links can follow later.
341
+
342
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
343
+ [1]: http://slashdot.org
344
+ [link text itself]: http://www.reddit.com
345
+
346
+ <a name="images"></a>
347
+
348
+ ## Images
349
+
350
+ \`\`\`no-highlight
351
+ Here's our logo (hover to see the title text):
352
+
353
+ Inline-style:
354
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
355
+
356
+ Reference-style:
357
+ ![alt text][logo]
358
+
359
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
360
+ \`\`\`
361
+
362
+ Here's our logo (hover to see the title text):
363
+
364
+ Inline-style:
365
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
366
+
367
+ Reference-style:
368
+ ![alt text][logo]
369
+
370
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
371
+
372
+ <a name="code"></a>
373
+
374
+ ## Code and Syntax Highlighting
375
+
376
+ Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and *Markdown Here* -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. *Markdown Here* 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 [highlight.js demo page](http://softwaremaniacs.org/media/soft/highlight/test.html).
377
+
378
+ \`\`\`no-highlight
379
+ Inline \`code\` has \`back-ticks around\` it.
380
+ \`\`\`
381
+
382
+ Inline \`code\` has \`back-ticks around\` it.
383
+
384
+ 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.
385
+
386
+ \`\`\`javascript
387
+ var s = "JavaScript syntax highlighting";
388
+ alert(s);
389
+ \`\`\`
390
+
391
+ \`\`\`python
392
+ s = "Python syntax highlighting"
393
+ print s
394
+ \`\`\`
395
+
396
+ \`\`\`
397
+ No language indicated, so no syntax highlighting.
398
+ But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
399
+ \`\`\`
400
+
401
+
402
+
403
+
404
+ \`\`\`javascript
405
+ var s = "JavaScript syntax highlighting";
406
+ alert(s);
407
+ \`\`\`
408
+
409
+ \`\`\`python
410
+ s = "Python syntax highlighting"
411
+ print s
412
+ \`\`\`
413
+
414
+ \`\`\`
415
+ No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
416
+ But let's throw in a <b>tag</b>.
417
+ \`\`\`
418
+
419
+
420
+ <a name="tables"></a>
421
+
422
+ ## Tables
423
+
424
+ Tables aren't part of the core Markdown spec, but they are part of GFM and *Markdown Here* supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
425
+
426
+ \`\`\`no-highlight
427
+ Colons can be used to align columns.
428
+
429
+ | Tables | Are | Cool |
430
+ | ------------- |:-------------:| -----:|
431
+ | col 3 is | right-aligned | $1600 |
432
+ | col 2 is | centered | $12 |
433
+ | zebra stripes | are neat | $1 |
434
+
435
+ There must be at least 3 dashes separating each header cell.
436
+ The outer pipes (|) are optional, and you don't need to make the
437
+ raw Markdown line up prettily. You can also use inline Markdown.
438
+
439
+ Markdown | Less | Pretty
440
+ --- | --- | ---
441
+ *Still* | \`renders\` | **nicely**
442
+ 1 | 2 | 3
443
+ \`\`\`
444
+
445
+ Colons can be used to align columns.
446
+
447
+ | Tables | Are | Cool |
448
+ | ------------- |:-------------:| -----:|
449
+ | col 3 is | right-aligned | $1600 |
450
+ | col 2 is | centered | $12 |
451
+ | zebra stripes | are neat | $1 |
452
+
453
+ 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.
454
+
455
+ Markdown | Less | Pretty
456
+ --- | --- | ---
457
+ *Still* | \`renders\` | **nicely**
458
+ 1 | 2 | 3
459
+
460
+ <a name="blockquotes"></a>
461
+
462
+ ## Blockquotes
463
+
464
+ \`\`\`no-highlight
465
+ > Blockquotes are very handy in email to emulate reply text.
466
+ > This line is part of the same quote.
467
+
468
+ Quote break.
469
+
470
+ > 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.
471
+ \`\`\`
472
+
473
+ > Blockquotes are very handy in email to emulate reply text.
474
+ > This line is part of the same quote.
475
+
476
+ Quote break.
477
+
478
+ > 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.
479
+
480
+ <a name="html"></a>
481
+
482
+ ## Inline HTML
483
+
484
+ You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
485
+
486
+ \`\`\`no-highlight
487
+ <dl>
488
+ <dt>Definition list</dt>
489
+ <dd>Is something people use sometimes.</dd>
490
+
491
+ <dt>Markdown in HTML</dt>
492
+ <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
493
+ </dl>
494
+ \`\`\`
495
+
496
+ <dl>
497
+ <dt>Definition list</dt>
498
+ <dd>Is something people use sometimes.</dd>
499
+
500
+ <dt>Markdown in HTML</dt>
501
+ <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
502
+ </dl>
503
+
504
+ <a name="hr"></a>
505
+
506
+ ## Horizontal Rule
507
+
508
+ \`\`\`
509
+ Three or more...
510
+
511
+ ---
512
+
513
+ Hyphens
514
+
515
+ ***
516
+
517
+ Asterisks
518
+
519
+ ___
520
+
521
+ Underscores
522
+ \`\`\`
523
+
524
+ Three or more...
525
+
526
+ ---
527
+
528
+ Hyphens
529
+
530
+ ***
531
+
532
+ Asterisks
533
+
534
+ ___
535
+
536
+ Underscores
537
+
538
+ <a name="lines"></a>
539
+
540
+ ## Line Breaks
541
+
542
+ My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; 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.
543
+
544
+ Here are some things to try out:
545
+
546
+ \`\`\`
547
+ Here's a line for us to start with.
548
+
549
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
550
+
551
+ This line is also a separate paragraph, but...
552
+ This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
553
+ \`\`\`
554
+
555
+ Here's a line for us to start with.
556
+
557
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
558
+
559
+ This line is also begins a separate paragraph, but...
560
+ This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
561
+
562
+ (Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
563
+
564
+ <a name="videos"></a>
565
+
566
+ ## YouTube Videos
567
+
568
+ They can't be added directly but you can add an image with a link to the video like this:
569
+
570
+ \`\`\`no-highlight
571
+ <a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
572
+ " target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
573
+ alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
574
+ \`\`\`
575
+
576
+ Or, in pure Markdown, but losing the image sizing and border:
577
+
578
+ \`\`\`no-highlight
579
+ [![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
580
+ \`\`\`
581
+
582
+ `)).toMatchInlineSnapshot(`
583
+ {
584
+ "errors": [
585
+ {
586
+ "message": "Unsupported jsx component dl",
587
+ },
588
+ ],
589
+ "result": <React.Fragment>
590
+ <h1>
591
+ Markdown Kitchen Sink
592
+ </h1>
593
+ <p>
594
+ This file is
595
+ <a
596
+ href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet"
597
+ title=""
598
+ >
599
+ https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
600
+ </a>
601
+ plus a few fixes and additions. Used by
602
+ <a
603
+ href="https://github.com/obedm503/bootmark"
604
+ title=""
605
+ >
606
+ obedm503/bootmark
607
+ </a>
608
+ to
609
+ <a
610
+ href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html"
611
+ title=""
612
+ >
613
+ demonstrate
614
+ </a>
615
+ it's styling features.
616
+ </p>
617
+ <p>
618
+ This is intended as a quick reference and showcase. For more complete info, see
619
+ <a
620
+ href="http://daringfireball.net/projects/markdown/"
621
+ title=""
622
+ >
623
+ John Gruber's original spec
624
+ </a>
625
+ and the
626
+ <a
627
+ href="http://github.github.com/github-flavored-markdown/"
628
+ title=""
629
+ >
630
+ Github-flavored Markdown info page
631
+ </a>
632
+ .
633
+ </p>
634
+ <p>
635
+ Note that there is also a
636
+ <a
637
+ href="./Markdown-Here-Cheatsheet"
638
+ title=""
639
+ >
640
+ Cheatsheet specific to Markdown Here
641
+ </a>
642
+ if that's what you're looking for. You can also check out
643
+ <a
644
+ href="./Other-Markdown-Tools"
645
+ title=""
646
+ >
647
+ more Markdown tools
648
+ </a>
649
+ .
650
+ </p>
651
+ <h5>
652
+ Table of Contents
653
+ </h5>
654
+ <p>
655
+ <a
656
+ href="#headers"
657
+ title=""
658
+ >
659
+ Headers
660
+ </a>
661
+ <br />
662
+ <a
663
+ href="#emphasis"
664
+ title=""
665
+ >
666
+ Emphasis
667
+ </a>
668
+ <br />
669
+ <a
670
+ href="#lists"
671
+ title=""
672
+ >
673
+ Lists
674
+ </a>
675
+ <br />
676
+ <a
677
+ href="#links"
678
+ title=""
679
+ >
680
+ Links
681
+ </a>
682
+ <br />
683
+ <a
684
+ href="#images"
685
+ title=""
686
+ >
687
+ Images
688
+ </a>
689
+ <br />
690
+ <a
691
+ href="#code"
692
+ title=""
693
+ >
694
+ Code and Syntax Highlighting
695
+ </a>
696
+ <br />
697
+ <a
698
+ href="#tables"
699
+ title=""
700
+ >
701
+ Tables
702
+ </a>
703
+ <br />
704
+ <a
705
+ href="#blockquotes"
706
+ title=""
707
+ >
708
+ Blockquotes
709
+ </a>
710
+ <br />
711
+ <a
712
+ href="#html"
713
+ title=""
714
+ >
715
+ Inline HTML
716
+ </a>
717
+ <br />
718
+ <a
719
+ href="#hr"
720
+ title=""
721
+ >
722
+ Horizontal Rule
723
+ </a>
724
+ <br />
725
+ <a
726
+ href="#lines"
727
+ title=""
728
+ >
729
+ Line Breaks
730
+ </a>
731
+ <br />
732
+ <a
733
+ href="#videos"
734
+ title=""
735
+ >
736
+ YouTube Videos
737
+ </a>
738
+ </p>
739
+ <a
740
+ name="headers"
741
+ />
742
+ <h2>
743
+ Headers
744
+ </h2>
745
+ <pre>
746
+ <code
747
+ className="language-no-highlight"
748
+ >
749
+ # H1
750
+ ## H2
751
+ ### H3
752
+ #### H4
753
+ ##### H5
754
+ ###### H6
755
+
756
+ Alternatively, for H1 and H2, an underline-ish style:
757
+
758
+ Alt-H1
759
+ ======
760
+
761
+ Alt-H2
762
+ ------
763
+ </code>
764
+ </pre>
765
+ <h1>
766
+ H1
767
+ </h1>
768
+ <h2>
769
+ H2
770
+ </h2>
771
+ <h3>
772
+ H3
773
+ </h3>
774
+ <h4>
775
+ H4
776
+ </h4>
777
+ <h5>
778
+ H5
779
+ </h5>
780
+ <h6>
781
+ H6
782
+ </h6>
783
+ <p>
784
+ Alternatively, for H1 and H2, an underline-ish style:
785
+ </p>
786
+ <h1>
787
+ Alt-H1
788
+ </h1>
789
+ <h2>
790
+ Alt-H2
791
+ </h2>
792
+ <a
793
+ name="emphasis"
794
+ />
795
+ <h2>
796
+ Emphasis
797
+ </h2>
798
+ <pre>
799
+ <code
800
+ className="language-no-highlight"
801
+ >
802
+ Emphasis, aka italics, with *asterisks* or _underscores_.
803
+
804
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
805
+
806
+ Combined emphasis with **asterisks and _underscores_**.
807
+
808
+ Strikethrough uses two tildes. ~~Scratch this.~~
809
+ </code>
810
+ </pre>
811
+ <p>
812
+ Emphasis, aka italics, with
813
+ <em>
814
+ asterisks
815
+ </em>
816
+ or
817
+ <em>
818
+ underscores
819
+ </em>
820
+ .
821
+ </p>
822
+ <p>
823
+ Strong emphasis, aka bold, with
824
+ <strong>
825
+ asterisks
826
+ </strong>
827
+ or
828
+ <strong>
829
+ underscores
830
+ </strong>
831
+ .
832
+ </p>
833
+ <p>
834
+ Combined emphasis with
835
+ <strong>
836
+ asterisks and
837
+ <em>
838
+ underscores
839
+ </em>
840
+ </strong>
841
+ .
842
+ </p>
843
+ <p>
844
+ Strikethrough uses two tildes.
845
+ <del>
846
+ Scratch this.
847
+ </del>
848
+ </p>
849
+ <a
850
+ name="lists"
851
+ />
852
+ <h2>
853
+ Lists
854
+ </h2>
855
+ <p>
856
+ (In this example, leading and trailing spaces are shown with with dots: ⋅)
857
+ </p>
858
+ <pre>
859
+ <code
860
+ className="language-no-highlight"
861
+ >
862
+ 1. First ordered list item
863
+ 2. Another item
864
+ ⋅⋅* Unordered sub-list.
865
+ 1. Actual numbers don't matter, just that it's a number
866
+ ⋅⋅1. Ordered sub-list
867
+ 4. And another item.
868
+
869
+ ⋅⋅⋅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).
870
+
871
+ ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
872
+ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
873
+ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
874
+
875
+ * Unordered list can use asterisks
876
+ - Or minuses
877
+ + Or pluses
878
+ </code>
879
+ </pre>
880
+ <ol
881
+ start={1}
882
+ >
883
+ <li>
884
+ <p>
885
+ First ordered list item
886
+ </p>
887
+ </li>
888
+ <li>
889
+ <p>
890
+ Another item
891
+ </p>
892
+ </li>
893
+ </ol>
894
+ <ul>
895
+ <li>
896
+ <p>
897
+ Unordered sub-list.
898
+ </p>
899
+ </li>
900
+ </ul>
901
+ <ol
902
+ start={1}
903
+ >
904
+ <li>
905
+ <p>
906
+ Actual numbers don't matter, just that it's a number
907
+ </p>
908
+ </li>
909
+ <li>
910
+ <p>
911
+ Ordered sub-list
912
+ </p>
913
+ </li>
914
+ <li>
915
+ <p>
916
+ And another item.
917
+ </p>
918
+ <p>
919
+ 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).
920
+ </p>
921
+ <p>
922
+ To have a line break without a paragraph, you will need to use two trailing spaces.
923
+ <br />
924
+ Note that this line is separate, but within the same paragraph.
925
+ <br />
926
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
927
+ </p>
928
+ </li>
929
+ </ol>
930
+ <ul>
931
+ <li>
932
+ <p>
933
+ Unordered list can use asterisks
934
+ </p>
935
+ </li>
936
+ </ul>
937
+ <ul>
938
+ <li>
939
+ <p>
940
+ Or minuses
941
+ </p>
942
+ </li>
943
+ </ul>
944
+ <ul>
945
+ <li>
946
+ <p>
947
+ Or pluses
948
+ </p>
949
+ </li>
950
+ </ul>
951
+ <a
952
+ name="links"
953
+ />
954
+ <h2>
955
+ Links
956
+ </h2>
957
+ <p>
958
+ There are two ways to create links.
959
+ </p>
960
+ <pre>
961
+ <code
962
+ className="language-no-highlight"
963
+ >
964
+ [I'm an inline-style link](https://www.google.com)
965
+
966
+ [I'm an inline-style link with title](https://www.google.com "Google's Homepage")
967
+
968
+ [I'm a reference-style link][Arbitrary case-insensitive reference text]
969
+
970
+ [I'm a relative reference to a repository file](../blob/master/LICENSE)
971
+
972
+ [You can use numbers for reference-style link definitions][1]
973
+
974
+ Or leave it empty and use the [link text itself].
975
+
976
+ URLs and URLs in angle brackets will automatically get turned into links.
977
+ http://www.example.com and sometimes
978
+ example.com (but not on Github, for example).
979
+
980
+ Some text to show that the reference links can follow later.
981
+
982
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
983
+ [1]: http://slashdot.org
984
+ [link text itself]: http://www.reddit.com
985
+ </code>
986
+ </pre>
987
+ <p>
988
+ <a
989
+ href="https://www.google.com"
990
+ title=""
991
+ >
992
+ I'm an inline-style link
993
+ </a>
994
+ </p>
995
+ <p>
996
+ <a
997
+ href="https://www.google.com"
998
+ title="Google's Homepage"
999
+ >
1000
+ I'm an inline-style link with title
1001
+ </a>
1002
+ </p>
1003
+ <p>
1004
+ <a
1005
+ href="https://www.mozilla.org"
1006
+ >
1007
+ I'm a reference-style link
1008
+ </a>
1009
+ </p>
1010
+ <p>
1011
+ <a
1012
+ href="../blob/master/LICENSE"
1013
+ title=""
1014
+ >
1015
+ I'm a relative reference to a repository file
1016
+ </a>
1017
+ </p>
1018
+ <p>
1019
+ <a
1020
+ href="http://slashdot.org"
1021
+ >
1022
+ You can use numbers for reference-style link definitions
1023
+ </a>
1024
+ </p>
1025
+ <p>
1026
+ Or leave it empty and use the
1027
+ <a
1028
+ href="http://www.reddit.com"
1029
+ >
1030
+ link text itself
1031
+ </a>
1032
+ .
1033
+ </p>
1034
+ <p>
1035
+ URLs and URLs in angle brackets will automatically get turned into links.
1036
+
1037
+ <a
1038
+ href="http://www.example.com"
1039
+ title=""
1040
+ >
1041
+ http://www.example.com
1042
+ </a>
1043
+ and sometimes
1044
+ example.com (but not on Github, for example).
1045
+ </p>
1046
+ <p>
1047
+ Some text to show that the reference links can follow later.
1048
+ </p>
1049
+ <a
1050
+ name="images"
1051
+ />
1052
+ <h2>
1053
+ Images
1054
+ </h2>
1055
+ <pre>
1056
+ <code
1057
+ className="language-no-highlight"
1058
+ >
1059
+ Here's our logo (hover to see the title text):
1060
+
1061
+ Inline-style:
1062
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
1063
+
1064
+ Reference-style:
1065
+ ![alt text][logo]
1066
+
1067
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
1068
+ </code>
1069
+ </pre>
1070
+ <p>
1071
+ Here's our logo (hover to see the title text):
1072
+ </p>
1073
+ <p>
1074
+ Inline-style:
1075
+
1076
+ <img
1077
+ alt="alt text"
1078
+ src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png"
1079
+ title="Logo Title Text 1"
1080
+ />
1081
+ </p>
1082
+ <p>
1083
+ Reference-style:
1084
+
1085
+ </p>
1086
+ <a
1087
+ name="code"
1088
+ />
1089
+ <h2>
1090
+ Code and Syntax Highlighting
1091
+ </h2>
1092
+ <p>
1093
+ Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and
1094
+ <em>
1095
+ Markdown Here
1096
+ </em>
1097
+ -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer.
1098
+ <em>
1099
+ Markdown Here
1100
+ </em>
1101
+ 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
1102
+ <a
1103
+ href="http://softwaremaniacs.org/media/soft/highlight/test.html"
1104
+ title=""
1105
+ >
1106
+ highlight.js demo page
1107
+ </a>
1108
+ .
1109
+ </p>
1110
+ <pre>
1111
+ <code
1112
+ className="language-no-highlight"
1113
+ >
1114
+ Inline \`code\` has \`back-ticks around\` it.
1115
+ </code>
1116
+ </pre>
1117
+ <p>
1118
+ Inline
1119
+ <code>
1120
+ code
1121
+ </code>
1122
+ has
1123
+ <code>
1124
+ back-ticks around
1125
+ </code>
1126
+ it.
1127
+ </p>
1128
+ <p>
1129
+ Blocks of code are either fenced by lines with three back-ticks
1130
+ <code>
1131
+ \`\`\`
1132
+ </code>
1133
+ , or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
1134
+ </p>
1135
+ <pre>
1136
+ <code
1137
+ className="language-javascript"
1138
+ >
1139
+ var s = "JavaScript syntax highlighting";
1140
+ alert(s);
1141
+ </code>
1142
+ </pre>
1143
+ <pre>
1144
+ <code
1145
+ className="language-python"
1146
+ >
1147
+ s = "Python syntax highlighting"
1148
+ print s
1149
+ </code>
1150
+ </pre>
1151
+ <pre>
1152
+ <code
1153
+ className="language-"
1154
+ >
1155
+ No language indicated, so no syntax highlighting.
1156
+ But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
1157
+ </code>
1158
+ </pre>
1159
+ <pre>
1160
+ <code
1161
+ className="language-javascript"
1162
+ >
1163
+ var s = "JavaScript syntax highlighting";
1164
+ alert(s);
1165
+ </code>
1166
+ </pre>
1167
+ <pre>
1168
+ <code
1169
+ className="language-python"
1170
+ >
1171
+ s = "Python syntax highlighting"
1172
+ print s
1173
+ </code>
1174
+ </pre>
1175
+ <pre>
1176
+ <code
1177
+ className="language-"
1178
+ >
1179
+ No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
1180
+ But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
1181
+ </code>
1182
+ </pre>
1183
+ <a
1184
+ name="tables"
1185
+ />
1186
+ <h2>
1187
+ Tables
1188
+ </h2>
1189
+ <p>
1190
+ Tables aren't part of the core Markdown spec, but they are part of GFM and
1191
+ <em>
1192
+ Markdown Here
1193
+ </em>
1194
+ supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
1195
+ </p>
1196
+ <pre>
1197
+ <code
1198
+ className="language-no-highlight"
1199
+ >
1200
+ Colons can be used to align columns.
1201
+
1202
+ | Tables | Are | Cool |
1203
+ | ------------- |:-------------:| -----:|
1204
+ | col 3 is | right-aligned | $1600 |
1205
+ | col 2 is | centered | $12 |
1206
+ | zebra stripes | are neat | $1 |
1207
+
1208
+ There must be at least 3 dashes separating each header cell.
1209
+ The outer pipes (|) are optional, and you don't need to make the
1210
+ raw Markdown line up prettily. You can also use inline Markdown.
1211
+
1212
+ Markdown | Less | Pretty
1213
+ --- | --- | ---
1214
+ *Still* | \`renders\` | **nicely**
1215
+ 1 | 2 | 3
1216
+ </code>
1217
+ </pre>
1218
+ <p>
1219
+ Colons can be used to align columns.
1220
+ </p>
1221
+ <table>
1222
+ <tr
1223
+ className=""
1224
+ >
1225
+ <td
1226
+ className=""
1227
+ >
1228
+ Tables
1229
+ </td>
1230
+ <td
1231
+ className=""
1232
+ >
1233
+ Are
1234
+ </td>
1235
+ <td
1236
+ className=""
1237
+ >
1238
+ Cool
1239
+ </td>
1240
+ </tr>
1241
+ <tr
1242
+ className=""
1243
+ >
1244
+ <td
1245
+ className=""
1246
+ >
1247
+ col 3 is
1248
+ </td>
1249
+ <td
1250
+ className=""
1251
+ >
1252
+ right-aligned
1253
+ </td>
1254
+ <td
1255
+ className=""
1256
+ >
1257
+ $1600
1258
+ </td>
1259
+ </tr>
1260
+ <tr
1261
+ className=""
1262
+ >
1263
+ <td
1264
+ className=""
1265
+ >
1266
+ col 2 is
1267
+ </td>
1268
+ <td
1269
+ className=""
1270
+ >
1271
+ centered
1272
+ </td>
1273
+ <td
1274
+ className=""
1275
+ >
1276
+ $12
1277
+ </td>
1278
+ </tr>
1279
+ <tr
1280
+ className=""
1281
+ >
1282
+ <td
1283
+ className=""
1284
+ >
1285
+ zebra stripes
1286
+ </td>
1287
+ <td
1288
+ className=""
1289
+ >
1290
+ are neat
1291
+ </td>
1292
+ <td
1293
+ className=""
1294
+ >
1295
+ $1
1296
+ </td>
1297
+ </tr>
1298
+ </table>
1299
+ <p>
1300
+ 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.
1301
+ </p>
1302
+ <table>
1303
+ <tr
1304
+ className=""
1305
+ >
1306
+ <td
1307
+ className=""
1308
+ >
1309
+ Markdown
1310
+ </td>
1311
+ <td
1312
+ className=""
1313
+ >
1314
+ Less
1315
+ </td>
1316
+ <td
1317
+ className=""
1318
+ >
1319
+ Pretty
1320
+ </td>
1321
+ </tr>
1322
+ <tr
1323
+ className=""
1324
+ >
1325
+ <td
1326
+ className=""
1327
+ >
1328
+ <em>
1329
+ Still
1330
+ </em>
1331
+ </td>
1332
+ <td
1333
+ className=""
1334
+ >
1335
+ <code>
1336
+ renders
1337
+ </code>
1338
+ </td>
1339
+ <td
1340
+ className=""
1341
+ >
1342
+ <strong>
1343
+ nicely
1344
+ </strong>
1345
+ </td>
1346
+ </tr>
1347
+ <tr
1348
+ className=""
1349
+ >
1350
+ <td
1351
+ className=""
1352
+ >
1353
+ 1
1354
+ </td>
1355
+ <td
1356
+ className=""
1357
+ >
1358
+ 2
1359
+ </td>
1360
+ <td
1361
+ className=""
1362
+ >
1363
+ 3
1364
+ </td>
1365
+ </tr>
1366
+ </table>
1367
+ <a
1368
+ name="blockquotes"
1369
+ />
1370
+ <h2>
1371
+ Blockquotes
1372
+ </h2>
1373
+ <pre>
1374
+ <code
1375
+ className="language-no-highlight"
1376
+ >
1377
+ &gt; Blockquotes are very handy in email to emulate reply text.
1378
+ &gt; This line is part of the same quote.
1379
+
1380
+ Quote break.
1381
+
1382
+ &gt; 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.
1383
+ </code>
1384
+ </pre>
1385
+ <blockquote>
1386
+ <p>
1387
+ Blockquotes are very handy in email to emulate reply text.
1388
+ This line is part of the same quote.
1389
+ </p>
1390
+ </blockquote>
1391
+ <p>
1392
+ Quote break.
1393
+ </p>
1394
+ <blockquote>
1395
+ <p>
1396
+ 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
1397
+ <em>
1398
+ put
1399
+ </em>
1400
+
1401
+ <strong>
1402
+ Markdown
1403
+ </strong>
1404
+ into a blockquote.
1405
+ </p>
1406
+ </blockquote>
1407
+ <a
1408
+ name="html"
1409
+ />
1410
+ <h2>
1411
+ Inline HTML
1412
+ </h2>
1413
+ <p>
1414
+ You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
1415
+ </p>
1416
+ <pre>
1417
+ <code
1418
+ className="language-no-highlight"
1419
+ >
1420
+ &lt;dl&gt;
1421
+ &lt;dt&gt;Definition list&lt;/dt&gt;
1422
+ &lt;dd&gt;Is something people use sometimes.&lt;/dd&gt;
1423
+
1424
+ &lt;dt&gt;Markdown in HTML&lt;/dt&gt;
1425
+ &lt;dd&gt;Does *not* work **very** well. Use HTML &lt;em&gt;tags&lt;/em&gt;.&lt;/dd&gt;
1426
+ &lt;/dl&gt;
1427
+ </code>
1428
+ </pre>
1429
+ <a
1430
+ name="hr"
1431
+ />
1432
+ <h2>
1433
+ Horizontal Rule
1434
+ </h2>
1435
+ <pre>
1436
+ <code
1437
+ className="language-"
1438
+ >
1439
+ Three or more...
1440
+
1441
+ ---
1442
+
1443
+ Hyphens
1444
+
1445
+ ***
1446
+
1447
+ Asterisks
1448
+
1449
+ ___
1450
+
1451
+ Underscores
1452
+ </code>
1453
+ </pre>
1454
+ <p>
1455
+ Three or more...
1456
+ </p>
1457
+ <hr />
1458
+ <p>
1459
+ Hyphens
1460
+ </p>
1461
+ <hr />
1462
+ <p>
1463
+ Asterisks
1464
+ </p>
1465
+ <hr />
1466
+ <p>
1467
+ Underscores
1468
+ </p>
1469
+ <a
1470
+ name="lines"
1471
+ />
1472
+ <h2>
1473
+ Line Breaks
1474
+ </h2>
1475
+ <p>
1476
+ My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; 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.
1477
+ </p>
1478
+ <p>
1479
+ Here are some things to try out:
1480
+ </p>
1481
+ <pre>
1482
+ <code
1483
+ className="language-"
1484
+ >
1485
+ Here's a line for us to start with.
1486
+
1487
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
1488
+
1489
+ This line is also a separate paragraph, but...
1490
+ This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
1491
+ </code>
1492
+ </pre>
1493
+ <p>
1494
+ Here's a line for us to start with.
1495
+ </p>
1496
+ <p>
1497
+ This line is separated from the one above by two newlines, so it will be a
1498
+ <em>
1499
+ separate paragraph
1500
+ </em>
1501
+ .
1502
+ </p>
1503
+ <p>
1504
+ This line is also begins a separate paragraph, but...
1505
+ <br />
1506
+ This line is only separated by a single newline, so it's a separate line in the
1507
+ <em>
1508
+ same paragraph
1509
+ </em>
1510
+ .
1511
+ </p>
1512
+ <p>
1513
+ (Technical note:
1514
+ <em>
1515
+ Markdown Here
1516
+ </em>
1517
+ uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
1518
+ </p>
1519
+ <a
1520
+ name="videos"
1521
+ />
1522
+ <h2>
1523
+ YouTube Videos
1524
+ </h2>
1525
+ <p>
1526
+ They can't be added directly but you can add an image with a link to the video like this:
1527
+ </p>
1528
+ <pre>
1529
+ <code
1530
+ className="language-no-highlight"
1531
+ >
1532
+ &lt;a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
1533
+ " target="_blank"&gt;&lt;img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
1534
+ alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /&gt;&lt;/a&gt;
1535
+ </code>
1536
+ </pre>
1537
+ <p>
1538
+ Or, in pure Markdown, but losing the image sizing and border:
1539
+ </p>
1540
+ <pre>
1541
+ <code
1542
+ className="language-no-highlight"
1543
+ >
1544
+ [![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
1545
+ </code>
1546
+ </pre>
1547
+ </React.Fragment>,
1548
+ }
1549
+ `);
1550
+ });
1551
+ //# sourceMappingURL=safe-mdx.test.js.map