safe-mdx 0.0.6 → 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.
- package/LICENSE +21 -0
- package/README.md +46 -14
- package/dist/safe-mdx.d.ts +29 -6
- package/dist/safe-mdx.d.ts.map +1 -1
- package/dist/safe-mdx.js +132 -35
- package/dist/safe-mdx.js.map +1 -1
- package/dist/safe-mdx.test.js +503 -234
- package/dist/safe-mdx.test.js.map +1 -1
- package/package.json +8 -8
- package/src/safe-mdx.test.tsx +512 -236
- package/src/safe-mdx.tsx +231 -40
- package/dist/plugins.d.ts +0 -12
- package/dist/plugins.d.ts.map +0 -1
- package/dist/plugins.js +0 -68
- package/dist/plugins.js.map +0 -1
- package/src/plugins.ts +0 -87
package/src/safe-mdx.test.tsx
CHANGED
|
@@ -3,13 +3,15 @@ import React from 'react'
|
|
|
3
3
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
4
4
|
import { expect, test } from 'vitest'
|
|
5
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
|
-
}
|
|
14
|
+
}
|
|
13
15
|
|
|
14
16
|
function render(code) {
|
|
15
17
|
const visitor = new MdastToJsx({ code, components })
|
|
@@ -18,19 +20,84 @@ 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
|
+
})
|
|
21
79
|
|
|
22
80
|
test('remark and jsx does not wrap in p', () => {
|
|
23
81
|
const code = dedent`
|
|
82
|
+
---
|
|
83
|
+
title: createSearchParams
|
|
84
|
+
---
|
|
85
|
+
|
|
24
86
|
# Hello
|
|
25
87
|
|
|
26
88
|
i am a paragraph
|
|
27
89
|
|
|
28
90
|
<Heading>heading</Heading>
|
|
29
91
|
|
|
30
|
-
|
|
92
|
+
sone \`inline code\`
|
|
93
|
+
|
|
94
|
+
\`\`\`tsx
|
|
95
|
+
some code
|
|
96
|
+
\`\`\`
|
|
97
|
+
|
|
98
|
+
what
|
|
31
99
|
`
|
|
32
100
|
const mdast = mdxParse(code)
|
|
33
|
-
|
|
34
101
|
|
|
35
102
|
mdastBfs(mdast, (x) => {
|
|
36
103
|
delete x.position
|
|
@@ -38,6 +105,10 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
38
105
|
expect(mdast).toMatchInlineSnapshot(`
|
|
39
106
|
{
|
|
40
107
|
"children": [
|
|
108
|
+
{
|
|
109
|
+
"type": "yaml",
|
|
110
|
+
"value": "title: createSearchParams",
|
|
111
|
+
},
|
|
41
112
|
{
|
|
42
113
|
"children": [
|
|
43
114
|
{
|
|
@@ -72,7 +143,26 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
72
143
|
"children": [
|
|
73
144
|
{
|
|
74
145
|
"type": "text",
|
|
75
|
-
"value": "
|
|
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",
|
|
76
166
|
},
|
|
77
167
|
],
|
|
78
168
|
"type": "paragraph",
|
|
@@ -116,7 +206,7 @@ test('frontmatter', () => {
|
|
|
116
206
|
---
|
|
117
207
|
hello: 5
|
|
118
208
|
---
|
|
119
|
-
|
|
209
|
+
|
|
120
210
|
# Hello
|
|
121
211
|
|
|
122
212
|
i am a paragraph
|
|
@@ -228,7 +318,7 @@ test('table, only head', () => {
|
|
|
228
318
|
|
|
229
319
|
| Tables | Are | Cool |
|
|
230
320
|
| ------------- |:-------------:| -----:|
|
|
231
|
-
|
|
321
|
+
|
|
232
322
|
`),
|
|
233
323
|
).toMatchInlineSnapshot(`
|
|
234
324
|
{
|
|
@@ -359,7 +449,7 @@ test('missing components are ignored', () => {
|
|
|
359
449
|
test('props parsing', () => {
|
|
360
450
|
expect(
|
|
361
451
|
render(dedent`
|
|
362
|
-
<Heading
|
|
452
|
+
<Heading
|
|
363
453
|
num={2}
|
|
364
454
|
doublequote={"a \" string"}
|
|
365
455
|
quote={'a \' string'}
|
|
@@ -392,7 +482,7 @@ test('props parsing', () => {
|
|
|
392
482
|
"message": "Expressions in jsx props are not supported (jsx={<SomeComponent />})",
|
|
393
483
|
},
|
|
394
484
|
{
|
|
395
|
-
"message": "Expressions in jsx props are not supported (...{
|
|
485
|
+
"message": "Expressions in jsx props are not supported (...{ spread: true })",
|
|
396
486
|
},
|
|
397
487
|
],
|
|
398
488
|
"html": "<h1><p>hi</p></h1>",
|
|
@@ -421,21 +511,21 @@ test('props parsing', () => {
|
|
|
421
511
|
test('breaks', () => {
|
|
422
512
|
expect(
|
|
423
513
|
render(dedent`
|
|
424
|
-
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
425
|
-
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.
|
|
426
516
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
427
517
|
`),
|
|
428
518
|
).toMatchInlineSnapshot(`
|
|
429
519
|
{
|
|
430
520
|
"errors": [],
|
|
431
|
-
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces
|
|
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>",
|
|
432
524
|
"result": <React.Fragment>
|
|
433
525
|
<p>
|
|
434
526
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
<br />
|
|
438
|
-
(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.)
|
|
439
529
|
</p>
|
|
440
530
|
</React.Fragment>,
|
|
441
531
|
}
|
|
@@ -448,410 +538,410 @@ test('kitchen sink', () => {
|
|
|
448
538
|
render(dedent`
|
|
449
539
|
# Markdown Kitchen Sink
|
|
450
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.
|
|
451
|
-
|
|
541
|
+
|
|
452
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/).
|
|
453
|
-
|
|
543
|
+
|
|
454
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).
|
|
455
|
-
|
|
456
|
-
##### Table of Contents
|
|
457
|
-
[Headers](#headers)
|
|
458
|
-
[Emphasis](#emphasis)
|
|
459
|
-
[Lists](#lists)
|
|
460
|
-
[Links](#links)
|
|
461
|
-
[Images](#images)
|
|
462
|
-
[Code and Syntax Highlighting](#code)
|
|
463
|
-
[Tables](#tables)
|
|
464
|
-
[Blockquotes](#blockquotes)
|
|
465
|
-
[Inline HTML](#html)
|
|
466
|
-
[Horizontal Rule](#hr)
|
|
467
|
-
[Line Breaks](#lines)
|
|
468
|
-
[YouTube Videos](#videos)
|
|
469
|
-
|
|
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
|
+
|
|
470
560
|
<a name="headers"></a>
|
|
471
|
-
|
|
561
|
+
|
|
472
562
|
## Headers
|
|
473
|
-
|
|
474
|
-
|
|
563
|
+
|
|
564
|
+
|
|
475
565
|
# H1
|
|
476
566
|
## H2
|
|
477
567
|
### H3
|
|
478
568
|
#### H4
|
|
479
569
|
##### H5
|
|
480
570
|
###### H6
|
|
481
|
-
|
|
571
|
+
|
|
482
572
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
483
|
-
|
|
573
|
+
|
|
484
574
|
Alt-H1
|
|
485
575
|
======
|
|
486
|
-
|
|
576
|
+
|
|
487
577
|
Alt-H2
|
|
488
578
|
------
|
|
489
|
-
|
|
490
|
-
|
|
579
|
+
|
|
580
|
+
|
|
491
581
|
# H1
|
|
492
582
|
## H2
|
|
493
583
|
### H3
|
|
494
584
|
#### H4
|
|
495
585
|
##### H5
|
|
496
586
|
###### H6
|
|
497
|
-
|
|
587
|
+
|
|
498
588
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
499
|
-
|
|
589
|
+
|
|
500
590
|
Alt-H1
|
|
501
591
|
======
|
|
502
|
-
|
|
592
|
+
|
|
503
593
|
Alt-H2
|
|
504
594
|
------
|
|
505
|
-
|
|
595
|
+
|
|
506
596
|
<a name="emphasis"></a>
|
|
507
|
-
|
|
597
|
+
|
|
508
598
|
## Emphasis
|
|
509
|
-
|
|
599
|
+
|
|
510
600
|
\`\`\`no-highlight
|
|
511
601
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
512
|
-
|
|
602
|
+
|
|
513
603
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
514
|
-
|
|
604
|
+
|
|
515
605
|
Combined emphasis with **asterisks and _underscores_**.
|
|
516
|
-
|
|
606
|
+
|
|
517
607
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
518
608
|
\`\`\`
|
|
519
|
-
|
|
609
|
+
|
|
520
610
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
521
|
-
|
|
611
|
+
|
|
522
612
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
523
|
-
|
|
613
|
+
|
|
524
614
|
Combined emphasis with **asterisks and _underscores_**.
|
|
525
|
-
|
|
615
|
+
|
|
526
616
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
527
|
-
|
|
528
|
-
|
|
617
|
+
|
|
618
|
+
|
|
529
619
|
<a name="lists"></a>
|
|
530
|
-
|
|
620
|
+
|
|
531
621
|
## Lists
|
|
532
|
-
|
|
622
|
+
|
|
533
623
|
(In this example, leading and trailing spaces are shown with with dots: ⋅)
|
|
534
|
-
|
|
624
|
+
|
|
535
625
|
\`\`\`no-highlight
|
|
536
626
|
1. First ordered list item
|
|
537
627
|
2. Another item
|
|
538
|
-
⋅⋅* Unordered sub-list.
|
|
628
|
+
⋅⋅* Unordered sub-list.
|
|
539
629
|
1. Actual numbers don't matter, just that it's a number
|
|
540
630
|
⋅⋅1. Ordered sub-list
|
|
541
631
|
4. And another item.
|
|
542
|
-
|
|
632
|
+
|
|
543
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).
|
|
544
|
-
|
|
634
|
+
|
|
545
635
|
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
|
|
546
636
|
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
|
|
547
637
|
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
548
|
-
|
|
638
|
+
|
|
549
639
|
* Unordered list can use asterisks
|
|
550
640
|
- Or minuses
|
|
551
641
|
+ Or pluses
|
|
552
642
|
\`\`\`
|
|
553
|
-
|
|
643
|
+
|
|
554
644
|
1. First ordered list item
|
|
555
645
|
2. Another item
|
|
556
|
-
* Unordered sub-list.
|
|
646
|
+
* Unordered sub-list.
|
|
557
647
|
1. Actual numbers don't matter, just that it's a number
|
|
558
648
|
1. Ordered sub-list
|
|
559
649
|
4. And another item.
|
|
560
|
-
|
|
650
|
+
|
|
561
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).
|
|
562
|
-
|
|
563
|
-
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
564
|
-
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.
|
|
565
655
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
566
|
-
|
|
656
|
+
|
|
567
657
|
* Unordered list can use asterisks
|
|
568
658
|
- Or minuses
|
|
569
659
|
+ Or pluses
|
|
570
|
-
|
|
660
|
+
|
|
571
661
|
<a name="links"></a>
|
|
572
|
-
|
|
662
|
+
|
|
573
663
|
## Links
|
|
574
|
-
|
|
664
|
+
|
|
575
665
|
There are two ways to create links.
|
|
576
|
-
|
|
666
|
+
|
|
577
667
|
\`\`\`no-highlight
|
|
578
668
|
[I'm an inline-style link](https://www.google.com)
|
|
579
|
-
|
|
669
|
+
|
|
580
670
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
581
|
-
|
|
671
|
+
|
|
582
672
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
583
|
-
|
|
673
|
+
|
|
584
674
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
585
|
-
|
|
675
|
+
|
|
586
676
|
[You can use numbers for reference-style link definitions][1]
|
|
587
|
-
|
|
677
|
+
|
|
588
678
|
Or leave it empty and use the [link text itself].
|
|
589
|
-
|
|
590
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
591
|
-
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
|
|
592
682
|
example.com (but not on Github, for example).
|
|
593
|
-
|
|
683
|
+
|
|
594
684
|
Some text to show that the reference links can follow later.
|
|
595
|
-
|
|
685
|
+
|
|
596
686
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
597
687
|
[1]: http://slashdot.org
|
|
598
688
|
[link text itself]: http://www.reddit.com
|
|
599
689
|
\`\`\`
|
|
600
|
-
|
|
690
|
+
|
|
601
691
|
[I'm an inline-style link](https://www.google.com)
|
|
602
|
-
|
|
692
|
+
|
|
603
693
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
604
|
-
|
|
694
|
+
|
|
605
695
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
606
|
-
|
|
696
|
+
|
|
607
697
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
608
|
-
|
|
698
|
+
|
|
609
699
|
[You can use numbers for reference-style link definitions][1]
|
|
610
|
-
|
|
700
|
+
|
|
611
701
|
Or leave it empty and use the [link text itself].
|
|
612
|
-
|
|
613
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
614
|
-
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
|
|
615
705
|
example.com (but not on Github, for example).
|
|
616
|
-
|
|
706
|
+
|
|
617
707
|
Some text to show that the reference links can follow later.
|
|
618
|
-
|
|
708
|
+
|
|
619
709
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
620
710
|
[1]: http://slashdot.org
|
|
621
711
|
[link text itself]: http://www.reddit.com
|
|
622
|
-
|
|
712
|
+
|
|
623
713
|
<a name="images"></a>
|
|
624
|
-
|
|
714
|
+
|
|
625
715
|
## Images
|
|
626
|
-
|
|
716
|
+
|
|
627
717
|
\`\`\`no-highlight
|
|
628
718
|
Here's our logo (hover to see the title text):
|
|
629
|
-
|
|
630
|
-
Inline-style:
|
|
719
|
+
|
|
720
|
+
Inline-style:
|
|
631
721
|

|
|
632
|
-
|
|
633
|
-
Reference-style:
|
|
722
|
+
|
|
723
|
+
Reference-style:
|
|
634
724
|
![alt text][logo]
|
|
635
|
-
|
|
725
|
+
|
|
636
726
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
637
727
|
\`\`\`
|
|
638
|
-
|
|
728
|
+
|
|
639
729
|
Here's our logo (hover to see the title text):
|
|
640
|
-
|
|
641
|
-
Inline-style:
|
|
730
|
+
|
|
731
|
+
Inline-style:
|
|
642
732
|

|
|
643
|
-
|
|
644
|
-
Reference-style:
|
|
733
|
+
|
|
734
|
+
Reference-style:
|
|
645
735
|
![alt text][logo]
|
|
646
|
-
|
|
736
|
+
|
|
647
737
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
648
|
-
|
|
738
|
+
|
|
649
739
|
<a name="code"></a>
|
|
650
|
-
|
|
740
|
+
|
|
651
741
|
## Code and Syntax Highlighting
|
|
652
|
-
|
|
742
|
+
|
|
653
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).
|
|
654
|
-
|
|
744
|
+
|
|
655
745
|
\`\`\`no-highlight
|
|
656
746
|
Inline \`code\` has \`back-ticks around\` it.
|
|
657
747
|
\`\`\`
|
|
658
|
-
|
|
748
|
+
|
|
659
749
|
Inline \`code\` has \`back-ticks around\` it.
|
|
660
|
-
|
|
750
|
+
|
|
661
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.
|
|
662
|
-
|
|
752
|
+
|
|
663
753
|
\`\`\`javascript
|
|
664
754
|
var s = "JavaScript syntax highlighting";
|
|
665
755
|
alert(s);
|
|
666
756
|
\`\`\`
|
|
667
|
-
|
|
757
|
+
|
|
668
758
|
\`\`\`python
|
|
669
759
|
s = "Python syntax highlighting"
|
|
670
760
|
print s
|
|
671
761
|
\`\`\`
|
|
672
|
-
|
|
762
|
+
|
|
673
763
|
\`\`\`
|
|
674
|
-
No language indicated, so no syntax highlighting.
|
|
764
|
+
No language indicated, so no syntax highlighting.
|
|
675
765
|
But let's throw in a <b>tag</b>.
|
|
676
766
|
\`\`\`
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
|
|
681
771
|
\`\`\`javascript
|
|
682
772
|
var s = "JavaScript syntax highlighting";
|
|
683
773
|
alert(s);
|
|
684
774
|
\`\`\`
|
|
685
|
-
|
|
775
|
+
|
|
686
776
|
\`\`\`python
|
|
687
777
|
s = "Python syntax highlighting"
|
|
688
778
|
print s
|
|
689
779
|
\`\`\`
|
|
690
|
-
|
|
780
|
+
|
|
691
781
|
\`\`\`
|
|
692
|
-
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).
|
|
693
783
|
But let's throw in a <b>tag</b>.
|
|
694
784
|
\`\`\`
|
|
695
|
-
|
|
696
|
-
|
|
785
|
+
|
|
786
|
+
|
|
697
787
|
<a name="tables"></a>
|
|
698
|
-
|
|
788
|
+
|
|
699
789
|
## Tables
|
|
700
|
-
|
|
790
|
+
|
|
701
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.
|
|
702
|
-
|
|
792
|
+
|
|
703
793
|
\`\`\`no-highlight
|
|
704
794
|
Colons can be used to align columns.
|
|
705
|
-
|
|
795
|
+
|
|
706
796
|
| Tables | Are | Cool |
|
|
707
797
|
| ------------- |:-------------:| -----:|
|
|
708
798
|
| col 3 is | right-aligned | $1600 |
|
|
709
799
|
| col 2 is | centered | $12 |
|
|
710
800
|
| zebra stripes | are neat | $1 |
|
|
711
|
-
|
|
801
|
+
|
|
712
802
|
There must be at least 3 dashes separating each header cell.
|
|
713
|
-
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
|
|
714
804
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
715
|
-
|
|
805
|
+
|
|
716
806
|
Markdown | Less | Pretty
|
|
717
807
|
--- | --- | ---
|
|
718
808
|
*Still* | \`renders\` | **nicely**
|
|
719
809
|
1 | 2 | 3
|
|
720
810
|
\`\`\`
|
|
721
|
-
|
|
811
|
+
|
|
722
812
|
Colons can be used to align columns.
|
|
723
|
-
|
|
813
|
+
|
|
724
814
|
| Tables | Are | Cool |
|
|
725
815
|
| ------------- |:-------------:| -----:|
|
|
726
816
|
| col 3 is | right-aligned | $1600 |
|
|
727
817
|
| col 2 is | centered | $12 |
|
|
728
818
|
| zebra stripes | are neat | $1 |
|
|
729
|
-
|
|
819
|
+
|
|
730
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.
|
|
731
|
-
|
|
821
|
+
|
|
732
822
|
Markdown | Less | Pretty
|
|
733
823
|
--- | --- | ---
|
|
734
824
|
*Still* | \`renders\` | **nicely**
|
|
735
825
|
1 | 2 | 3
|
|
736
|
-
|
|
826
|
+
|
|
737
827
|
<a name="blockquotes"></a>
|
|
738
|
-
|
|
828
|
+
|
|
739
829
|
## Blockquotes
|
|
740
|
-
|
|
830
|
+
|
|
741
831
|
\`\`\`no-highlight
|
|
742
832
|
> Blockquotes are very handy in email to emulate reply text.
|
|
743
833
|
> This line is part of the same quote.
|
|
744
|
-
|
|
834
|
+
|
|
745
835
|
Quote break.
|
|
746
|
-
|
|
747
|
-
> 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.
|
|
748
838
|
\`\`\`
|
|
749
|
-
|
|
839
|
+
|
|
750
840
|
> Blockquotes are very handy in email to emulate reply text.
|
|
751
841
|
> This line is part of the same quote.
|
|
752
|
-
|
|
842
|
+
|
|
753
843
|
Quote break.
|
|
754
|
-
|
|
755
|
-
> 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.
|
|
756
|
-
|
|
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
|
+
|
|
757
847
|
<a name="html"></a>
|
|
758
|
-
|
|
848
|
+
|
|
759
849
|
## Inline HTML
|
|
760
|
-
|
|
761
|
-
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
|
|
762
|
-
|
|
850
|
+
|
|
851
|
+
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
|
|
852
|
+
|
|
763
853
|
\`\`\`no-highlight
|
|
764
854
|
<dl>
|
|
765
855
|
<dt>Definition list</dt>
|
|
766
856
|
<dd>Is something people use sometimes.</dd>
|
|
767
|
-
|
|
857
|
+
|
|
768
858
|
<dt>Markdown in HTML</dt>
|
|
769
859
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
770
860
|
</dl>
|
|
771
861
|
\`\`\`
|
|
772
|
-
|
|
862
|
+
|
|
773
863
|
<dl>
|
|
774
864
|
<dt>Definition list</dt>
|
|
775
865
|
<dd>Is something people use sometimes.</dd>
|
|
776
|
-
|
|
866
|
+
|
|
777
867
|
<dt>Markdown in HTML</dt>
|
|
778
868
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
779
869
|
</dl>
|
|
780
|
-
|
|
870
|
+
|
|
781
871
|
<a name="hr"></a>
|
|
782
|
-
|
|
872
|
+
|
|
783
873
|
## Horizontal Rule
|
|
784
|
-
|
|
874
|
+
|
|
785
875
|
\`\`\`
|
|
786
876
|
Three or more...
|
|
787
|
-
|
|
877
|
+
|
|
788
878
|
---
|
|
789
|
-
|
|
879
|
+
|
|
790
880
|
Hyphens
|
|
791
|
-
|
|
881
|
+
|
|
792
882
|
***
|
|
793
|
-
|
|
883
|
+
|
|
794
884
|
Asterisks
|
|
795
|
-
|
|
885
|
+
|
|
796
886
|
___
|
|
797
|
-
|
|
887
|
+
|
|
798
888
|
Underscores
|
|
799
889
|
\`\`\`
|
|
800
|
-
|
|
890
|
+
|
|
801
891
|
Three or more...
|
|
802
|
-
|
|
892
|
+
|
|
803
893
|
---
|
|
804
|
-
|
|
894
|
+
|
|
805
895
|
Hyphens
|
|
806
|
-
|
|
896
|
+
|
|
807
897
|
***
|
|
808
|
-
|
|
898
|
+
|
|
809
899
|
Asterisks
|
|
810
|
-
|
|
900
|
+
|
|
811
901
|
___
|
|
812
|
-
|
|
902
|
+
|
|
813
903
|
Underscores
|
|
814
|
-
|
|
904
|
+
|
|
815
905
|
<a name="lines"></a>
|
|
816
|
-
|
|
906
|
+
|
|
817
907
|
## Line Breaks
|
|
818
|
-
|
|
819
|
-
My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
|
|
820
|
-
|
|
908
|
+
|
|
909
|
+
My basic recommendation for learning how line breaks work is to experiment and discover -- hit <Enter> once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
|
|
910
|
+
|
|
821
911
|
Here are some things to try out:
|
|
822
|
-
|
|
912
|
+
|
|
823
913
|
\`\`\`
|
|
824
914
|
Here's a line for us to start with.
|
|
825
|
-
|
|
915
|
+
|
|
826
916
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
827
|
-
|
|
917
|
+
|
|
828
918
|
This line is also a separate paragraph, but...
|
|
829
919
|
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
|
|
830
920
|
\`\`\`
|
|
831
|
-
|
|
921
|
+
|
|
832
922
|
Here's a line for us to start with.
|
|
833
|
-
|
|
923
|
+
|
|
834
924
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
835
|
-
|
|
836
|
-
This line is also begins a separate paragraph, but...
|
|
925
|
+
|
|
926
|
+
This line is also begins a separate paragraph, but...
|
|
837
927
|
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
|
|
838
|
-
|
|
928
|
+
|
|
839
929
|
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
|
|
840
|
-
|
|
930
|
+
|
|
841
931
|
<a name="videos"></a>
|
|
842
|
-
|
|
932
|
+
|
|
843
933
|
## YouTube Videos
|
|
844
|
-
|
|
934
|
+
|
|
845
935
|
They can't be added directly but you can add an image with a link to the video like this:
|
|
846
|
-
|
|
936
|
+
|
|
847
937
|
\`\`\`no-highlight
|
|
848
938
|
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
849
|
-
" 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"
|
|
850
940
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
|
|
851
941
|
\`\`\`
|
|
852
|
-
|
|
942
|
+
|
|
853
943
|
Or, in pure Markdown, but losing the image sizing and border:
|
|
854
|
-
|
|
944
|
+
|
|
855
945
|
\`\`\`no-highlight
|
|
856
946
|
[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
|
|
857
947
|
\`\`\`
|
|
@@ -884,9 +974,6 @@ test('kitchen sink', () => {
|
|
|
884
974
|
{
|
|
885
975
|
"message": "Unsupported language no-highlight",
|
|
886
976
|
},
|
|
887
|
-
{
|
|
888
|
-
"message": "Unsupported jsx component dl",
|
|
889
|
-
},
|
|
890
977
|
{
|
|
891
978
|
"message": "Unsupported language no-highlight",
|
|
892
979
|
},
|
|
@@ -894,7 +981,18 @@ test('kitchen sink', () => {
|
|
|
894
981
|
"message": "Unsupported language no-highlight",
|
|
895
982
|
},
|
|
896
983
|
],
|
|
897
|
-
"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's styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber's original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that's what you're looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a
|
|
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's styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber's original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that's what you're looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a>
|
|
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_.
|
|
898
996
|
|
|
899
997
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
900
998
|
|
|
@@ -902,7 +1000,7 @@ test('kitchen sink', () => {
|
|
|
902
1000
|
|
|
903
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
|
|
904
1002
|
2. Another item
|
|
905
|
-
⋅⋅* Unordered sub-list.
|
|
1003
|
+
⋅⋅* Unordered sub-list.
|
|
906
1004
|
1. Actual numbers don't matter, just that it's a number
|
|
907
1005
|
⋅⋅1. Ordered sub-list
|
|
908
1006
|
4. And another item.
|
|
@@ -915,7 +1013,9 @@ test('kitchen sink', () => {
|
|
|
915
1013
|
|
|
916
1014
|
* Unordered list can use asterisks
|
|
917
1015
|
- Or minuses
|
|
918
|
-
+ Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don't matter, just that it's a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces
|
|
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't matter, just that it's a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we'll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
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'm an inline-style link](https://www.google.com)
|
|
919
1019
|
|
|
920
1020
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
921
1021
|
|
|
@@ -927,8 +1027,8 @@ test('kitchen sink', () => {
|
|
|
927
1027
|
|
|
928
1028
|
Or leave it empty and use the [link text itself].
|
|
929
1029
|
|
|
930
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
931
|
-
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
|
|
932
1032
|
example.com (but not on Github, for example).
|
|
933
1033
|
|
|
934
1034
|
Some text to show that the reference links can follow later.
|
|
@@ -939,20 +1039,20 @@ test('kitchen sink', () => {
|
|
|
939
1039
|
<a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
|
|
940
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's our logo (hover to see the title text):
|
|
941
1041
|
|
|
942
|
-
Inline-style:
|
|
1042
|
+
Inline-style:
|
|
943
1043
|

|
|
944
1044
|
|
|
945
|
-
Reference-style:
|
|
1045
|
+
Reference-style:
|
|
946
1046
|
![alt text][logo]
|
|
947
1047
|
|
|
948
1048
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"</code></pre><p>Here's our logo (hover to see the title text):</p><p>Inline-style:
|
|
949
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:
|
|
950
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't. However, many renderers -- like Github's and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.</p><pre><code class="language-javascript">var s = "JavaScript syntax highlighting";
|
|
951
1051
|
alert(s);</code></pre><pre><code class="language-python">s = "Python syntax highlighting"
|
|
952
|
-
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
1052
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
953
1053
|
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><pre><code class="language-javascript">var s = "JavaScript syntax highlighting";
|
|
954
1054
|
alert(s);</code></pre><pre><code class="language-python">s = "Python syntax highlighting"
|
|
955
|
-
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1055
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
956
1056
|
But let's throw in a <b>tag</b>.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren't part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
|
|
957
1057
|
|
|
958
1058
|
| Tables | Are | Cool |
|
|
@@ -962,7 +1062,7 @@ test('kitchen sink', () => {
|
|
|
962
1062
|
| zebra stripes | are neat | $1 |
|
|
963
1063
|
|
|
964
1064
|
There must be at least 3 dashes separating each header cell.
|
|
965
|
-
The outer pipes (|) are optional, and you don't need to make the
|
|
1065
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
966
1066
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
967
1067
|
|
|
968
1068
|
Markdown | Less | Pretty
|
|
@@ -973,14 +1073,14 @@ test('kitchen sink', () => {
|
|
|
973
1073
|
|
|
974
1074
|
Quote break.
|
|
975
1075
|
|
|
976
|
-
> 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
|
|
1076
|
+
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.</code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
|
|
977
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's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it'll mostly work pretty well.</p><pre><code><dl>
|
|
978
1078
|
<dt>Definition list</dt>
|
|
979
1079
|
<dd>Is something people use sometimes.</dd>
|
|
980
1080
|
|
|
981
1081
|
<dt>Markdown in HTML</dt>
|
|
982
1082
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
983
|
-
</dl></code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
|
|
1083
|
+
</dl></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...
|
|
984
1084
|
|
|
985
1085
|
---
|
|
986
1086
|
|
|
@@ -997,8 +1097,9 @@ test('kitchen sink', () => {
|
|
|
997
1097
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
998
1098
|
|
|
999
1099
|
This line is also a separate paragraph, but...
|
|
1000
|
-
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.</code></pre><p>Here's a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but
|
|
1001
|
-
|
|
1100
|
+
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.</code></pre><p>Here's a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...
|
|
1101
|
+
This line is only separated by a single newline, so it's a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there's no need to use MD's two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can't be added directly but you can add an image with a link to the video like this:</p><pre><code><a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
1102
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
1002
1103
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a></code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
|
|
1003
1104
|
"result": <React.Fragment>
|
|
1004
1105
|
<h1>
|
|
@@ -1072,77 +1173,88 @@ test('kitchen sink', () => {
|
|
|
1072
1173
|
>
|
|
1073
1174
|
Headers
|
|
1074
1175
|
</a>
|
|
1075
|
-
|
|
1176
|
+
|
|
1177
|
+
|
|
1076
1178
|
<a
|
|
1077
1179
|
href="#emphasis"
|
|
1078
1180
|
title=""
|
|
1079
1181
|
>
|
|
1080
1182
|
Emphasis
|
|
1081
1183
|
</a>
|
|
1082
|
-
|
|
1184
|
+
|
|
1185
|
+
|
|
1083
1186
|
<a
|
|
1084
1187
|
href="#lists"
|
|
1085
1188
|
title=""
|
|
1086
1189
|
>
|
|
1087
1190
|
Lists
|
|
1088
1191
|
</a>
|
|
1089
|
-
|
|
1192
|
+
|
|
1193
|
+
|
|
1090
1194
|
<a
|
|
1091
1195
|
href="#links"
|
|
1092
1196
|
title=""
|
|
1093
1197
|
>
|
|
1094
1198
|
Links
|
|
1095
1199
|
</a>
|
|
1096
|
-
|
|
1200
|
+
|
|
1201
|
+
|
|
1097
1202
|
<a
|
|
1098
1203
|
href="#images"
|
|
1099
1204
|
title=""
|
|
1100
1205
|
>
|
|
1101
1206
|
Images
|
|
1102
1207
|
</a>
|
|
1103
|
-
|
|
1208
|
+
|
|
1209
|
+
|
|
1104
1210
|
<a
|
|
1105
1211
|
href="#code"
|
|
1106
1212
|
title=""
|
|
1107
1213
|
>
|
|
1108
1214
|
Code and Syntax Highlighting
|
|
1109
1215
|
</a>
|
|
1110
|
-
|
|
1216
|
+
|
|
1217
|
+
|
|
1111
1218
|
<a
|
|
1112
1219
|
href="#tables"
|
|
1113
1220
|
title=""
|
|
1114
1221
|
>
|
|
1115
1222
|
Tables
|
|
1116
1223
|
</a>
|
|
1117
|
-
|
|
1224
|
+
|
|
1225
|
+
|
|
1118
1226
|
<a
|
|
1119
1227
|
href="#blockquotes"
|
|
1120
1228
|
title=""
|
|
1121
1229
|
>
|
|
1122
1230
|
Blockquotes
|
|
1123
1231
|
</a>
|
|
1124
|
-
|
|
1232
|
+
|
|
1233
|
+
|
|
1125
1234
|
<a
|
|
1126
1235
|
href="#html"
|
|
1127
1236
|
title=""
|
|
1128
1237
|
>
|
|
1129
1238
|
Inline HTML
|
|
1130
1239
|
</a>
|
|
1131
|
-
|
|
1240
|
+
|
|
1241
|
+
|
|
1132
1242
|
<a
|
|
1133
1243
|
href="#hr"
|
|
1134
1244
|
title=""
|
|
1135
1245
|
>
|
|
1136
1246
|
Horizontal Rule
|
|
1137
1247
|
</a>
|
|
1138
|
-
|
|
1248
|
+
|
|
1249
|
+
|
|
1139
1250
|
<a
|
|
1140
1251
|
href="#lines"
|
|
1141
1252
|
title=""
|
|
1142
1253
|
>
|
|
1143
1254
|
Line Breaks
|
|
1144
1255
|
</a>
|
|
1145
|
-
|
|
1256
|
+
|
|
1257
|
+
|
|
1146
1258
|
<a
|
|
1147
1259
|
href="#videos"
|
|
1148
1260
|
title=""
|
|
@@ -1278,7 +1390,7 @@ test('kitchen sink', () => {
|
|
|
1278
1390
|
<code>
|
|
1279
1391
|
1. First ordered list item
|
|
1280
1392
|
2. Another item
|
|
1281
|
-
⋅⋅* Unordered sub-list.
|
|
1393
|
+
⋅⋅* Unordered sub-list.
|
|
1282
1394
|
1. Actual numbers don't matter, just that it's a number
|
|
1283
1395
|
⋅⋅1. Ordered sub-list
|
|
1284
1396
|
4. And another item.
|
|
@@ -1337,10 +1449,8 @@ test('kitchen sink', () => {
|
|
|
1337
1449
|
</p>
|
|
1338
1450
|
<p>
|
|
1339
1451
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
<br />
|
|
1343
|
-
(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.)
|
|
1344
1454
|
</p>
|
|
1345
1455
|
</li>
|
|
1346
1456
|
</ol>
|
|
@@ -1388,8 +1498,8 @@ test('kitchen sink', () => {
|
|
|
1388
1498
|
|
|
1389
1499
|
Or leave it empty and use the [link text itself].
|
|
1390
1500
|
|
|
1391
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1392
|
-
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
|
|
1393
1503
|
example.com (but not on Github, for example).
|
|
1394
1504
|
|
|
1395
1505
|
Some text to show that the reference links can follow later.
|
|
@@ -1471,10 +1581,10 @@ test('kitchen sink', () => {
|
|
|
1471
1581
|
<code>
|
|
1472
1582
|
Here's our logo (hover to see the title text):
|
|
1473
1583
|
|
|
1474
|
-
Inline-style:
|
|
1584
|
+
Inline-style:
|
|
1475
1585
|

|
|
1476
1586
|
|
|
1477
|
-
Reference-style:
|
|
1587
|
+
Reference-style:
|
|
1478
1588
|
![alt text][logo]
|
|
1479
1589
|
|
|
1480
1590
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
@@ -1561,7 +1671,7 @@ test('kitchen sink', () => {
|
|
|
1561
1671
|
</pre>
|
|
1562
1672
|
<pre>
|
|
1563
1673
|
<code>
|
|
1564
|
-
No language indicated, so no syntax highlighting.
|
|
1674
|
+
No language indicated, so no syntax highlighting.
|
|
1565
1675
|
But let's throw in a <b>tag</b>.
|
|
1566
1676
|
</code>
|
|
1567
1677
|
</pre>
|
|
@@ -1583,7 +1693,7 @@ test('kitchen sink', () => {
|
|
|
1583
1693
|
</pre>
|
|
1584
1694
|
<pre>
|
|
1585
1695
|
<code>
|
|
1586
|
-
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).
|
|
1587
1697
|
But let's throw in a <b>tag</b>.
|
|
1588
1698
|
</code>
|
|
1589
1699
|
</pre>
|
|
@@ -1611,7 +1721,7 @@ test('kitchen sink', () => {
|
|
|
1611
1721
|
| zebra stripes | are neat | $1 |
|
|
1612
1722
|
|
|
1613
1723
|
There must be at least 3 dashes separating each header cell.
|
|
1614
|
-
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
|
|
1615
1725
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
1616
1726
|
|
|
1617
1727
|
Markdown | Less | Pretty
|
|
@@ -1790,7 +1900,7 @@ test('kitchen sink', () => {
|
|
|
1790
1900
|
|
|
1791
1901
|
Quote break.
|
|
1792
1902
|
|
|
1793
|
-
> 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
|
+
> 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.
|
|
1794
1904
|
</code>
|
|
1795
1905
|
</pre>
|
|
1796
1906
|
<blockquote>
|
|
@@ -1835,6 +1945,32 @@ test('kitchen sink', () => {
|
|
|
1835
1945
|
</dl>
|
|
1836
1946
|
</code>
|
|
1837
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>
|
|
1838
1974
|
<a
|
|
1839
1975
|
name="hr"
|
|
1840
1976
|
/>
|
|
@@ -1907,8 +2043,7 @@ test('kitchen sink', () => {
|
|
|
1907
2043
|
</p>
|
|
1908
2044
|
<p>
|
|
1909
2045
|
This line is also begins a separate paragraph, but...
|
|
1910
|
-
|
|
1911
|
-
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
|
|
1912
2047
|
<em>
|
|
1913
2048
|
same paragraph
|
|
1914
2049
|
</em>
|
|
@@ -1933,7 +2068,7 @@ test('kitchen sink', () => {
|
|
|
1933
2068
|
<pre>
|
|
1934
2069
|
<code>
|
|
1935
2070
|
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
1936
|
-
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
2071
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
1937
2072
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
|
|
1938
2073
|
</code>
|
|
1939
2074
|
</pre>
|
|
@@ -1988,3 +2123,144 @@ test('code block rendering', () => {
|
|
|
1988
2123
|
}
|
|
1989
2124
|
`)
|
|
1990
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
|
+
})
|