safe-mdx 0.0.0 → 0.0.2

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