safe-mdx 0.0.5 → 0.1.0

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.
@@ -1,15 +1,17 @@
1
- import React from 'react'
2
1
  import dedent from 'dedent'
3
- import { test, expect } from 'vitest'
4
- import { MdastToJsx } from './safe-mdx.js'
2
+ import React from 'react'
5
3
  import { renderToStaticMarkup } from 'react-dom/server'
4
+ import { expect, test } from 'vitest'
5
+ import { mdastBfs, MdastToJsx, mdxParse } from './safe-mdx.js'
6
+ import { remark } from 'remark'
7
+ import remarkMdx from 'remark-mdx'
6
8
  void React
7
9
 
8
10
  const components = {
9
11
  Heading({ level, children }) {
10
12
  return <h1>{children}</h1>
11
13
  },
12
- } as any
14
+ }
13
15
 
14
16
  function render(code) {
15
17
  const visitor = new MdastToJsx({ code, components })
@@ -18,6 +20,158 @@ function render(code) {
18
20
  // console.log(JSON.stringify(result, null, 2))
19
21
  return { result, errors: visitor.errors || [], html }
20
22
  }
23
+ import { htmlToJsx } from 'html-to-jsx-transform'
24
+
25
+ test('htmlToJsx', () => {
26
+ expect(htmlToJsx('<p x="y">')).toMatchInlineSnapshot(`"<p x="y" />"`)
27
+ expect(htmlToJsx('<p>text</p>')).toMatchInlineSnapshot(`"<p>text</p>"`)
28
+ expect(htmlToJsx('before <p>text</p>')).toMatchInlineSnapshot(`"<>before <p>text</p></>"`)
29
+ expect(htmlToJsx('<nonexisting>text</nonexisting>')).toMatchInlineSnapshot(
30
+ `"<nonexisting>text</nonexisting>"`,
31
+ )
32
+ })
33
+
34
+ test('markdown inside jsx', () => {
35
+ const code = dedent`
36
+ # Hello
37
+
38
+ <Heading prop="value">
39
+ Component *children*
40
+ </Heading>
41
+
42
+ <figure>
43
+ some *bold* content
44
+ </figure>
45
+
46
+ `
47
+
48
+ expect(render(code)).toMatchInlineSnapshot(`
49
+ {
50
+ "errors": [],
51
+ "html": "<h1>Hello</h1><h1><p>Component <em>children</em></p></h1><figure><p>some <em>bold</em> content</p></figure>",
52
+ "result": <React.Fragment>
53
+ <h1>
54
+ Hello
55
+ </h1>
56
+ <Heading
57
+ prop="value"
58
+ >
59
+ <p>
60
+ Component
61
+ <em>
62
+ children
63
+ </em>
64
+ </p>
65
+ </Heading>
66
+ <figure>
67
+ <p>
68
+ some
69
+ <em>
70
+ bold
71
+ </em>
72
+ content
73
+ </p>
74
+ </figure>
75
+ </React.Fragment>,
76
+ }
77
+ `)
78
+ })
79
+
80
+ test('remark and jsx does not wrap in p', () => {
81
+ const code = dedent`
82
+ ---
83
+ title: createSearchParams
84
+ ---
85
+
86
+ # Hello
87
+
88
+ i am a paragraph
89
+
90
+ <Heading>heading</Heading>
91
+
92
+ sone \`inline code\`
93
+
94
+ \`\`\`tsx
95
+ some code
96
+ \`\`\`
97
+
98
+ what
99
+ `
100
+ const mdast = mdxParse(code)
101
+
102
+ mdastBfs(mdast, (x) => {
103
+ delete x.position
104
+ })
105
+ expect(mdast).toMatchInlineSnapshot(`
106
+ {
107
+ "children": [
108
+ {
109
+ "type": "yaml",
110
+ "value": "title: createSearchParams",
111
+ },
112
+ {
113
+ "children": [
114
+ {
115
+ "type": "text",
116
+ "value": "Hello",
117
+ },
118
+ ],
119
+ "depth": 1,
120
+ "type": "heading",
121
+ },
122
+ {
123
+ "children": [
124
+ {
125
+ "type": "text",
126
+ "value": "i am a paragraph",
127
+ },
128
+ ],
129
+ "type": "paragraph",
130
+ },
131
+ {
132
+ "attributes": [],
133
+ "children": [
134
+ {
135
+ "type": "text",
136
+ "value": "heading",
137
+ },
138
+ ],
139
+ "name": "Heading",
140
+ "type": "mdxJsxFlowElement",
141
+ },
142
+ {
143
+ "children": [
144
+ {
145
+ "type": "text",
146
+ "value": "sone ",
147
+ },
148
+ {
149
+ "type": "inlineCode",
150
+ "value": "inline code",
151
+ },
152
+ ],
153
+ "type": "paragraph",
154
+ },
155
+ {
156
+ "lang": "tsx",
157
+ "meta": null,
158
+ "type": "code",
159
+ "value": "some code",
160
+ },
161
+ {
162
+ "children": [
163
+ {
164
+ "type": "text",
165
+ "value": "what",
166
+ },
167
+ ],
168
+ "type": "paragraph",
169
+ },
170
+ ],
171
+ "type": "root",
172
+ }
173
+ `)
174
+ })
21
175
 
22
176
  test('basic', () => {
23
177
  expect(
@@ -25,11 +179,13 @@ test('basic', () => {
25
179
  # Hello
26
180
 
27
181
  i am a paragraph
182
+
183
+ <Heading>heading</Heading>
28
184
  `),
29
185
  ).toMatchInlineSnapshot(`
30
186
  {
31
187
  "errors": [],
32
- "html": "<h1>Hello</h1><p>i am a paragraph</p>",
188
+ "html": "<h1>Hello</h1><p>i am a paragraph</p><h1>heading</h1>",
33
189
  "result": <React.Fragment>
34
190
  <h1>
35
191
  Hello
@@ -37,6 +193,9 @@ test('basic', () => {
37
193
  <p>
38
194
  i am a paragraph
39
195
  </p>
196
+ <Heading>
197
+ heading
198
+ </Heading>
40
199
  </React.Fragment>,
41
200
  }
42
201
  `)
@@ -47,7 +206,7 @@ test('frontmatter', () => {
47
206
  ---
48
207
  hello: 5
49
208
  ---
50
-
209
+
51
210
  # Hello
52
211
 
53
212
  i am a paragraph
@@ -159,7 +318,7 @@ test('table, only head', () => {
159
318
 
160
319
  | Tables | Are | Cool |
161
320
  | ------------- |:-------------:| -----:|
162
-
321
+
163
322
  `),
164
323
  ).toMatchInlineSnapshot(`
165
324
  {
@@ -205,15 +364,13 @@ test('inline jsx', () => {
205
364
  ).toMatchInlineSnapshot(`
206
365
  {
207
366
  "errors": [],
208
- "html": "<p><h1>hello</h1></p>",
367
+ "html": "<h1>hello</h1>",
209
368
  "result": <React.Fragment>
210
- <p>
211
- <Heading
212
- level={2}
213
- >
214
- hello
215
- </Heading>
216
- </p>
369
+ <Heading
370
+ level={2}
371
+ >
372
+ hello
373
+ </Heading>
217
374
  </React.Fragment>,
218
375
  }
219
376
  `)
@@ -292,7 +449,7 @@ test('missing components are ignored', () => {
292
449
  test('props parsing', () => {
293
450
  expect(
294
451
  render(dedent`
295
- <Heading
452
+ <Heading
296
453
  num={2}
297
454
  doublequote={"a \" string"}
298
455
  quote={'a \' string'}
@@ -325,7 +482,7 @@ test('props parsing', () => {
325
482
  "message": "Expressions in jsx props are not supported (jsx={<SomeComponent />})",
326
483
  },
327
484
  {
328
- "message": "Expressions in jsx props are not supported (...{ spread: true })",
485
+ "message": "Expressions in jsx props are not supported (...{ spread: true })",
329
486
  },
330
487
  ],
331
488
  "html": "<h1><p>hi</p></h1>",
@@ -354,21 +511,21 @@ test('props parsing', () => {
354
511
  test('breaks', () => {
355
512
  expect(
356
513
  render(dedent`
357
- To have a line break without a paragraph, you will need to use two trailing spaces.
358
- Note that this line is separate, but within the same paragraph.
514
+ To have a line break without a paragraph, you will need to use two trailing spaces.
515
+ Note that this line is separate, but within the same paragraph.
359
516
  (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
360
517
  `),
361
518
  ).toMatchInlineSnapshot(`
362
519
  {
363
520
  "errors": [],
364
- "html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
521
+ "html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.
522
+ Note that this line is separate, but within the same paragraph.
523
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
365
524
  "result": <React.Fragment>
366
525
  <p>
367
526
  To have a line break without a paragraph, you will need to use two trailing spaces.
368
- <br />
369
- Note that this line is separate, but within the same paragraph.
370
- <br />
371
- (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
527
+ Note that this line is separate, but within the same paragraph.
528
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
372
529
  </p>
373
530
  </React.Fragment>,
374
531
  }
@@ -381,410 +538,410 @@ test('kitchen sink', () => {
381
538
  render(dedent`
382
539
  # Markdown Kitchen Sink
383
540
  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.
384
-
541
+
385
542
  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/).
386
-
543
+
387
544
  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).
388
-
389
- ##### Table of Contents
390
- [Headers](#headers)
391
- [Emphasis](#emphasis)
392
- [Lists](#lists)
393
- [Links](#links)
394
- [Images](#images)
395
- [Code and Syntax Highlighting](#code)
396
- [Tables](#tables)
397
- [Blockquotes](#blockquotes)
398
- [Inline HTML](#html)
399
- [Horizontal Rule](#hr)
400
- [Line Breaks](#lines)
401
- [YouTube Videos](#videos)
402
-
545
+
546
+ ##### Table of Contents
547
+ [Headers](#headers)
548
+ [Emphasis](#emphasis)
549
+ [Lists](#lists)
550
+ [Links](#links)
551
+ [Images](#images)
552
+ [Code and Syntax Highlighting](#code)
553
+ [Tables](#tables)
554
+ [Blockquotes](#blockquotes)
555
+ [Inline HTML](#html)
556
+ [Horizontal Rule](#hr)
557
+ [Line Breaks](#lines)
558
+ [YouTube Videos](#videos)
559
+
403
560
  <a name="headers"></a>
404
-
561
+
405
562
  ## Headers
406
-
407
-
563
+
564
+
408
565
  # H1
409
566
  ## H2
410
567
  ### H3
411
568
  #### H4
412
569
  ##### H5
413
570
  ###### H6
414
-
571
+
415
572
  Alternatively, for H1 and H2, an underline-ish style:
416
-
573
+
417
574
  Alt-H1
418
575
  ======
419
-
576
+
420
577
  Alt-H2
421
578
  ------
422
-
423
-
579
+
580
+
424
581
  # H1
425
582
  ## H2
426
583
  ### H3
427
584
  #### H4
428
585
  ##### H5
429
586
  ###### H6
430
-
587
+
431
588
  Alternatively, for H1 and H2, an underline-ish style:
432
-
589
+
433
590
  Alt-H1
434
591
  ======
435
-
592
+
436
593
  Alt-H2
437
594
  ------
438
-
595
+
439
596
  <a name="emphasis"></a>
440
-
597
+
441
598
  ## Emphasis
442
-
599
+
443
600
  \`\`\`no-highlight
444
601
  Emphasis, aka italics, with *asterisks* or _underscores_.
445
-
602
+
446
603
  Strong emphasis, aka bold, with **asterisks** or __underscores__.
447
-
604
+
448
605
  Combined emphasis with **asterisks and _underscores_**.
449
-
606
+
450
607
  Strikethrough uses two tildes. ~~Scratch this.~~
451
608
  \`\`\`
452
-
609
+
453
610
  Emphasis, aka italics, with *asterisks* or _underscores_.
454
-
611
+
455
612
  Strong emphasis, aka bold, with **asterisks** or __underscores__.
456
-
613
+
457
614
  Combined emphasis with **asterisks and _underscores_**.
458
-
615
+
459
616
  Strikethrough uses two tildes. ~~Scratch this.~~
460
-
461
-
617
+
618
+
462
619
  <a name="lists"></a>
463
-
620
+
464
621
  ## Lists
465
-
622
+
466
623
  (In this example, leading and trailing spaces are shown with with dots: ⋅)
467
-
624
+
468
625
  \`\`\`no-highlight
469
626
  1. First ordered list item
470
627
  2. Another item
471
- ⋅⋅* Unordered sub-list.
628
+ ⋅⋅* Unordered sub-list.
472
629
  1. Actual numbers don't matter, just that it's a number
473
630
  ⋅⋅1. Ordered sub-list
474
631
  4. And another item.
475
-
632
+
476
633
  ⋅⋅⋅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).
477
-
634
+
478
635
  ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
479
636
  ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
480
637
  ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
481
-
638
+
482
639
  * Unordered list can use asterisks
483
640
  - Or minuses
484
641
  + Or pluses
485
642
  \`\`\`
486
-
643
+
487
644
  1. First ordered list item
488
645
  2. Another item
489
- * Unordered sub-list.
646
+ * Unordered sub-list.
490
647
  1. Actual numbers don't matter, just that it's a number
491
648
  1. Ordered sub-list
492
649
  4. And another item.
493
-
650
+
494
651
  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).
495
-
496
- To have a line break without a paragraph, you will need to use two trailing spaces.
497
- Note that this line is separate, but within the same paragraph.
652
+
653
+ To have a line break without a paragraph, you will need to use two trailing spaces.
654
+ Note that this line is separate, but within the same paragraph.
498
655
  (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
499
-
656
+
500
657
  * Unordered list can use asterisks
501
658
  - Or minuses
502
659
  + Or pluses
503
-
660
+
504
661
  <a name="links"></a>
505
-
662
+
506
663
  ## Links
507
-
664
+
508
665
  There are two ways to create links.
509
-
666
+
510
667
  \`\`\`no-highlight
511
668
  [I'm an inline-style link](https://www.google.com)
512
-
669
+
513
670
  [I'm an inline-style link with title](https://www.google.com "Google's Homepage")
514
-
671
+
515
672
  [I'm a reference-style link][Arbitrary case-insensitive reference text]
516
-
673
+
517
674
  [I'm a relative reference to a repository file](../blob/master/LICENSE)
518
-
675
+
519
676
  [You can use numbers for reference-style link definitions][1]
520
-
677
+
521
678
  Or leave it empty and use the [link text itself].
522
-
523
- URLs and URLs in angle brackets will automatically get turned into links.
524
- http://www.example.com and sometimes
679
+
680
+ URLs and URLs in angle brackets will automatically get turned into links.
681
+ http://www.example.com and sometimes
525
682
  example.com (but not on Github, for example).
526
-
683
+
527
684
  Some text to show that the reference links can follow later.
528
-
685
+
529
686
  [arbitrary case-insensitive reference text]: https://www.mozilla.org
530
687
  [1]: http://slashdot.org
531
688
  [link text itself]: http://www.reddit.com
532
689
  \`\`\`
533
-
690
+
534
691
  [I'm an inline-style link](https://www.google.com)
535
-
692
+
536
693
  [I'm an inline-style link with title](https://www.google.com "Google's Homepage")
537
-
694
+
538
695
  [I'm a reference-style link][Arbitrary case-insensitive reference text]
539
-
696
+
540
697
  [I'm a relative reference to a repository file](../blob/master/LICENSE)
541
-
698
+
542
699
  [You can use numbers for reference-style link definitions][1]
543
-
700
+
544
701
  Or leave it empty and use the [link text itself].
545
-
546
- URLs and URLs in angle brackets will automatically get turned into links.
547
- http://www.example.com and sometimes
702
+
703
+ URLs and URLs in angle brackets will automatically get turned into links.
704
+ http://www.example.com and sometimes
548
705
  example.com (but not on Github, for example).
549
-
706
+
550
707
  Some text to show that the reference links can follow later.
551
-
708
+
552
709
  [arbitrary case-insensitive reference text]: https://www.mozilla.org
553
710
  [1]: http://slashdot.org
554
711
  [link text itself]: http://www.reddit.com
555
-
712
+
556
713
  <a name="images"></a>
557
-
714
+
558
715
  ## Images
559
-
716
+
560
717
  \`\`\`no-highlight
561
718
  Here's our logo (hover to see the title text):
562
-
563
- Inline-style:
719
+
720
+ Inline-style:
564
721
  ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
565
-
566
- Reference-style:
722
+
723
+ Reference-style:
567
724
  ![alt text][logo]
568
-
725
+
569
726
  [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
570
727
  \`\`\`
571
-
728
+
572
729
  Here's our logo (hover to see the title text):
573
-
574
- Inline-style:
730
+
731
+ Inline-style:
575
732
  ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
576
-
577
- Reference-style:
733
+
734
+ Reference-style:
578
735
  ![alt text][logo]
579
-
736
+
580
737
  [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
581
-
738
+
582
739
  <a name="code"></a>
583
-
740
+
584
741
  ## Code and Syntax Highlighting
585
-
742
+
586
743
  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).
587
-
744
+
588
745
  \`\`\`no-highlight
589
746
  Inline \`code\` has \`back-ticks around\` it.
590
747
  \`\`\`
591
-
748
+
592
749
  Inline \`code\` has \`back-ticks around\` it.
593
-
750
+
594
751
  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.
595
-
752
+
596
753
  \`\`\`javascript
597
754
  var s = "JavaScript syntax highlighting";
598
755
  alert(s);
599
756
  \`\`\`
600
-
757
+
601
758
  \`\`\`python
602
759
  s = "Python syntax highlighting"
603
760
  print s
604
761
  \`\`\`
605
-
762
+
606
763
  \`\`\`
607
- No language indicated, so no syntax highlighting.
764
+ No language indicated, so no syntax highlighting.
608
765
  But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
609
766
  \`\`\`
610
-
611
-
612
-
613
-
767
+
768
+
769
+
770
+
614
771
  \`\`\`javascript
615
772
  var s = "JavaScript syntax highlighting";
616
773
  alert(s);
617
774
  \`\`\`
618
-
775
+
619
776
  \`\`\`python
620
777
  s = "Python syntax highlighting"
621
778
  print s
622
779
  \`\`\`
623
-
780
+
624
781
  \`\`\`
625
- No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
782
+ No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
626
783
  But let's throw in a <b>tag</b>.
627
784
  \`\`\`
628
-
629
-
785
+
786
+
630
787
  <a name="tables"></a>
631
-
788
+
632
789
  ## Tables
633
-
790
+
634
791
  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.
635
-
792
+
636
793
  \`\`\`no-highlight
637
794
  Colons can be used to align columns.
638
-
795
+
639
796
  | Tables | Are | Cool |
640
797
  | ------------- |:-------------:| -----:|
641
798
  | col 3 is | right-aligned | $1600 |
642
799
  | col 2 is | centered | $12 |
643
800
  | zebra stripes | are neat | $1 |
644
-
801
+
645
802
  There must be at least 3 dashes separating each header cell.
646
- The outer pipes (|) are optional, and you don't need to make the
803
+ The outer pipes (|) are optional, and you don't need to make the
647
804
  raw Markdown line up prettily. You can also use inline Markdown.
648
-
805
+
649
806
  Markdown | Less | Pretty
650
807
  --- | --- | ---
651
808
  *Still* | \`renders\` | **nicely**
652
809
  1 | 2 | 3
653
810
  \`\`\`
654
-
811
+
655
812
  Colons can be used to align columns.
656
-
813
+
657
814
  | Tables | Are | Cool |
658
815
  | ------------- |:-------------:| -----:|
659
816
  | col 3 is | right-aligned | $1600 |
660
817
  | col 2 is | centered | $12 |
661
818
  | zebra stripes | are neat | $1 |
662
-
819
+
663
820
  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.
664
-
821
+
665
822
  Markdown | Less | Pretty
666
823
  --- | --- | ---
667
824
  *Still* | \`renders\` | **nicely**
668
825
  1 | 2 | 3
669
-
826
+
670
827
  <a name="blockquotes"></a>
671
-
828
+
672
829
  ## Blockquotes
673
-
830
+
674
831
  \`\`\`no-highlight
675
832
  > Blockquotes are very handy in email to emulate reply text.
676
833
  > This line is part of the same quote.
677
-
834
+
678
835
  Quote break.
679
-
680
- > 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.
836
+
837
+ > 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.
681
838
  \`\`\`
682
-
839
+
683
840
  > Blockquotes are very handy in email to emulate reply text.
684
841
  > This line is part of the same quote.
685
-
842
+
686
843
  Quote break.
687
-
688
- > 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.
689
-
844
+
845
+ > 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.
846
+
690
847
  <a name="html"></a>
691
-
848
+
692
849
  ## Inline HTML
693
-
694
- You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
695
-
850
+
851
+ You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
852
+
696
853
  \`\`\`no-highlight
697
854
  <dl>
698
855
  <dt>Definition list</dt>
699
856
  <dd>Is something people use sometimes.</dd>
700
-
857
+
701
858
  <dt>Markdown in HTML</dt>
702
859
  <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
703
860
  </dl>
704
861
  \`\`\`
705
-
862
+
706
863
  <dl>
707
864
  <dt>Definition list</dt>
708
865
  <dd>Is something people use sometimes.</dd>
709
-
866
+
710
867
  <dt>Markdown in HTML</dt>
711
868
  <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
712
869
  </dl>
713
-
870
+
714
871
  <a name="hr"></a>
715
-
872
+
716
873
  ## Horizontal Rule
717
-
874
+
718
875
  \`\`\`
719
876
  Three or more...
720
-
877
+
721
878
  ---
722
-
879
+
723
880
  Hyphens
724
-
881
+
725
882
  ***
726
-
883
+
727
884
  Asterisks
728
-
885
+
729
886
  ___
730
-
887
+
731
888
  Underscores
732
889
  \`\`\`
733
-
890
+
734
891
  Three or more...
735
-
892
+
736
893
  ---
737
-
894
+
738
895
  Hyphens
739
-
896
+
740
897
  ***
741
-
898
+
742
899
  Asterisks
743
-
900
+
744
901
  ___
745
-
902
+
746
903
  Underscores
747
-
904
+
748
905
  <a name="lines"></a>
749
-
906
+
750
907
  ## Line Breaks
751
-
752
- 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.
753
-
908
+
909
+ 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.
910
+
754
911
  Here are some things to try out:
755
-
912
+
756
913
  \`\`\`
757
914
  Here's a line for us to start with.
758
-
915
+
759
916
  This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
760
-
917
+
761
918
  This line is also a separate paragraph, but...
762
919
  This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
763
920
  \`\`\`
764
-
921
+
765
922
  Here's a line for us to start with.
766
-
923
+
767
924
  This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
768
-
769
- This line is also begins a separate paragraph, but...
925
+
926
+ This line is also begins a separate paragraph, but...
770
927
  This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
771
-
928
+
772
929
  (Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
773
-
930
+
774
931
  <a name="videos"></a>
775
-
932
+
776
933
  ## YouTube Videos
777
-
934
+
778
935
  They can't be added directly but you can add an image with a link to the video like this:
779
-
936
+
780
937
  \`\`\`no-highlight
781
938
  <a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
782
- " target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
939
+ " target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
783
940
  alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
784
941
  \`\`\`
785
-
942
+
786
943
  Or, in pure Markdown, but losing the image sizing and border:
787
-
944
+
788
945
  \`\`\`no-highlight
789
946
  [![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)
790
947
  \`\`\`
@@ -794,10 +951,48 @@ test('kitchen sink', () => {
794
951
  {
795
952
  "errors": [
796
953
  {
797
- "message": "Unsupported jsx component dl",
954
+ "message": "Unsupported language no-highlight",
955
+ },
956
+ {
957
+ "message": "Unsupported language no-highlight",
958
+ },
959
+ {
960
+ "message": "Unsupported language no-highlight",
961
+ },
962
+ {
963
+ "message": "Unsupported language no-highlight",
964
+ },
965
+ {
966
+ "message": "Unsupported language no-highlight",
967
+ },
968
+ {
969
+ "message": "Unsupported language no-highlight",
970
+ },
971
+ {
972
+ "message": "Unsupported language no-highlight",
973
+ },
974
+ {
975
+ "message": "Unsupported language no-highlight",
976
+ },
977
+ {
978
+ "message": "Unsupported language no-highlight",
979
+ },
980
+ {
981
+ "message": "Unsupported language no-highlight",
798
982
  },
799
983
  ],
800
- "html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it&#x27;s styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber&#x27;s original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that&#x27;s what you&#x27;re looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
984
+ "html": "<link rel="preload" as="image" href="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png"/><h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it&#x27;s styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber&#x27;s original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that&#x27;s what you&#x27;re looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a>
985
+ <a href="#emphasis" title="">Emphasis</a>
986
+ <a href="#lists" title="">Lists</a>
987
+ <a href="#links" title="">Links</a>
988
+ <a href="#images" title="">Images</a>
989
+ <a href="#code" title="">Code and Syntax Highlighting</a>
990
+ <a href="#tables" title="">Tables</a>
991
+ <a href="#blockquotes" title="">Blockquotes</a>
992
+ <a href="#html" title="">Inline HTML</a>
993
+ <a href="#hr" title="">Horizontal Rule</a>
994
+ <a href="#lines" title="">Line Breaks</a>
995
+ <a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
801
996
 
802
997
  Strong emphasis, aka bold, with **asterisks** or __underscores__.
803
998
 
@@ -805,7 +1000,7 @@ test('kitchen sink', () => {
805
1000
 
806
1001
  Strikethrough uses two tildes. ~~Scratch this.~~</code></pre><p>Emphasis, aka italics, with <em>asterisks</em> or <em>underscores</em>.</p><p>Strong emphasis, aka bold, with <strong>asterisks</strong> or <strong>underscores</strong>.</p><p>Combined emphasis with <strong>asterisks and <em>underscores</em></strong>.</p><p>Strikethrough uses two tildes. <del>Scratch this.</del></p><a name="lists"></a><h2>Lists</h2><p>(In this example, leading and trailing spaces are shown with with dots: ⋅)</p><pre><code>1. First ordered list item
807
1002
  2. Another item
808
- ⋅⋅* Unordered sub-list.
1003
+ ⋅⋅* Unordered sub-list.
809
1004
  1. Actual numbers don&#x27;t matter, just that it&#x27;s a number
810
1005
  ⋅⋅1. Ordered sub-list
811
1006
  4. And another item.
@@ -818,7 +1013,9 @@ test('kitchen sink', () => {
818
1013
 
819
1014
  * Unordered list can use asterisks
820
1015
  - Or minuses
821
- + Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don&#x27;t matter, just that it&#x27;s a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I&#x27;m an inline-style link](https://www.google.com)
1016
+ + Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don&#x27;t matter, just that it&#x27;s a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.
1017
+ Note that this line is separate, but within the same paragraph.
1018
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I&#x27;m an inline-style link](https://www.google.com)
822
1019
 
823
1020
  [I&#x27;m an inline-style link with title](https://www.google.com &quot;Google&#x27;s Homepage&quot;)
824
1021
 
@@ -830,8 +1027,8 @@ test('kitchen sink', () => {
830
1027
 
831
1028
  Or leave it empty and use the [link text itself].
832
1029
 
833
- URLs and URLs in angle brackets will automatically get turned into links.
834
- http://www.example.com and sometimes
1030
+ URLs and URLs in angle brackets will automatically get turned into links.
1031
+ http://www.example.com and sometimes
835
1032
  example.com (but not on Github, for example).
836
1033
 
837
1034
  Some text to show that the reference links can follow later.
@@ -842,20 +1039,20 @@ test('kitchen sink', () => {
842
1039
  <a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
843
1040
  example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here&#x27;s our logo (hover to see the title text):
844
1041
 
845
- Inline-style:
1042
+ Inline-style:
846
1043
  ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 1&quot;)
847
1044
 
848
- Reference-style:
1045
+ Reference-style:
849
1046
  ![alt text][logo]
850
1047
 
851
1048
  [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 2&quot;</code></pre><p>Here&#x27;s our logo (hover to see the title text):</p><p>Inline-style:
852
1049
  <img src="https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png" alt="alt text" title="Logo Title Text 1"/></p><p>Reference-style:
853
- </p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn&#x27;t. However, many renderers -- like Github&#x27;s and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they&#x27;re easier and only they support syntax highlighting.</p><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
854
- alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
855
- print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
856
- But let&#x27;s throw in a &amp;lt;b&amp;gt;tag&amp;lt;/b&amp;gt;.</code></pre><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
857
- alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
858
- print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
1050
+ </p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn&#x27;t. However, many renderers -- like Github&#x27;s and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they&#x27;re easier and only they support syntax highlighting.</p><pre><code class="language-javascript">var s = &quot;JavaScript syntax highlighting&quot;;
1051
+ alert(s);</code></pre><pre><code class="language-python">s = &quot;Python syntax highlighting&quot;
1052
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
1053
+ But let&#x27;s throw in a &amp;lt;b&amp;gt;tag&amp;lt;/b&amp;gt;.</code></pre><pre><code class="language-javascript">var s = &quot;JavaScript syntax highlighting&quot;;
1054
+ alert(s);</code></pre><pre><code class="language-python">s = &quot;Python syntax highlighting&quot;
1055
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
859
1056
  But let&#x27;s throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren&#x27;t part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
860
1057
 
861
1058
  | Tables | Are | Cool |
@@ -865,7 +1062,7 @@ test('kitchen sink', () => {
865
1062
  | zebra stripes | are neat | $1 |
866
1063
 
867
1064
  There must be at least 3 dashes separating each header cell.
868
- The outer pipes (|) are optional, and you don&#x27;t need to make the
1065
+ The outer pipes (|) are optional, and you don&#x27;t need to make the
869
1066
  raw Markdown line up prettily. You can also use inline Markdown.
870
1067
 
871
1068
  Markdown | Less | Pretty
@@ -876,14 +1073,14 @@ test('kitchen sink', () => {
876
1073
 
877
1074
  Quote break.
878
1075
 
879
- &gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
1076
+ &gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.</code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
880
1077
  This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it&#x27;ll mostly work pretty well.</p><pre><code>&lt;dl&gt;
881
1078
  &lt;dt&gt;Definition list&lt;/dt&gt;
882
1079
  &lt;dd&gt;Is something people use sometimes.&lt;/dd&gt;
883
1080
 
884
1081
  &lt;dt&gt;Markdown in HTML&lt;/dt&gt;
885
1082
  &lt;dd&gt;Does *not* work **very** well. Use HTML &lt;em&gt;tags&lt;/em&gt;.&lt;/dd&gt;
886
- &lt;/dl&gt;</code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
1083
+ &lt;/dl&gt;</code></pre><dl><dt>Definition list</dt><dd>Is something people use sometimes.</dd><dt>Markdown in HTML</dt><dd>Does <em>not</em> work <strong>very</strong> well. Use HTML <em>tags</em>.</dd></dl><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
887
1084
 
888
1085
  ---
889
1086
 
@@ -900,8 +1097,9 @@ test('kitchen sink', () => {
900
1097
  This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
901
1098
 
902
1099
  This line is also a separate paragraph, but...
903
- This line is only separated by a single newline, so it&#x27;s a separate line in the *same paragraph*.</code></pre><p>Here&#x27;s a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it&#x27;s a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there&#x27;s no need to use MD&#x27;s two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can&#x27;t be added directly but you can add an image with a link to the video like this:</p><pre><code>&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;v=YOUTUBE_VIDEO_ID_HERE
904
- &quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg&quot;
1100
+ This line is only separated by a single newline, so it&#x27;s a separate line in the *same paragraph*.</code></pre><p>Here&#x27;s a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...
1101
+ This line is only separated by a single newline, so it&#x27;s a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there&#x27;s no need to use MD&#x27;s two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can&#x27;t be added directly but you can add an image with a link to the video like this:</p><pre><code>&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;v=YOUTUBE_VIDEO_ID_HERE
1102
+ &quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg&quot;
905
1103
  alt=&quot;IMAGE ALT TEXT HERE&quot; width=&quot;240&quot; height=&quot;180&quot; border=&quot;10&quot; /&gt;&lt;/a&gt;</code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[![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)</code></pre>",
906
1104
  "result": <React.Fragment>
907
1105
  <h1>
@@ -975,77 +1173,88 @@ test('kitchen sink', () => {
975
1173
  >
976
1174
  Headers
977
1175
  </a>
978
- <br />
1176
+
1177
+
979
1178
  <a
980
1179
  href="#emphasis"
981
1180
  title=""
982
1181
  >
983
1182
  Emphasis
984
1183
  </a>
985
- <br />
1184
+
1185
+
986
1186
  <a
987
1187
  href="#lists"
988
1188
  title=""
989
1189
  >
990
1190
  Lists
991
1191
  </a>
992
- <br />
1192
+
1193
+
993
1194
  <a
994
1195
  href="#links"
995
1196
  title=""
996
1197
  >
997
1198
  Links
998
1199
  </a>
999
- <br />
1200
+
1201
+
1000
1202
  <a
1001
1203
  href="#images"
1002
1204
  title=""
1003
1205
  >
1004
1206
  Images
1005
1207
  </a>
1006
- <br />
1208
+
1209
+
1007
1210
  <a
1008
1211
  href="#code"
1009
1212
  title=""
1010
1213
  >
1011
1214
  Code and Syntax Highlighting
1012
1215
  </a>
1013
- <br />
1216
+
1217
+
1014
1218
  <a
1015
1219
  href="#tables"
1016
1220
  title=""
1017
1221
  >
1018
1222
  Tables
1019
1223
  </a>
1020
- <br />
1224
+
1225
+
1021
1226
  <a
1022
1227
  href="#blockquotes"
1023
1228
  title=""
1024
1229
  >
1025
1230
  Blockquotes
1026
1231
  </a>
1027
- <br />
1232
+
1233
+
1028
1234
  <a
1029
1235
  href="#html"
1030
1236
  title=""
1031
1237
  >
1032
1238
  Inline HTML
1033
1239
  </a>
1034
- <br />
1240
+
1241
+
1035
1242
  <a
1036
1243
  href="#hr"
1037
1244
  title=""
1038
1245
  >
1039
1246
  Horizontal Rule
1040
1247
  </a>
1041
- <br />
1248
+
1249
+
1042
1250
  <a
1043
1251
  href="#lines"
1044
1252
  title=""
1045
1253
  >
1046
1254
  Line Breaks
1047
1255
  </a>
1048
- <br />
1256
+
1257
+
1049
1258
  <a
1050
1259
  href="#videos"
1051
1260
  title=""
@@ -1181,7 +1390,7 @@ test('kitchen sink', () => {
1181
1390
  <code>
1182
1391
  1. First ordered list item
1183
1392
  2. Another item
1184
- ⋅⋅* Unordered sub-list.
1393
+ ⋅⋅* Unordered sub-list.
1185
1394
  1. Actual numbers don't matter, just that it's a number
1186
1395
  ⋅⋅1. Ordered sub-list
1187
1396
  4. And another item.
@@ -1240,10 +1449,8 @@ test('kitchen sink', () => {
1240
1449
  </p>
1241
1450
  <p>
1242
1451
  To have a line break without a paragraph, you will need to use two trailing spaces.
1243
- <br />
1244
- Note that this line is separate, but within the same paragraph.
1245
- <br />
1246
- (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
1452
+ Note that this line is separate, but within the same paragraph.
1453
+ (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
1247
1454
  </p>
1248
1455
  </li>
1249
1456
  </ol>
@@ -1291,8 +1498,8 @@ test('kitchen sink', () => {
1291
1498
 
1292
1499
  Or leave it empty and use the [link text itself].
1293
1500
 
1294
- URLs and URLs in angle brackets will automatically get turned into links.
1295
- http://www.example.com and sometimes
1501
+ URLs and URLs in angle brackets will automatically get turned into links.
1502
+ http://www.example.com and sometimes
1296
1503
  example.com (but not on Github, for example).
1297
1504
 
1298
1505
  Some text to show that the reference links can follow later.
@@ -1374,10 +1581,10 @@ test('kitchen sink', () => {
1374
1581
  <code>
1375
1582
  Here's our logo (hover to see the title text):
1376
1583
 
1377
- Inline-style:
1584
+ Inline-style:
1378
1585
  ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
1379
1586
 
1380
- Reference-style:
1587
+ Reference-style:
1381
1588
  ![alt text][logo]
1382
1589
 
1383
1590
  [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
@@ -1447,38 +1654,46 @@ test('kitchen sink', () => {
1447
1654
  , or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
1448
1655
  </p>
1449
1656
  <pre>
1450
- <code>
1657
+ <code
1658
+ className="language-javascript"
1659
+ >
1451
1660
  var s = "JavaScript syntax highlighting";
1452
1661
  alert(s);
1453
1662
  </code>
1454
1663
  </pre>
1455
1664
  <pre>
1456
- <code>
1665
+ <code
1666
+ className="language-python"
1667
+ >
1457
1668
  s = "Python syntax highlighting"
1458
1669
  print s
1459
1670
  </code>
1460
1671
  </pre>
1461
1672
  <pre>
1462
1673
  <code>
1463
- No language indicated, so no syntax highlighting.
1674
+ No language indicated, so no syntax highlighting.
1464
1675
  But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
1465
1676
  </code>
1466
1677
  </pre>
1467
1678
  <pre>
1468
- <code>
1679
+ <code
1680
+ className="language-javascript"
1681
+ >
1469
1682
  var s = "JavaScript syntax highlighting";
1470
1683
  alert(s);
1471
1684
  </code>
1472
1685
  </pre>
1473
1686
  <pre>
1474
- <code>
1687
+ <code
1688
+ className="language-python"
1689
+ >
1475
1690
  s = "Python syntax highlighting"
1476
1691
  print s
1477
1692
  </code>
1478
1693
  </pre>
1479
1694
  <pre>
1480
1695
  <code>
1481
- No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
1696
+ No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
1482
1697
  But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
1483
1698
  </code>
1484
1699
  </pre>
@@ -1506,7 +1721,7 @@ test('kitchen sink', () => {
1506
1721
  | zebra stripes | are neat | $1 |
1507
1722
 
1508
1723
  There must be at least 3 dashes separating each header cell.
1509
- The outer pipes (|) are optional, and you don't need to make the
1724
+ The outer pipes (|) are optional, and you don't need to make the
1510
1725
  raw Markdown line up prettily. You can also use inline Markdown.
1511
1726
 
1512
1727
  Markdown | Less | Pretty
@@ -1685,7 +1900,7 @@ test('kitchen sink', () => {
1685
1900
 
1686
1901
  Quote break.
1687
1902
 
1688
- &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.
1903
+ &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.
1689
1904
  </code>
1690
1905
  </pre>
1691
1906
  <blockquote>
@@ -1730,6 +1945,32 @@ test('kitchen sink', () => {
1730
1945
  &lt;/dl&gt;
1731
1946
  </code>
1732
1947
  </pre>
1948
+ <dl>
1949
+ <dt>
1950
+ Definition list
1951
+ </dt>
1952
+ <dd>
1953
+ Is something people use sometimes.
1954
+ </dd>
1955
+ <dt>
1956
+ Markdown in HTML
1957
+ </dt>
1958
+ <dd>
1959
+ Does
1960
+ <em>
1961
+ not
1962
+ </em>
1963
+ work
1964
+ <strong>
1965
+ very
1966
+ </strong>
1967
+ well. Use HTML
1968
+ <em>
1969
+ tags
1970
+ </em>
1971
+ .
1972
+ </dd>
1973
+ </dl>
1733
1974
  <a
1734
1975
  name="hr"
1735
1976
  />
@@ -1802,8 +2043,7 @@ test('kitchen sink', () => {
1802
2043
  </p>
1803
2044
  <p>
1804
2045
  This line is also begins a separate paragraph, but...
1805
- <br />
1806
- This line is only separated by a single newline, so it's a separate line in the
2046
+ This line is only separated by a single newline, so it's a separate line in the
1807
2047
  <em>
1808
2048
  same paragraph
1809
2049
  </em>
@@ -1828,7 +2068,7 @@ test('kitchen sink', () => {
1828
2068
  <pre>
1829
2069
  <code>
1830
2070
  &lt;a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
1831
- " target="_blank"&gt;&lt;img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
2071
+ " target="_blank"&gt;&lt;img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
1832
2072
  alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /&gt;&lt;/a&gt;
1833
2073
  </code>
1834
2074
  </pre>
@@ -1844,3 +2084,183 @@ test('kitchen sink', () => {
1844
2084
  }
1845
2085
  `)
1846
2086
  })
2087
+
2088
+ test('code block rendering', () => {
2089
+ const code = dedent`
2090
+ `
2091
+ expect(
2092
+ render(dedent`
2093
+ \`\`\`typescript
2094
+ const x = 1;
2095
+ \`\`\`
2096
+
2097
+ \`\`\`invalid-language
2098
+ const y = 2;
2099
+ \`\`\`
2100
+ `),
2101
+ ).toMatchInlineSnapshot(`
2102
+ {
2103
+ "errors": [
2104
+ {
2105
+ "message": "Unsupported language invalid-language",
2106
+ },
2107
+ ],
2108
+ "html": "<pre><code class="language-typescript">const x = 1;</code></pre><pre><code>const y = 2;</code></pre>",
2109
+ "result": <React.Fragment>
2110
+ <pre>
2111
+ <code
2112
+ className="language-typescript"
2113
+ >
2114
+ const x = 1;
2115
+ </code>
2116
+ </pre>
2117
+ <pre>
2118
+ <code>
2119
+ const y = 2;
2120
+ </code>
2121
+ </pre>
2122
+ </React.Fragment>,
2123
+ }
2124
+ `)
2125
+ })
2126
+
2127
+ test('code is not wrapped by p', () => {
2128
+ const code = `
2129
+ ---
2130
+ title: createSearchParams
2131
+ ---
2132
+
2133
+ # createSearchParams
2134
+
2135
+ [MODES: framework, data, declarative]
2136
+
2137
+ ## Summary
2138
+
2139
+ [Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html)
2140
+
2141
+ Creates a URLSearchParams object using the given initializer.
2142
+
2143
+ This is identical to \`new URLSearchParams(init)\` except it also
2144
+ supports arrays as values in the object form of the initializer
2145
+ instead of just strings. This is convenient when you need multiple
2146
+ values for a given key, but don't want to use an array initializer.
2147
+
2148
+ For example, instead of:
2149
+
2150
+ \`\`\`tsx
2151
+ let searchParams = new URLSearchParams([
2152
+ ["sort", "name"],
2153
+ ["sort", "price"],
2154
+ ]);
2155
+ \`\`\`
2156
+
2157
+ you can do:
2158
+
2159
+ \`\`\`
2160
+ let searchParams = createSearchParams({
2161
+ sort: ['name', 'price']
2162
+ });
2163
+ \`\`\`
2164
+
2165
+ ## Signature
2166
+
2167
+ \`\`\`tsx
2168
+ createSearchParams(init): URLSearchParams
2169
+ \`\`\`
2170
+
2171
+ ## Params
2172
+
2173
+ ### init
2174
+
2175
+ [modes: framework, data, declarative]
2176
+
2177
+ _No documentation_
2178
+
2179
+ `
2180
+ const jsx = render(code)
2181
+ expect(jsx.result).toMatchInlineSnapshot(`
2182
+ <React.Fragment>
2183
+ <hr />
2184
+ <h2>
2185
+ title: createSearchParams
2186
+ </h2>
2187
+ <h1>
2188
+ createSearchParams
2189
+ </h1>
2190
+ <p>
2191
+ [MODES: framework, data, declarative]
2192
+ </p>
2193
+ <h2>
2194
+ Summary
2195
+ </h2>
2196
+ <p>
2197
+ <a
2198
+ href="https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html"
2199
+ title=""
2200
+ >
2201
+ Reference Documentation ↗
2202
+ </a>
2203
+ </p>
2204
+ <p>
2205
+ Creates a URLSearchParams object using the given initializer.
2206
+ </p>
2207
+ <p>
2208
+ This is identical to
2209
+ <code>
2210
+ new URLSearchParams(init)
2211
+ </code>
2212
+ except it also
2213
+ supports arrays as values in the object form of the initializer
2214
+ instead of just strings. This is convenient when you need multiple
2215
+ values for a given key, but don't want to use an array initializer.
2216
+ </p>
2217
+ <p>
2218
+ For example, instead of:
2219
+ </p>
2220
+ <pre>
2221
+ <code
2222
+ className="language-tsx"
2223
+ >
2224
+ let searchParams = new URLSearchParams([
2225
+ ["sort", "name"],
2226
+ ["sort", "price"],
2227
+ ]);
2228
+ </code>
2229
+ </pre>
2230
+ <p>
2231
+ you can do:
2232
+ </p>
2233
+ <pre>
2234
+ <code>
2235
+ let searchParams = createSearchParams({
2236
+ sort: ['name', 'price']
2237
+ });
2238
+ </code>
2239
+ </pre>
2240
+ <h2>
2241
+ Signature
2242
+ </h2>
2243
+ <pre>
2244
+ <code
2245
+ className="language-tsx"
2246
+ >
2247
+ createSearchParams(init): URLSearchParams
2248
+ </code>
2249
+ </pre>
2250
+ <h2>
2251
+ Params
2252
+ </h2>
2253
+ <h3>
2254
+ init
2255
+ </h3>
2256
+ <p>
2257
+ [modes: framework, data, declarative]
2258
+ </p>
2259
+ <p>
2260
+ <em>
2261
+ No documentation
2262
+ </em>
2263
+ </p>
2264
+ </React.Fragment>
2265
+ `)
2266
+ })