safe-mdx 0.0.6 → 0.2.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 +60 -5
- package/dist/safe-mdx.d.ts +31 -7
- package/dist/safe-mdx.d.ts.map +1 -1
- package/dist/safe-mdx.js +134 -35
- package/dist/safe-mdx.js.map +1 -1
- package/dist/safe-mdx.test.js +537 -234
- package/dist/safe-mdx.test.js.map +1 -1
- package/dist/streaming.d.ts +2 -0
- package/dist/streaming.d.ts.map +1 -0
- package/dist/streaming.js +50 -0
- package/dist/streaming.js.map +1 -0
- package/package.json +8 -8
- package/src/safe-mdx.test.tsx +550 -236
- package/src/safe-mdx.tsx +234 -40
- package/src/streaming.tsx +60 -0
- package/src/plugins.ts +0 -87
package/src/safe-mdx.test.tsx
CHANGED
|
@@ -3,13 +3,18 @@ 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
|
+
Cards({ level, children }) {
|
|
15
|
+
return <div>{children}</div>
|
|
16
|
+
},
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
function render(code) {
|
|
15
20
|
const visitor = new MdastToJsx({ code, components })
|
|
@@ -18,19 +23,119 @@ function render(code) {
|
|
|
18
23
|
// console.log(JSON.stringify(result, null, 2))
|
|
19
24
|
return { result, errors: visitor.errors || [], html }
|
|
20
25
|
}
|
|
26
|
+
import { htmlToJsx } from 'html-to-jsx-transform'
|
|
27
|
+
import { completeJsxTags } from './streaming.js'
|
|
28
|
+
|
|
29
|
+
test('htmlToJsx', () => {
|
|
30
|
+
expect(htmlToJsx('<p x="y">')).toMatchInlineSnapshot(`"<p x="y" />"`)
|
|
31
|
+
expect(htmlToJsx('<p>text</p>')).toMatchInlineSnapshot(`"<p>text</p>"`)
|
|
32
|
+
expect(htmlToJsx('before <p>text</p>')).toMatchInlineSnapshot(
|
|
33
|
+
`"<>before <p>text</p></>"`,
|
|
34
|
+
)
|
|
35
|
+
expect(htmlToJsx('<nonexisting>text</nonexisting>')).toMatchInlineSnapshot(
|
|
36
|
+
`"<nonexisting>text</nonexisting>"`,
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('markdown inside jsx', () => {
|
|
41
|
+
const code = dedent`
|
|
42
|
+
# Hello
|
|
43
|
+
|
|
44
|
+
<Heading prop="value">
|
|
45
|
+
Component *children*
|
|
46
|
+
</Heading>
|
|
47
|
+
|
|
48
|
+
<figure>
|
|
49
|
+
some *bold* content
|
|
50
|
+
</figure>
|
|
51
|
+
|
|
52
|
+
`
|
|
53
|
+
|
|
54
|
+
expect(render(code)).toMatchInlineSnapshot(`
|
|
55
|
+
{
|
|
56
|
+
"errors": [],
|
|
57
|
+
"html": "<h1>Hello</h1><h1><p>Component <em>children</em></p></h1><figure><p>some <em>bold</em> content</p></figure>",
|
|
58
|
+
"result": <React.Fragment>
|
|
59
|
+
<h1>
|
|
60
|
+
Hello
|
|
61
|
+
</h1>
|
|
62
|
+
<Heading
|
|
63
|
+
prop="value"
|
|
64
|
+
>
|
|
65
|
+
<p>
|
|
66
|
+
Component
|
|
67
|
+
<em>
|
|
68
|
+
children
|
|
69
|
+
</em>
|
|
70
|
+
</p>
|
|
71
|
+
</Heading>
|
|
72
|
+
<figure>
|
|
73
|
+
<p>
|
|
74
|
+
some
|
|
75
|
+
<em>
|
|
76
|
+
bold
|
|
77
|
+
</em>
|
|
78
|
+
content
|
|
79
|
+
</p>
|
|
80
|
+
</figure>
|
|
81
|
+
</React.Fragment>,
|
|
82
|
+
}
|
|
83
|
+
`)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('can complete jsx code with completeJsxTags', () => {
|
|
87
|
+
const code = dedent`
|
|
88
|
+
# Hello
|
|
89
|
+
|
|
90
|
+
<Cards>
|
|
91
|
+
<Heading prop="value">
|
|
92
|
+
some value
|
|
93
|
+
|
|
94
|
+
Component *children*
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
`
|
|
99
|
+
|
|
100
|
+
expect(render(completeJsxTags(code))).toMatchInlineSnapshot(`
|
|
101
|
+
{
|
|
102
|
+
"errors": [],
|
|
103
|
+
"html": "<h1>Hello</h1><div><h1></h1></div>",
|
|
104
|
+
"result": <React.Fragment>
|
|
105
|
+
<h1>
|
|
106
|
+
Hello
|
|
107
|
+
</h1>
|
|
108
|
+
<Cards>
|
|
109
|
+
<Heading
|
|
110
|
+
prop="value"
|
|
111
|
+
/>
|
|
112
|
+
</Cards>
|
|
113
|
+
</React.Fragment>,
|
|
114
|
+
}
|
|
115
|
+
`)
|
|
116
|
+
})
|
|
21
117
|
|
|
22
118
|
test('remark and jsx does not wrap in p', () => {
|
|
23
119
|
const code = dedent`
|
|
120
|
+
---
|
|
121
|
+
title: createSearchParams
|
|
122
|
+
---
|
|
123
|
+
|
|
24
124
|
# Hello
|
|
25
125
|
|
|
26
126
|
i am a paragraph
|
|
27
127
|
|
|
28
128
|
<Heading>heading</Heading>
|
|
29
129
|
|
|
30
|
-
|
|
130
|
+
sone \`inline code\`
|
|
131
|
+
|
|
132
|
+
\`\`\`tsx
|
|
133
|
+
some code
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
what
|
|
31
137
|
`
|
|
32
138
|
const mdast = mdxParse(code)
|
|
33
|
-
|
|
34
139
|
|
|
35
140
|
mdastBfs(mdast, (x) => {
|
|
36
141
|
delete x.position
|
|
@@ -38,6 +143,10 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
38
143
|
expect(mdast).toMatchInlineSnapshot(`
|
|
39
144
|
{
|
|
40
145
|
"children": [
|
|
146
|
+
{
|
|
147
|
+
"type": "yaml",
|
|
148
|
+
"value": "title: createSearchParams",
|
|
149
|
+
},
|
|
41
150
|
{
|
|
42
151
|
"children": [
|
|
43
152
|
{
|
|
@@ -72,7 +181,26 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
72
181
|
"children": [
|
|
73
182
|
{
|
|
74
183
|
"type": "text",
|
|
75
|
-
"value": "
|
|
184
|
+
"value": "sone ",
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"type": "inlineCode",
|
|
188
|
+
"value": "inline code",
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
"type": "paragraph",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"lang": "tsx",
|
|
195
|
+
"meta": null,
|
|
196
|
+
"type": "code",
|
|
197
|
+
"value": "some code",
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"children": [
|
|
201
|
+
{
|
|
202
|
+
"type": "text",
|
|
203
|
+
"value": "what",
|
|
76
204
|
},
|
|
77
205
|
],
|
|
78
206
|
"type": "paragraph",
|
|
@@ -116,7 +244,7 @@ test('frontmatter', () => {
|
|
|
116
244
|
---
|
|
117
245
|
hello: 5
|
|
118
246
|
---
|
|
119
|
-
|
|
247
|
+
|
|
120
248
|
# Hello
|
|
121
249
|
|
|
122
250
|
i am a paragraph
|
|
@@ -228,7 +356,7 @@ test('table, only head', () => {
|
|
|
228
356
|
|
|
229
357
|
| Tables | Are | Cool |
|
|
230
358
|
| ------------- |:-------------:| -----:|
|
|
231
|
-
|
|
359
|
+
|
|
232
360
|
`),
|
|
233
361
|
).toMatchInlineSnapshot(`
|
|
234
362
|
{
|
|
@@ -359,7 +487,7 @@ test('missing components are ignored', () => {
|
|
|
359
487
|
test('props parsing', () => {
|
|
360
488
|
expect(
|
|
361
489
|
render(dedent`
|
|
362
|
-
<Heading
|
|
490
|
+
<Heading
|
|
363
491
|
num={2}
|
|
364
492
|
doublequote={"a \" string"}
|
|
365
493
|
quote={'a \' string'}
|
|
@@ -392,7 +520,7 @@ test('props parsing', () => {
|
|
|
392
520
|
"message": "Expressions in jsx props are not supported (jsx={<SomeComponent />})",
|
|
393
521
|
},
|
|
394
522
|
{
|
|
395
|
-
"message": "Expressions in jsx props are not supported (...{
|
|
523
|
+
"message": "Expressions in jsx props are not supported (...{ spread: true })",
|
|
396
524
|
},
|
|
397
525
|
],
|
|
398
526
|
"html": "<h1><p>hi</p></h1>",
|
|
@@ -421,21 +549,21 @@ test('props parsing', () => {
|
|
|
421
549
|
test('breaks', () => {
|
|
422
550
|
expect(
|
|
423
551
|
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.
|
|
552
|
+
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
553
|
+
Note that this line is separate, but within the same paragraph.
|
|
426
554
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
427
555
|
`),
|
|
428
556
|
).toMatchInlineSnapshot(`
|
|
429
557
|
{
|
|
430
558
|
"errors": [],
|
|
431
|
-
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces
|
|
559
|
+
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
560
|
+
Note that this line is separate, but within the same paragraph.
|
|
561
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
|
|
432
562
|
"result": <React.Fragment>
|
|
433
563
|
<p>
|
|
434
564
|
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.)
|
|
565
|
+
Note that this line is separate, but within the same paragraph.
|
|
566
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
439
567
|
</p>
|
|
440
568
|
</React.Fragment>,
|
|
441
569
|
}
|
|
@@ -448,410 +576,410 @@ test('kitchen sink', () => {
|
|
|
448
576
|
render(dedent`
|
|
449
577
|
# Markdown Kitchen Sink
|
|
450
578
|
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
|
-
|
|
579
|
+
|
|
452
580
|
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
|
-
|
|
581
|
+
|
|
454
582
|
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
|
-
|
|
583
|
+
|
|
584
|
+
##### Table of Contents
|
|
585
|
+
[Headers](#headers)
|
|
586
|
+
[Emphasis](#emphasis)
|
|
587
|
+
[Lists](#lists)
|
|
588
|
+
[Links](#links)
|
|
589
|
+
[Images](#images)
|
|
590
|
+
[Code and Syntax Highlighting](#code)
|
|
591
|
+
[Tables](#tables)
|
|
592
|
+
[Blockquotes](#blockquotes)
|
|
593
|
+
[Inline HTML](#html)
|
|
594
|
+
[Horizontal Rule](#hr)
|
|
595
|
+
[Line Breaks](#lines)
|
|
596
|
+
[YouTube Videos](#videos)
|
|
597
|
+
|
|
470
598
|
<a name="headers"></a>
|
|
471
|
-
|
|
599
|
+
|
|
472
600
|
## Headers
|
|
473
|
-
|
|
474
|
-
|
|
601
|
+
|
|
602
|
+
|
|
475
603
|
# H1
|
|
476
604
|
## H2
|
|
477
605
|
### H3
|
|
478
606
|
#### H4
|
|
479
607
|
##### H5
|
|
480
608
|
###### H6
|
|
481
|
-
|
|
609
|
+
|
|
482
610
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
483
|
-
|
|
611
|
+
|
|
484
612
|
Alt-H1
|
|
485
613
|
======
|
|
486
|
-
|
|
614
|
+
|
|
487
615
|
Alt-H2
|
|
488
616
|
------
|
|
489
|
-
|
|
490
|
-
|
|
617
|
+
|
|
618
|
+
|
|
491
619
|
# H1
|
|
492
620
|
## H2
|
|
493
621
|
### H3
|
|
494
622
|
#### H4
|
|
495
623
|
##### H5
|
|
496
624
|
###### H6
|
|
497
|
-
|
|
625
|
+
|
|
498
626
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
499
|
-
|
|
627
|
+
|
|
500
628
|
Alt-H1
|
|
501
629
|
======
|
|
502
|
-
|
|
630
|
+
|
|
503
631
|
Alt-H2
|
|
504
632
|
------
|
|
505
|
-
|
|
633
|
+
|
|
506
634
|
<a name="emphasis"></a>
|
|
507
|
-
|
|
635
|
+
|
|
508
636
|
## Emphasis
|
|
509
|
-
|
|
637
|
+
|
|
510
638
|
\`\`\`no-highlight
|
|
511
639
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
512
|
-
|
|
640
|
+
|
|
513
641
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
514
|
-
|
|
642
|
+
|
|
515
643
|
Combined emphasis with **asterisks and _underscores_**.
|
|
516
|
-
|
|
644
|
+
|
|
517
645
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
518
646
|
\`\`\`
|
|
519
|
-
|
|
647
|
+
|
|
520
648
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
521
|
-
|
|
649
|
+
|
|
522
650
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
523
|
-
|
|
651
|
+
|
|
524
652
|
Combined emphasis with **asterisks and _underscores_**.
|
|
525
|
-
|
|
653
|
+
|
|
526
654
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
527
|
-
|
|
528
|
-
|
|
655
|
+
|
|
656
|
+
|
|
529
657
|
<a name="lists"></a>
|
|
530
|
-
|
|
658
|
+
|
|
531
659
|
## Lists
|
|
532
|
-
|
|
660
|
+
|
|
533
661
|
(In this example, leading and trailing spaces are shown with with dots: ⋅)
|
|
534
|
-
|
|
662
|
+
|
|
535
663
|
\`\`\`no-highlight
|
|
536
664
|
1. First ordered list item
|
|
537
665
|
2. Another item
|
|
538
|
-
⋅⋅* Unordered sub-list.
|
|
666
|
+
⋅⋅* Unordered sub-list.
|
|
539
667
|
1. Actual numbers don't matter, just that it's a number
|
|
540
668
|
⋅⋅1. Ordered sub-list
|
|
541
669
|
4. And another item.
|
|
542
|
-
|
|
670
|
+
|
|
543
671
|
⋅⋅⋅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
|
-
|
|
672
|
+
|
|
545
673
|
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
|
|
546
674
|
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
|
|
547
675
|
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
548
|
-
|
|
676
|
+
|
|
549
677
|
* Unordered list can use asterisks
|
|
550
678
|
- Or minuses
|
|
551
679
|
+ Or pluses
|
|
552
680
|
\`\`\`
|
|
553
|
-
|
|
681
|
+
|
|
554
682
|
1. First ordered list item
|
|
555
683
|
2. Another item
|
|
556
|
-
* Unordered sub-list.
|
|
684
|
+
* Unordered sub-list.
|
|
557
685
|
1. Actual numbers don't matter, just that it's a number
|
|
558
686
|
1. Ordered sub-list
|
|
559
687
|
4. And another item.
|
|
560
|
-
|
|
688
|
+
|
|
561
689
|
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.
|
|
690
|
+
|
|
691
|
+
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
692
|
+
Note that this line is separate, but within the same paragraph.
|
|
565
693
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
566
|
-
|
|
694
|
+
|
|
567
695
|
* Unordered list can use asterisks
|
|
568
696
|
- Or minuses
|
|
569
697
|
+ Or pluses
|
|
570
|
-
|
|
698
|
+
|
|
571
699
|
<a name="links"></a>
|
|
572
|
-
|
|
700
|
+
|
|
573
701
|
## Links
|
|
574
|
-
|
|
702
|
+
|
|
575
703
|
There are two ways to create links.
|
|
576
|
-
|
|
704
|
+
|
|
577
705
|
\`\`\`no-highlight
|
|
578
706
|
[I'm an inline-style link](https://www.google.com)
|
|
579
|
-
|
|
707
|
+
|
|
580
708
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
581
|
-
|
|
709
|
+
|
|
582
710
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
583
|
-
|
|
711
|
+
|
|
584
712
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
585
|
-
|
|
713
|
+
|
|
586
714
|
[You can use numbers for reference-style link definitions][1]
|
|
587
|
-
|
|
715
|
+
|
|
588
716
|
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
|
|
717
|
+
|
|
718
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
719
|
+
http://www.example.com and sometimes
|
|
592
720
|
example.com (but not on Github, for example).
|
|
593
|
-
|
|
721
|
+
|
|
594
722
|
Some text to show that the reference links can follow later.
|
|
595
|
-
|
|
723
|
+
|
|
596
724
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
597
725
|
[1]: http://slashdot.org
|
|
598
726
|
[link text itself]: http://www.reddit.com
|
|
599
727
|
\`\`\`
|
|
600
|
-
|
|
728
|
+
|
|
601
729
|
[I'm an inline-style link](https://www.google.com)
|
|
602
|
-
|
|
730
|
+
|
|
603
731
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
604
|
-
|
|
732
|
+
|
|
605
733
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
606
|
-
|
|
734
|
+
|
|
607
735
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
608
|
-
|
|
736
|
+
|
|
609
737
|
[You can use numbers for reference-style link definitions][1]
|
|
610
|
-
|
|
738
|
+
|
|
611
739
|
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
|
|
740
|
+
|
|
741
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
742
|
+
http://www.example.com and sometimes
|
|
615
743
|
example.com (but not on Github, for example).
|
|
616
|
-
|
|
744
|
+
|
|
617
745
|
Some text to show that the reference links can follow later.
|
|
618
|
-
|
|
746
|
+
|
|
619
747
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
620
748
|
[1]: http://slashdot.org
|
|
621
749
|
[link text itself]: http://www.reddit.com
|
|
622
|
-
|
|
750
|
+
|
|
623
751
|
<a name="images"></a>
|
|
624
|
-
|
|
752
|
+
|
|
625
753
|
## Images
|
|
626
|
-
|
|
754
|
+
|
|
627
755
|
\`\`\`no-highlight
|
|
628
756
|
Here's our logo (hover to see the title text):
|
|
629
|
-
|
|
630
|
-
Inline-style:
|
|
757
|
+
|
|
758
|
+
Inline-style:
|
|
631
759
|

|
|
632
|
-
|
|
633
|
-
Reference-style:
|
|
760
|
+
|
|
761
|
+
Reference-style:
|
|
634
762
|
![alt text][logo]
|
|
635
|
-
|
|
763
|
+
|
|
636
764
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
637
765
|
\`\`\`
|
|
638
|
-
|
|
766
|
+
|
|
639
767
|
Here's our logo (hover to see the title text):
|
|
640
|
-
|
|
641
|
-
Inline-style:
|
|
768
|
+
|
|
769
|
+
Inline-style:
|
|
642
770
|

|
|
643
|
-
|
|
644
|
-
Reference-style:
|
|
771
|
+
|
|
772
|
+
Reference-style:
|
|
645
773
|
![alt text][logo]
|
|
646
|
-
|
|
774
|
+
|
|
647
775
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
648
|
-
|
|
776
|
+
|
|
649
777
|
<a name="code"></a>
|
|
650
|
-
|
|
778
|
+
|
|
651
779
|
## Code and Syntax Highlighting
|
|
652
|
-
|
|
780
|
+
|
|
653
781
|
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
|
-
|
|
782
|
+
|
|
655
783
|
\`\`\`no-highlight
|
|
656
784
|
Inline \`code\` has \`back-ticks around\` it.
|
|
657
785
|
\`\`\`
|
|
658
|
-
|
|
786
|
+
|
|
659
787
|
Inline \`code\` has \`back-ticks around\` it.
|
|
660
|
-
|
|
788
|
+
|
|
661
789
|
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
|
-
|
|
790
|
+
|
|
663
791
|
\`\`\`javascript
|
|
664
792
|
var s = "JavaScript syntax highlighting";
|
|
665
793
|
alert(s);
|
|
666
794
|
\`\`\`
|
|
667
|
-
|
|
795
|
+
|
|
668
796
|
\`\`\`python
|
|
669
797
|
s = "Python syntax highlighting"
|
|
670
798
|
print s
|
|
671
799
|
\`\`\`
|
|
672
|
-
|
|
800
|
+
|
|
673
801
|
\`\`\`
|
|
674
|
-
No language indicated, so no syntax highlighting.
|
|
802
|
+
No language indicated, so no syntax highlighting.
|
|
675
803
|
But let's throw in a <b>tag</b>.
|
|
676
804
|
\`\`\`
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
|
|
681
809
|
\`\`\`javascript
|
|
682
810
|
var s = "JavaScript syntax highlighting";
|
|
683
811
|
alert(s);
|
|
684
812
|
\`\`\`
|
|
685
|
-
|
|
813
|
+
|
|
686
814
|
\`\`\`python
|
|
687
815
|
s = "Python syntax highlighting"
|
|
688
816
|
print s
|
|
689
817
|
\`\`\`
|
|
690
|
-
|
|
818
|
+
|
|
691
819
|
\`\`\`
|
|
692
|
-
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
820
|
+
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
693
821
|
But let's throw in a <b>tag</b>.
|
|
694
822
|
\`\`\`
|
|
695
|
-
|
|
696
|
-
|
|
823
|
+
|
|
824
|
+
|
|
697
825
|
<a name="tables"></a>
|
|
698
|
-
|
|
826
|
+
|
|
699
827
|
## Tables
|
|
700
|
-
|
|
828
|
+
|
|
701
829
|
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
|
-
|
|
830
|
+
|
|
703
831
|
\`\`\`no-highlight
|
|
704
832
|
Colons can be used to align columns.
|
|
705
|
-
|
|
833
|
+
|
|
706
834
|
| Tables | Are | Cool |
|
|
707
835
|
| ------------- |:-------------:| -----:|
|
|
708
836
|
| col 3 is | right-aligned | $1600 |
|
|
709
837
|
| col 2 is | centered | $12 |
|
|
710
838
|
| zebra stripes | are neat | $1 |
|
|
711
|
-
|
|
839
|
+
|
|
712
840
|
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
|
|
841
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
714
842
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
715
|
-
|
|
843
|
+
|
|
716
844
|
Markdown | Less | Pretty
|
|
717
845
|
--- | --- | ---
|
|
718
846
|
*Still* | \`renders\` | **nicely**
|
|
719
847
|
1 | 2 | 3
|
|
720
848
|
\`\`\`
|
|
721
|
-
|
|
849
|
+
|
|
722
850
|
Colons can be used to align columns.
|
|
723
|
-
|
|
851
|
+
|
|
724
852
|
| Tables | Are | Cool |
|
|
725
853
|
| ------------- |:-------------:| -----:|
|
|
726
854
|
| col 3 is | right-aligned | $1600 |
|
|
727
855
|
| col 2 is | centered | $12 |
|
|
728
856
|
| zebra stripes | are neat | $1 |
|
|
729
|
-
|
|
857
|
+
|
|
730
858
|
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
|
-
|
|
859
|
+
|
|
732
860
|
Markdown | Less | Pretty
|
|
733
861
|
--- | --- | ---
|
|
734
862
|
*Still* | \`renders\` | **nicely**
|
|
735
863
|
1 | 2 | 3
|
|
736
|
-
|
|
864
|
+
|
|
737
865
|
<a name="blockquotes"></a>
|
|
738
|
-
|
|
866
|
+
|
|
739
867
|
## Blockquotes
|
|
740
|
-
|
|
868
|
+
|
|
741
869
|
\`\`\`no-highlight
|
|
742
870
|
> Blockquotes are very handy in email to emulate reply text.
|
|
743
871
|
> This line is part of the same quote.
|
|
744
|
-
|
|
872
|
+
|
|
745
873
|
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.
|
|
874
|
+
|
|
875
|
+
> 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
876
|
\`\`\`
|
|
749
|
-
|
|
877
|
+
|
|
750
878
|
> Blockquotes are very handy in email to emulate reply text.
|
|
751
879
|
> This line is part of the same quote.
|
|
752
|
-
|
|
880
|
+
|
|
753
881
|
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
|
-
|
|
882
|
+
|
|
883
|
+
> 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.
|
|
884
|
+
|
|
757
885
|
<a name="html"></a>
|
|
758
|
-
|
|
886
|
+
|
|
759
887
|
## Inline HTML
|
|
760
|
-
|
|
761
|
-
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
|
|
762
|
-
|
|
888
|
+
|
|
889
|
+
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
|
|
890
|
+
|
|
763
891
|
\`\`\`no-highlight
|
|
764
892
|
<dl>
|
|
765
893
|
<dt>Definition list</dt>
|
|
766
894
|
<dd>Is something people use sometimes.</dd>
|
|
767
|
-
|
|
895
|
+
|
|
768
896
|
<dt>Markdown in HTML</dt>
|
|
769
897
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
770
898
|
</dl>
|
|
771
899
|
\`\`\`
|
|
772
|
-
|
|
900
|
+
|
|
773
901
|
<dl>
|
|
774
902
|
<dt>Definition list</dt>
|
|
775
903
|
<dd>Is something people use sometimes.</dd>
|
|
776
|
-
|
|
904
|
+
|
|
777
905
|
<dt>Markdown in HTML</dt>
|
|
778
906
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
779
907
|
</dl>
|
|
780
|
-
|
|
908
|
+
|
|
781
909
|
<a name="hr"></a>
|
|
782
|
-
|
|
910
|
+
|
|
783
911
|
## Horizontal Rule
|
|
784
|
-
|
|
912
|
+
|
|
785
913
|
\`\`\`
|
|
786
914
|
Three or more...
|
|
787
|
-
|
|
915
|
+
|
|
788
916
|
---
|
|
789
|
-
|
|
917
|
+
|
|
790
918
|
Hyphens
|
|
791
|
-
|
|
919
|
+
|
|
792
920
|
***
|
|
793
|
-
|
|
921
|
+
|
|
794
922
|
Asterisks
|
|
795
|
-
|
|
923
|
+
|
|
796
924
|
___
|
|
797
|
-
|
|
925
|
+
|
|
798
926
|
Underscores
|
|
799
927
|
\`\`\`
|
|
800
|
-
|
|
928
|
+
|
|
801
929
|
Three or more...
|
|
802
|
-
|
|
930
|
+
|
|
803
931
|
---
|
|
804
|
-
|
|
932
|
+
|
|
805
933
|
Hyphens
|
|
806
|
-
|
|
934
|
+
|
|
807
935
|
***
|
|
808
|
-
|
|
936
|
+
|
|
809
937
|
Asterisks
|
|
810
|
-
|
|
938
|
+
|
|
811
939
|
___
|
|
812
|
-
|
|
940
|
+
|
|
813
941
|
Underscores
|
|
814
|
-
|
|
942
|
+
|
|
815
943
|
<a name="lines"></a>
|
|
816
|
-
|
|
944
|
+
|
|
817
945
|
## 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
|
-
|
|
946
|
+
|
|
947
|
+
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.
|
|
948
|
+
|
|
821
949
|
Here are some things to try out:
|
|
822
|
-
|
|
950
|
+
|
|
823
951
|
\`\`\`
|
|
824
952
|
Here's a line for us to start with.
|
|
825
|
-
|
|
953
|
+
|
|
826
954
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
827
|
-
|
|
955
|
+
|
|
828
956
|
This line is also a separate paragraph, but...
|
|
829
957
|
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
|
|
830
958
|
\`\`\`
|
|
831
|
-
|
|
959
|
+
|
|
832
960
|
Here's a line for us to start with.
|
|
833
|
-
|
|
961
|
+
|
|
834
962
|
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...
|
|
963
|
+
|
|
964
|
+
This line is also begins a separate paragraph, but...
|
|
837
965
|
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
|
|
838
|
-
|
|
966
|
+
|
|
839
967
|
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
|
|
840
|
-
|
|
968
|
+
|
|
841
969
|
<a name="videos"></a>
|
|
842
|
-
|
|
970
|
+
|
|
843
971
|
## YouTube Videos
|
|
844
|
-
|
|
972
|
+
|
|
845
973
|
They can't be added directly but you can add an image with a link to the video like this:
|
|
846
|
-
|
|
974
|
+
|
|
847
975
|
\`\`\`no-highlight
|
|
848
976
|
<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"
|
|
977
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
850
978
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
|
|
851
979
|
\`\`\`
|
|
852
|
-
|
|
980
|
+
|
|
853
981
|
Or, in pure Markdown, but losing the image sizing and border:
|
|
854
|
-
|
|
982
|
+
|
|
855
983
|
\`\`\`no-highlight
|
|
856
984
|
[](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
|
|
857
985
|
\`\`\`
|
|
@@ -884,9 +1012,6 @@ test('kitchen sink', () => {
|
|
|
884
1012
|
{
|
|
885
1013
|
"message": "Unsupported language no-highlight",
|
|
886
1014
|
},
|
|
887
|
-
{
|
|
888
|
-
"message": "Unsupported jsx component dl",
|
|
889
|
-
},
|
|
890
1015
|
{
|
|
891
1016
|
"message": "Unsupported language no-highlight",
|
|
892
1017
|
},
|
|
@@ -894,7 +1019,18 @@ test('kitchen sink', () => {
|
|
|
894
1019
|
"message": "Unsupported language no-highlight",
|
|
895
1020
|
},
|
|
896
1021
|
],
|
|
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
|
|
1022
|
+
"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>
|
|
1023
|
+
<a href="#emphasis" title="">Emphasis</a>
|
|
1024
|
+
<a href="#lists" title="">Lists</a>
|
|
1025
|
+
<a href="#links" title="">Links</a>
|
|
1026
|
+
<a href="#images" title="">Images</a>
|
|
1027
|
+
<a href="#code" title="">Code and Syntax Highlighting</a>
|
|
1028
|
+
<a href="#tables" title="">Tables</a>
|
|
1029
|
+
<a href="#blockquotes" title="">Blockquotes</a>
|
|
1030
|
+
<a href="#html" title="">Inline HTML</a>
|
|
1031
|
+
<a href="#hr" title="">Horizontal Rule</a>
|
|
1032
|
+
<a href="#lines" title="">Line Breaks</a>
|
|
1033
|
+
<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
1034
|
|
|
899
1035
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
900
1036
|
|
|
@@ -902,7 +1038,7 @@ test('kitchen sink', () => {
|
|
|
902
1038
|
|
|
903
1039
|
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
1040
|
2. Another item
|
|
905
|
-
⋅⋅* Unordered sub-list.
|
|
1041
|
+
⋅⋅* Unordered sub-list.
|
|
906
1042
|
1. Actual numbers don't matter, just that it's a number
|
|
907
1043
|
⋅⋅1. Ordered sub-list
|
|
908
1044
|
4. And another item.
|
|
@@ -915,7 +1051,9 @@ test('kitchen sink', () => {
|
|
|
915
1051
|
|
|
916
1052
|
* Unordered list can use asterisks
|
|
917
1053
|
- 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
|
|
1054
|
+
+ 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.
|
|
1055
|
+
Note that this line is separate, but within the same paragraph.
|
|
1056
|
+
(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
1057
|
|
|
920
1058
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
921
1059
|
|
|
@@ -927,8 +1065,8 @@ test('kitchen sink', () => {
|
|
|
927
1065
|
|
|
928
1066
|
Or leave it empty and use the [link text itself].
|
|
929
1067
|
|
|
930
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
931
|
-
http://www.example.com and sometimes
|
|
1068
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1069
|
+
http://www.example.com and sometimes
|
|
932
1070
|
example.com (but not on Github, for example).
|
|
933
1071
|
|
|
934
1072
|
Some text to show that the reference links can follow later.
|
|
@@ -939,20 +1077,20 @@ test('kitchen sink', () => {
|
|
|
939
1077
|
<a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
|
|
940
1078
|
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
1079
|
|
|
942
|
-
Inline-style:
|
|
1080
|
+
Inline-style:
|
|
943
1081
|

|
|
944
1082
|
|
|
945
|
-
Reference-style:
|
|
1083
|
+
Reference-style:
|
|
946
1084
|
![alt text][logo]
|
|
947
1085
|
|
|
948
1086
|
[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
1087
|
<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
1088
|
</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
1089
|
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.
|
|
1090
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
953
1091
|
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
1092
|
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).
|
|
1093
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
956
1094
|
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
1095
|
|
|
958
1096
|
| Tables | Are | Cool |
|
|
@@ -962,7 +1100,7 @@ test('kitchen sink', () => {
|
|
|
962
1100
|
| zebra stripes | are neat | $1 |
|
|
963
1101
|
|
|
964
1102
|
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
|
|
1103
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
966
1104
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
967
1105
|
|
|
968
1106
|
Markdown | Less | Pretty
|
|
@@ -973,14 +1111,14 @@ test('kitchen sink', () => {
|
|
|
973
1111
|
|
|
974
1112
|
Quote break.
|
|
975
1113
|
|
|
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
|
|
1114
|
+
> 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
1115
|
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
1116
|
<dt>Definition list</dt>
|
|
979
1117
|
<dd>Is something people use sometimes.</dd>
|
|
980
1118
|
|
|
981
1119
|
<dt>Markdown in HTML</dt>
|
|
982
1120
|
<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...
|
|
1121
|
+
</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
1122
|
|
|
985
1123
|
---
|
|
986
1124
|
|
|
@@ -997,8 +1135,9 @@ test('kitchen sink', () => {
|
|
|
997
1135
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
998
1136
|
|
|
999
1137
|
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
|
-
|
|
1138
|
+
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...
|
|
1139
|
+
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
|
|
1140
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
1002
1141
|
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
1142
|
"result": <React.Fragment>
|
|
1004
1143
|
<h1>
|
|
@@ -1072,77 +1211,88 @@ test('kitchen sink', () => {
|
|
|
1072
1211
|
>
|
|
1073
1212
|
Headers
|
|
1074
1213
|
</a>
|
|
1075
|
-
|
|
1214
|
+
|
|
1215
|
+
|
|
1076
1216
|
<a
|
|
1077
1217
|
href="#emphasis"
|
|
1078
1218
|
title=""
|
|
1079
1219
|
>
|
|
1080
1220
|
Emphasis
|
|
1081
1221
|
</a>
|
|
1082
|
-
|
|
1222
|
+
|
|
1223
|
+
|
|
1083
1224
|
<a
|
|
1084
1225
|
href="#lists"
|
|
1085
1226
|
title=""
|
|
1086
1227
|
>
|
|
1087
1228
|
Lists
|
|
1088
1229
|
</a>
|
|
1089
|
-
|
|
1230
|
+
|
|
1231
|
+
|
|
1090
1232
|
<a
|
|
1091
1233
|
href="#links"
|
|
1092
1234
|
title=""
|
|
1093
1235
|
>
|
|
1094
1236
|
Links
|
|
1095
1237
|
</a>
|
|
1096
|
-
|
|
1238
|
+
|
|
1239
|
+
|
|
1097
1240
|
<a
|
|
1098
1241
|
href="#images"
|
|
1099
1242
|
title=""
|
|
1100
1243
|
>
|
|
1101
1244
|
Images
|
|
1102
1245
|
</a>
|
|
1103
|
-
|
|
1246
|
+
|
|
1247
|
+
|
|
1104
1248
|
<a
|
|
1105
1249
|
href="#code"
|
|
1106
1250
|
title=""
|
|
1107
1251
|
>
|
|
1108
1252
|
Code and Syntax Highlighting
|
|
1109
1253
|
</a>
|
|
1110
|
-
|
|
1254
|
+
|
|
1255
|
+
|
|
1111
1256
|
<a
|
|
1112
1257
|
href="#tables"
|
|
1113
1258
|
title=""
|
|
1114
1259
|
>
|
|
1115
1260
|
Tables
|
|
1116
1261
|
</a>
|
|
1117
|
-
|
|
1262
|
+
|
|
1263
|
+
|
|
1118
1264
|
<a
|
|
1119
1265
|
href="#blockquotes"
|
|
1120
1266
|
title=""
|
|
1121
1267
|
>
|
|
1122
1268
|
Blockquotes
|
|
1123
1269
|
</a>
|
|
1124
|
-
|
|
1270
|
+
|
|
1271
|
+
|
|
1125
1272
|
<a
|
|
1126
1273
|
href="#html"
|
|
1127
1274
|
title=""
|
|
1128
1275
|
>
|
|
1129
1276
|
Inline HTML
|
|
1130
1277
|
</a>
|
|
1131
|
-
|
|
1278
|
+
|
|
1279
|
+
|
|
1132
1280
|
<a
|
|
1133
1281
|
href="#hr"
|
|
1134
1282
|
title=""
|
|
1135
1283
|
>
|
|
1136
1284
|
Horizontal Rule
|
|
1137
1285
|
</a>
|
|
1138
|
-
|
|
1286
|
+
|
|
1287
|
+
|
|
1139
1288
|
<a
|
|
1140
1289
|
href="#lines"
|
|
1141
1290
|
title=""
|
|
1142
1291
|
>
|
|
1143
1292
|
Line Breaks
|
|
1144
1293
|
</a>
|
|
1145
|
-
|
|
1294
|
+
|
|
1295
|
+
|
|
1146
1296
|
<a
|
|
1147
1297
|
href="#videos"
|
|
1148
1298
|
title=""
|
|
@@ -1278,7 +1428,7 @@ test('kitchen sink', () => {
|
|
|
1278
1428
|
<code>
|
|
1279
1429
|
1. First ordered list item
|
|
1280
1430
|
2. Another item
|
|
1281
|
-
⋅⋅* Unordered sub-list.
|
|
1431
|
+
⋅⋅* Unordered sub-list.
|
|
1282
1432
|
1. Actual numbers don't matter, just that it's a number
|
|
1283
1433
|
⋅⋅1. Ordered sub-list
|
|
1284
1434
|
4. And another item.
|
|
@@ -1337,10 +1487,8 @@ test('kitchen sink', () => {
|
|
|
1337
1487
|
</p>
|
|
1338
1488
|
<p>
|
|
1339
1489
|
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.)
|
|
1490
|
+
Note that this line is separate, but within the same paragraph.
|
|
1491
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
1344
1492
|
</p>
|
|
1345
1493
|
</li>
|
|
1346
1494
|
</ol>
|
|
@@ -1388,8 +1536,8 @@ test('kitchen sink', () => {
|
|
|
1388
1536
|
|
|
1389
1537
|
Or leave it empty and use the [link text itself].
|
|
1390
1538
|
|
|
1391
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1392
|
-
http://www.example.com and sometimes
|
|
1539
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1540
|
+
http://www.example.com and sometimes
|
|
1393
1541
|
example.com (but not on Github, for example).
|
|
1394
1542
|
|
|
1395
1543
|
Some text to show that the reference links can follow later.
|
|
@@ -1471,10 +1619,10 @@ test('kitchen sink', () => {
|
|
|
1471
1619
|
<code>
|
|
1472
1620
|
Here's our logo (hover to see the title text):
|
|
1473
1621
|
|
|
1474
|
-
Inline-style:
|
|
1622
|
+
Inline-style:
|
|
1475
1623
|

|
|
1476
1624
|
|
|
1477
|
-
Reference-style:
|
|
1625
|
+
Reference-style:
|
|
1478
1626
|
![alt text][logo]
|
|
1479
1627
|
|
|
1480
1628
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
@@ -1561,7 +1709,7 @@ test('kitchen sink', () => {
|
|
|
1561
1709
|
</pre>
|
|
1562
1710
|
<pre>
|
|
1563
1711
|
<code>
|
|
1564
|
-
No language indicated, so no syntax highlighting.
|
|
1712
|
+
No language indicated, so no syntax highlighting.
|
|
1565
1713
|
But let's throw in a <b>tag</b>.
|
|
1566
1714
|
</code>
|
|
1567
1715
|
</pre>
|
|
@@ -1583,7 +1731,7 @@ test('kitchen sink', () => {
|
|
|
1583
1731
|
</pre>
|
|
1584
1732
|
<pre>
|
|
1585
1733
|
<code>
|
|
1586
|
-
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1734
|
+
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1587
1735
|
But let's throw in a <b>tag</b>.
|
|
1588
1736
|
</code>
|
|
1589
1737
|
</pre>
|
|
@@ -1611,7 +1759,7 @@ test('kitchen sink', () => {
|
|
|
1611
1759
|
| zebra stripes | are neat | $1 |
|
|
1612
1760
|
|
|
1613
1761
|
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
|
|
1762
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
1615
1763
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
1616
1764
|
|
|
1617
1765
|
Markdown | Less | Pretty
|
|
@@ -1790,7 +1938,7 @@ test('kitchen sink', () => {
|
|
|
1790
1938
|
|
|
1791
1939
|
Quote break.
|
|
1792
1940
|
|
|
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.
|
|
1941
|
+
> 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
1942
|
</code>
|
|
1795
1943
|
</pre>
|
|
1796
1944
|
<blockquote>
|
|
@@ -1835,6 +1983,32 @@ test('kitchen sink', () => {
|
|
|
1835
1983
|
</dl>
|
|
1836
1984
|
</code>
|
|
1837
1985
|
</pre>
|
|
1986
|
+
<dl>
|
|
1987
|
+
<dt>
|
|
1988
|
+
Definition list
|
|
1989
|
+
</dt>
|
|
1990
|
+
<dd>
|
|
1991
|
+
Is something people use sometimes.
|
|
1992
|
+
</dd>
|
|
1993
|
+
<dt>
|
|
1994
|
+
Markdown in HTML
|
|
1995
|
+
</dt>
|
|
1996
|
+
<dd>
|
|
1997
|
+
Does
|
|
1998
|
+
<em>
|
|
1999
|
+
not
|
|
2000
|
+
</em>
|
|
2001
|
+
work
|
|
2002
|
+
<strong>
|
|
2003
|
+
very
|
|
2004
|
+
</strong>
|
|
2005
|
+
well. Use HTML
|
|
2006
|
+
<em>
|
|
2007
|
+
tags
|
|
2008
|
+
</em>
|
|
2009
|
+
.
|
|
2010
|
+
</dd>
|
|
2011
|
+
</dl>
|
|
1838
2012
|
<a
|
|
1839
2013
|
name="hr"
|
|
1840
2014
|
/>
|
|
@@ -1907,8 +2081,7 @@ test('kitchen sink', () => {
|
|
|
1907
2081
|
</p>
|
|
1908
2082
|
<p>
|
|
1909
2083
|
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
|
|
2084
|
+
This line is only separated by a single newline, so it's a separate line in the
|
|
1912
2085
|
<em>
|
|
1913
2086
|
same paragraph
|
|
1914
2087
|
</em>
|
|
@@ -1933,7 +2106,7 @@ test('kitchen sink', () => {
|
|
|
1933
2106
|
<pre>
|
|
1934
2107
|
<code>
|
|
1935
2108
|
<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"
|
|
2109
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
1937
2110
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
|
|
1938
2111
|
</code>
|
|
1939
2112
|
</pre>
|
|
@@ -1988,3 +2161,144 @@ test('code block rendering', () => {
|
|
|
1988
2161
|
}
|
|
1989
2162
|
`)
|
|
1990
2163
|
})
|
|
2164
|
+
|
|
2165
|
+
test('code is not wrapped by p', () => {
|
|
2166
|
+
const code = `
|
|
2167
|
+
---
|
|
2168
|
+
title: createSearchParams
|
|
2169
|
+
---
|
|
2170
|
+
|
|
2171
|
+
# createSearchParams
|
|
2172
|
+
|
|
2173
|
+
[MODES: framework, data, declarative]
|
|
2174
|
+
|
|
2175
|
+
## Summary
|
|
2176
|
+
|
|
2177
|
+
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html)
|
|
2178
|
+
|
|
2179
|
+
Creates a URLSearchParams object using the given initializer.
|
|
2180
|
+
|
|
2181
|
+
This is identical to \`new URLSearchParams(init)\` except it also
|
|
2182
|
+
supports arrays as values in the object form of the initializer
|
|
2183
|
+
instead of just strings. This is convenient when you need multiple
|
|
2184
|
+
values for a given key, but don't want to use an array initializer.
|
|
2185
|
+
|
|
2186
|
+
For example, instead of:
|
|
2187
|
+
|
|
2188
|
+
\`\`\`tsx
|
|
2189
|
+
let searchParams = new URLSearchParams([
|
|
2190
|
+
["sort", "name"],
|
|
2191
|
+
["sort", "price"],
|
|
2192
|
+
]);
|
|
2193
|
+
\`\`\`
|
|
2194
|
+
|
|
2195
|
+
you can do:
|
|
2196
|
+
|
|
2197
|
+
\`\`\`
|
|
2198
|
+
let searchParams = createSearchParams({
|
|
2199
|
+
sort: ['name', 'price']
|
|
2200
|
+
});
|
|
2201
|
+
\`\`\`
|
|
2202
|
+
|
|
2203
|
+
## Signature
|
|
2204
|
+
|
|
2205
|
+
\`\`\`tsx
|
|
2206
|
+
createSearchParams(init): URLSearchParams
|
|
2207
|
+
\`\`\`
|
|
2208
|
+
|
|
2209
|
+
## Params
|
|
2210
|
+
|
|
2211
|
+
### init
|
|
2212
|
+
|
|
2213
|
+
[modes: framework, data, declarative]
|
|
2214
|
+
|
|
2215
|
+
_No documentation_
|
|
2216
|
+
|
|
2217
|
+
`
|
|
2218
|
+
const jsx = render(code)
|
|
2219
|
+
expect(jsx.result).toMatchInlineSnapshot(`
|
|
2220
|
+
<React.Fragment>
|
|
2221
|
+
<hr />
|
|
2222
|
+
<h2>
|
|
2223
|
+
title: createSearchParams
|
|
2224
|
+
</h2>
|
|
2225
|
+
<h1>
|
|
2226
|
+
createSearchParams
|
|
2227
|
+
</h1>
|
|
2228
|
+
<p>
|
|
2229
|
+
[MODES: framework, data, declarative]
|
|
2230
|
+
</p>
|
|
2231
|
+
<h2>
|
|
2232
|
+
Summary
|
|
2233
|
+
</h2>
|
|
2234
|
+
<p>
|
|
2235
|
+
<a
|
|
2236
|
+
href="https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html"
|
|
2237
|
+
title=""
|
|
2238
|
+
>
|
|
2239
|
+
Reference Documentation ↗
|
|
2240
|
+
</a>
|
|
2241
|
+
</p>
|
|
2242
|
+
<p>
|
|
2243
|
+
Creates a URLSearchParams object using the given initializer.
|
|
2244
|
+
</p>
|
|
2245
|
+
<p>
|
|
2246
|
+
This is identical to
|
|
2247
|
+
<code>
|
|
2248
|
+
new URLSearchParams(init)
|
|
2249
|
+
</code>
|
|
2250
|
+
except it also
|
|
2251
|
+
supports arrays as values in the object form of the initializer
|
|
2252
|
+
instead of just strings. This is convenient when you need multiple
|
|
2253
|
+
values for a given key, but don't want to use an array initializer.
|
|
2254
|
+
</p>
|
|
2255
|
+
<p>
|
|
2256
|
+
For example, instead of:
|
|
2257
|
+
</p>
|
|
2258
|
+
<pre>
|
|
2259
|
+
<code
|
|
2260
|
+
className="language-tsx"
|
|
2261
|
+
>
|
|
2262
|
+
let searchParams = new URLSearchParams([
|
|
2263
|
+
["sort", "name"],
|
|
2264
|
+
["sort", "price"],
|
|
2265
|
+
]);
|
|
2266
|
+
</code>
|
|
2267
|
+
</pre>
|
|
2268
|
+
<p>
|
|
2269
|
+
you can do:
|
|
2270
|
+
</p>
|
|
2271
|
+
<pre>
|
|
2272
|
+
<code>
|
|
2273
|
+
let searchParams = createSearchParams({
|
|
2274
|
+
sort: ['name', 'price']
|
|
2275
|
+
});
|
|
2276
|
+
</code>
|
|
2277
|
+
</pre>
|
|
2278
|
+
<h2>
|
|
2279
|
+
Signature
|
|
2280
|
+
</h2>
|
|
2281
|
+
<pre>
|
|
2282
|
+
<code
|
|
2283
|
+
className="language-tsx"
|
|
2284
|
+
>
|
|
2285
|
+
createSearchParams(init): URLSearchParams
|
|
2286
|
+
</code>
|
|
2287
|
+
</pre>
|
|
2288
|
+
<h2>
|
|
2289
|
+
Params
|
|
2290
|
+
</h2>
|
|
2291
|
+
<h3>
|
|
2292
|
+
init
|
|
2293
|
+
</h3>
|
|
2294
|
+
<p>
|
|
2295
|
+
[modes: framework, data, declarative]
|
|
2296
|
+
</p>
|
|
2297
|
+
<p>
|
|
2298
|
+
<em>
|
|
2299
|
+
No documentation
|
|
2300
|
+
</em>
|
|
2301
|
+
</p>
|
|
2302
|
+
</React.Fragment>
|
|
2303
|
+
`)
|
|
2304
|
+
})
|