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