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/dist/safe-mdx.test.js
CHANGED
|
@@ -9,6 +9,9 @@ const components = {
|
|
|
9
9
|
Heading({ level, children }) {
|
|
10
10
|
return _jsx("h1", { children: children });
|
|
11
11
|
},
|
|
12
|
+
Cards({ level, children }) {
|
|
13
|
+
return _jsx("div", { children: children });
|
|
14
|
+
},
|
|
12
15
|
};
|
|
13
16
|
function render(code) {
|
|
14
17
|
const visitor = new MdastToJsx({ code, components });
|
|
@@ -17,15 +20,107 @@ function render(code) {
|
|
|
17
20
|
// console.log(JSON.stringify(result, null, 2))
|
|
18
21
|
return { result, errors: visitor.errors || [], html };
|
|
19
22
|
}
|
|
23
|
+
import { htmlToJsx } from 'html-to-jsx-transform';
|
|
24
|
+
import { completeJsxTags } from './streaming.js';
|
|
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(`"<nonexisting>text</nonexisting>"`);
|
|
30
|
+
});
|
|
31
|
+
test('markdown inside jsx', () => {
|
|
32
|
+
const code = dedent `
|
|
33
|
+
# Hello
|
|
34
|
+
|
|
35
|
+
<Heading prop="value">
|
|
36
|
+
Component *children*
|
|
37
|
+
</Heading>
|
|
38
|
+
|
|
39
|
+
<figure>
|
|
40
|
+
some *bold* content
|
|
41
|
+
</figure>
|
|
42
|
+
|
|
43
|
+
`;
|
|
44
|
+
expect(render(code)).toMatchInlineSnapshot(`
|
|
45
|
+
{
|
|
46
|
+
"errors": [],
|
|
47
|
+
"html": "<h1>Hello</h1><h1><p>Component <em>children</em></p></h1><figure><p>some <em>bold</em> content</p></figure>",
|
|
48
|
+
"result": <React.Fragment>
|
|
49
|
+
<h1>
|
|
50
|
+
Hello
|
|
51
|
+
</h1>
|
|
52
|
+
<Heading
|
|
53
|
+
prop="value"
|
|
54
|
+
>
|
|
55
|
+
<p>
|
|
56
|
+
Component
|
|
57
|
+
<em>
|
|
58
|
+
children
|
|
59
|
+
</em>
|
|
60
|
+
</p>
|
|
61
|
+
</Heading>
|
|
62
|
+
<figure>
|
|
63
|
+
<p>
|
|
64
|
+
some
|
|
65
|
+
<em>
|
|
66
|
+
bold
|
|
67
|
+
</em>
|
|
68
|
+
content
|
|
69
|
+
</p>
|
|
70
|
+
</figure>
|
|
71
|
+
</React.Fragment>,
|
|
72
|
+
}
|
|
73
|
+
`);
|
|
74
|
+
});
|
|
75
|
+
test('can complete jsx code with completeJsxTags', () => {
|
|
76
|
+
const code = dedent `
|
|
77
|
+
# Hello
|
|
78
|
+
|
|
79
|
+
<Cards>
|
|
80
|
+
<Heading prop="value">
|
|
81
|
+
some value
|
|
82
|
+
|
|
83
|
+
Component *children*
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
`;
|
|
88
|
+
expect(render(completeJsxTags(code))).toMatchInlineSnapshot(`
|
|
89
|
+
{
|
|
90
|
+
"errors": [],
|
|
91
|
+
"html": "<h1>Hello</h1><div><h1></h1></div>",
|
|
92
|
+
"result": <React.Fragment>
|
|
93
|
+
<h1>
|
|
94
|
+
Hello
|
|
95
|
+
</h1>
|
|
96
|
+
<Cards>
|
|
97
|
+
<Heading
|
|
98
|
+
prop="value"
|
|
99
|
+
/>
|
|
100
|
+
</Cards>
|
|
101
|
+
</React.Fragment>,
|
|
102
|
+
}
|
|
103
|
+
`);
|
|
104
|
+
});
|
|
20
105
|
test('remark and jsx does not wrap in p', () => {
|
|
21
106
|
const code = dedent `
|
|
107
|
+
---
|
|
108
|
+
title: createSearchParams
|
|
109
|
+
---
|
|
110
|
+
|
|
22
111
|
# Hello
|
|
23
112
|
|
|
24
113
|
i am a paragraph
|
|
25
114
|
|
|
26
115
|
<Heading>heading</Heading>
|
|
27
116
|
|
|
28
|
-
|
|
117
|
+
sone \`inline code\`
|
|
118
|
+
|
|
119
|
+
\`\`\`tsx
|
|
120
|
+
some code
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
what
|
|
29
124
|
`;
|
|
30
125
|
const mdast = mdxParse(code);
|
|
31
126
|
mdastBfs(mdast, (x) => {
|
|
@@ -34,6 +129,10 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
34
129
|
expect(mdast).toMatchInlineSnapshot(`
|
|
35
130
|
{
|
|
36
131
|
"children": [
|
|
132
|
+
{
|
|
133
|
+
"type": "yaml",
|
|
134
|
+
"value": "title: createSearchParams",
|
|
135
|
+
},
|
|
37
136
|
{
|
|
38
137
|
"children": [
|
|
39
138
|
{
|
|
@@ -68,7 +167,26 @@ test('remark and jsx does not wrap in p', () => {
|
|
|
68
167
|
"children": [
|
|
69
168
|
{
|
|
70
169
|
"type": "text",
|
|
71
|
-
"value": "
|
|
170
|
+
"value": "sone ",
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"type": "inlineCode",
|
|
174
|
+
"value": "inline code",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
"type": "paragraph",
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"lang": "tsx",
|
|
181
|
+
"meta": null,
|
|
182
|
+
"type": "code",
|
|
183
|
+
"value": "some code",
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"children": [
|
|
187
|
+
{
|
|
188
|
+
"type": "text",
|
|
189
|
+
"value": "what",
|
|
72
190
|
},
|
|
73
191
|
],
|
|
74
192
|
"type": "paragraph",
|
|
@@ -108,7 +226,7 @@ test('frontmatter', () => {
|
|
|
108
226
|
---
|
|
109
227
|
hello: 5
|
|
110
228
|
---
|
|
111
|
-
|
|
229
|
+
|
|
112
230
|
# Hello
|
|
113
231
|
|
|
114
232
|
i am a paragraph
|
|
@@ -216,7 +334,7 @@ test('table, only head', () => {
|
|
|
216
334
|
|
|
217
335
|
| Tables | Are | Cool |
|
|
218
336
|
| ------------- |:-------------:| -----:|
|
|
219
|
-
|
|
337
|
+
|
|
220
338
|
`)).toMatchInlineSnapshot(`
|
|
221
339
|
{
|
|
222
340
|
"errors": [],
|
|
@@ -333,7 +451,7 @@ test('missing components are ignored', () => {
|
|
|
333
451
|
});
|
|
334
452
|
test('props parsing', () => {
|
|
335
453
|
expect(render(dedent `
|
|
336
|
-
<Heading
|
|
454
|
+
<Heading
|
|
337
455
|
num={2}
|
|
338
456
|
doublequote={"a \" string"}
|
|
339
457
|
quote={'a \' string'}
|
|
@@ -365,7 +483,7 @@ test('props parsing', () => {
|
|
|
365
483
|
"message": "Expressions in jsx props are not supported (jsx={<SomeComponent />})",
|
|
366
484
|
},
|
|
367
485
|
{
|
|
368
|
-
"message": "Expressions in jsx props are not supported (...{
|
|
486
|
+
"message": "Expressions in jsx props are not supported (...{ spread: true })",
|
|
369
487
|
},
|
|
370
488
|
],
|
|
371
489
|
"html": "<h1><p>hi</p></h1>",
|
|
@@ -393,20 +511,20 @@ test('props parsing', () => {
|
|
|
393
511
|
});
|
|
394
512
|
test('breaks', () => {
|
|
395
513
|
expect(render(dedent `
|
|
396
|
-
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
397
|
-
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.
|
|
398
516
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
399
517
|
`)).toMatchInlineSnapshot(`
|
|
400
518
|
{
|
|
401
519
|
"errors": [],
|
|
402
|
-
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces
|
|
520
|
+
"html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
521
|
+
Note that this line is separate, but within the same paragraph.
|
|
522
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
|
|
403
523
|
"result": <React.Fragment>
|
|
404
524
|
<p>
|
|
405
525
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
<br />
|
|
409
|
-
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
526
|
+
Note that this line is separate, but within the same paragraph.
|
|
527
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
410
528
|
</p>
|
|
411
529
|
</React.Fragment>,
|
|
412
530
|
}
|
|
@@ -417,410 +535,410 @@ test('kitchen sink', () => {
|
|
|
417
535
|
expect(render(dedent `
|
|
418
536
|
# Markdown Kitchen Sink
|
|
419
537
|
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.
|
|
420
|
-
|
|
538
|
+
|
|
421
539
|
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/).
|
|
422
|
-
|
|
540
|
+
|
|
423
541
|
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).
|
|
424
|
-
|
|
425
|
-
##### Table of Contents
|
|
426
|
-
[Headers](#headers)
|
|
427
|
-
[Emphasis](#emphasis)
|
|
428
|
-
[Lists](#lists)
|
|
429
|
-
[Links](#links)
|
|
430
|
-
[Images](#images)
|
|
431
|
-
[Code and Syntax Highlighting](#code)
|
|
432
|
-
[Tables](#tables)
|
|
433
|
-
[Blockquotes](#blockquotes)
|
|
434
|
-
[Inline HTML](#html)
|
|
435
|
-
[Horizontal Rule](#hr)
|
|
436
|
-
[Line Breaks](#lines)
|
|
437
|
-
[YouTube Videos](#videos)
|
|
438
|
-
|
|
542
|
+
|
|
543
|
+
##### Table of Contents
|
|
544
|
+
[Headers](#headers)
|
|
545
|
+
[Emphasis](#emphasis)
|
|
546
|
+
[Lists](#lists)
|
|
547
|
+
[Links](#links)
|
|
548
|
+
[Images](#images)
|
|
549
|
+
[Code and Syntax Highlighting](#code)
|
|
550
|
+
[Tables](#tables)
|
|
551
|
+
[Blockquotes](#blockquotes)
|
|
552
|
+
[Inline HTML](#html)
|
|
553
|
+
[Horizontal Rule](#hr)
|
|
554
|
+
[Line Breaks](#lines)
|
|
555
|
+
[YouTube Videos](#videos)
|
|
556
|
+
|
|
439
557
|
<a name="headers"></a>
|
|
440
|
-
|
|
558
|
+
|
|
441
559
|
## Headers
|
|
442
|
-
|
|
443
|
-
|
|
560
|
+
|
|
561
|
+
|
|
444
562
|
# H1
|
|
445
563
|
## H2
|
|
446
564
|
### H3
|
|
447
565
|
#### H4
|
|
448
566
|
##### H5
|
|
449
567
|
###### H6
|
|
450
|
-
|
|
568
|
+
|
|
451
569
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
452
|
-
|
|
570
|
+
|
|
453
571
|
Alt-H1
|
|
454
572
|
======
|
|
455
|
-
|
|
573
|
+
|
|
456
574
|
Alt-H2
|
|
457
575
|
------
|
|
458
|
-
|
|
459
|
-
|
|
576
|
+
|
|
577
|
+
|
|
460
578
|
# H1
|
|
461
579
|
## H2
|
|
462
580
|
### H3
|
|
463
581
|
#### H4
|
|
464
582
|
##### H5
|
|
465
583
|
###### H6
|
|
466
|
-
|
|
584
|
+
|
|
467
585
|
Alternatively, for H1 and H2, an underline-ish style:
|
|
468
|
-
|
|
586
|
+
|
|
469
587
|
Alt-H1
|
|
470
588
|
======
|
|
471
|
-
|
|
589
|
+
|
|
472
590
|
Alt-H2
|
|
473
591
|
------
|
|
474
|
-
|
|
592
|
+
|
|
475
593
|
<a name="emphasis"></a>
|
|
476
|
-
|
|
594
|
+
|
|
477
595
|
## Emphasis
|
|
478
|
-
|
|
596
|
+
|
|
479
597
|
\`\`\`no-highlight
|
|
480
598
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
481
|
-
|
|
599
|
+
|
|
482
600
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
483
|
-
|
|
601
|
+
|
|
484
602
|
Combined emphasis with **asterisks and _underscores_**.
|
|
485
|
-
|
|
603
|
+
|
|
486
604
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
487
605
|
\`\`\`
|
|
488
|
-
|
|
606
|
+
|
|
489
607
|
Emphasis, aka italics, with *asterisks* or _underscores_.
|
|
490
|
-
|
|
608
|
+
|
|
491
609
|
Strong emphasis, aka bold, with **asterisks** or __underscores__.
|
|
492
|
-
|
|
610
|
+
|
|
493
611
|
Combined emphasis with **asterisks and _underscores_**.
|
|
494
|
-
|
|
612
|
+
|
|
495
613
|
Strikethrough uses two tildes. ~~Scratch this.~~
|
|
496
|
-
|
|
497
|
-
|
|
614
|
+
|
|
615
|
+
|
|
498
616
|
<a name="lists"></a>
|
|
499
|
-
|
|
617
|
+
|
|
500
618
|
## Lists
|
|
501
|
-
|
|
619
|
+
|
|
502
620
|
(In this example, leading and trailing spaces are shown with with dots: ⋅)
|
|
503
|
-
|
|
621
|
+
|
|
504
622
|
\`\`\`no-highlight
|
|
505
623
|
1. First ordered list item
|
|
506
624
|
2. Another item
|
|
507
|
-
⋅⋅* Unordered sub-list.
|
|
625
|
+
⋅⋅* Unordered sub-list.
|
|
508
626
|
1. Actual numbers don't matter, just that it's a number
|
|
509
627
|
⋅⋅1. Ordered sub-list
|
|
510
628
|
4. And another item.
|
|
511
|
-
|
|
629
|
+
|
|
512
630
|
⋅⋅⋅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).
|
|
513
|
-
|
|
631
|
+
|
|
514
632
|
⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
|
|
515
633
|
⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
|
|
516
634
|
⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
517
|
-
|
|
635
|
+
|
|
518
636
|
* Unordered list can use asterisks
|
|
519
637
|
- Or minuses
|
|
520
638
|
+ Or pluses
|
|
521
639
|
\`\`\`
|
|
522
|
-
|
|
640
|
+
|
|
523
641
|
1. First ordered list item
|
|
524
642
|
2. Another item
|
|
525
|
-
* Unordered sub-list.
|
|
643
|
+
* Unordered sub-list.
|
|
526
644
|
1. Actual numbers don't matter, just that it's a number
|
|
527
645
|
1. Ordered sub-list
|
|
528
646
|
4. And another item.
|
|
529
|
-
|
|
647
|
+
|
|
530
648
|
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).
|
|
531
|
-
|
|
532
|
-
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
533
|
-
Note that this line is separate, but within the same paragraph.
|
|
649
|
+
|
|
650
|
+
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
651
|
+
Note that this line is separate, but within the same paragraph.
|
|
534
652
|
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
535
|
-
|
|
653
|
+
|
|
536
654
|
* Unordered list can use asterisks
|
|
537
655
|
- Or minuses
|
|
538
656
|
+ Or pluses
|
|
539
|
-
|
|
657
|
+
|
|
540
658
|
<a name="links"></a>
|
|
541
|
-
|
|
659
|
+
|
|
542
660
|
## Links
|
|
543
|
-
|
|
661
|
+
|
|
544
662
|
There are two ways to create links.
|
|
545
|
-
|
|
663
|
+
|
|
546
664
|
\`\`\`no-highlight
|
|
547
665
|
[I'm an inline-style link](https://www.google.com)
|
|
548
|
-
|
|
666
|
+
|
|
549
667
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
550
|
-
|
|
668
|
+
|
|
551
669
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
552
|
-
|
|
670
|
+
|
|
553
671
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
554
|
-
|
|
672
|
+
|
|
555
673
|
[You can use numbers for reference-style link definitions][1]
|
|
556
|
-
|
|
674
|
+
|
|
557
675
|
Or leave it empty and use the [link text itself].
|
|
558
|
-
|
|
559
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
560
|
-
http://www.example.com and sometimes
|
|
676
|
+
|
|
677
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
678
|
+
http://www.example.com and sometimes
|
|
561
679
|
example.com (but not on Github, for example).
|
|
562
|
-
|
|
680
|
+
|
|
563
681
|
Some text to show that the reference links can follow later.
|
|
564
|
-
|
|
682
|
+
|
|
565
683
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
566
684
|
[1]: http://slashdot.org
|
|
567
685
|
[link text itself]: http://www.reddit.com
|
|
568
686
|
\`\`\`
|
|
569
|
-
|
|
687
|
+
|
|
570
688
|
[I'm an inline-style link](https://www.google.com)
|
|
571
|
-
|
|
689
|
+
|
|
572
690
|
[I'm an inline-style link with title](https://www.google.com "Google's Homepage")
|
|
573
|
-
|
|
691
|
+
|
|
574
692
|
[I'm a reference-style link][Arbitrary case-insensitive reference text]
|
|
575
|
-
|
|
693
|
+
|
|
576
694
|
[I'm a relative reference to a repository file](../blob/master/LICENSE)
|
|
577
|
-
|
|
695
|
+
|
|
578
696
|
[You can use numbers for reference-style link definitions][1]
|
|
579
|
-
|
|
697
|
+
|
|
580
698
|
Or leave it empty and use the [link text itself].
|
|
581
|
-
|
|
582
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
583
|
-
http://www.example.com and sometimes
|
|
699
|
+
|
|
700
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
701
|
+
http://www.example.com and sometimes
|
|
584
702
|
example.com (but not on Github, for example).
|
|
585
|
-
|
|
703
|
+
|
|
586
704
|
Some text to show that the reference links can follow later.
|
|
587
|
-
|
|
705
|
+
|
|
588
706
|
[arbitrary case-insensitive reference text]: https://www.mozilla.org
|
|
589
707
|
[1]: http://slashdot.org
|
|
590
708
|
[link text itself]: http://www.reddit.com
|
|
591
|
-
|
|
709
|
+
|
|
592
710
|
<a name="images"></a>
|
|
593
|
-
|
|
711
|
+
|
|
594
712
|
## Images
|
|
595
|
-
|
|
713
|
+
|
|
596
714
|
\`\`\`no-highlight
|
|
597
715
|
Here's our logo (hover to see the title text):
|
|
598
|
-
|
|
599
|
-
Inline-style:
|
|
716
|
+
|
|
717
|
+
Inline-style:
|
|
600
718
|

|
|
601
|
-
|
|
602
|
-
Reference-style:
|
|
719
|
+
|
|
720
|
+
Reference-style:
|
|
603
721
|
![alt text][logo]
|
|
604
|
-
|
|
722
|
+
|
|
605
723
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
606
724
|
\`\`\`
|
|
607
|
-
|
|
725
|
+
|
|
608
726
|
Here's our logo (hover to see the title text):
|
|
609
|
-
|
|
610
|
-
Inline-style:
|
|
727
|
+
|
|
728
|
+
Inline-style:
|
|
611
729
|

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

|
|
912
1040
|
|
|
913
|
-
Reference-style:
|
|
1041
|
+
Reference-style:
|
|
914
1042
|
![alt text][logo]
|
|
915
1043
|
|
|
916
1044
|
[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:
|
|
917
1045
|
<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:
|
|
918
1046
|
</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";
|
|
919
1047
|
alert(s);</code></pre><pre><code class="language-python">s = "Python syntax highlighting"
|
|
920
|
-
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
1048
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
|
|
921
1049
|
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";
|
|
922
1050
|
alert(s);</code></pre><pre><code class="language-python">s = "Python syntax highlighting"
|
|
923
|
-
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1051
|
+
print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
924
1052
|
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.
|
|
925
1053
|
|
|
926
1054
|
| Tables | Are | Cool |
|
|
@@ -930,7 +1058,7 @@ test('kitchen sink', () => {
|
|
|
930
1058
|
| zebra stripes | are neat | $1 |
|
|
931
1059
|
|
|
932
1060
|
There must be at least 3 dashes separating each header cell.
|
|
933
|
-
The outer pipes (|) are optional, and you don't need to make the
|
|
1061
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
934
1062
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
935
1063
|
|
|
936
1064
|
Markdown | Less | Pretty
|
|
@@ -941,14 +1069,14 @@ test('kitchen sink', () => {
|
|
|
941
1069
|
|
|
942
1070
|
Quote break.
|
|
943
1071
|
|
|
944
|
-
> 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
|
|
1072
|
+
> 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.
|
|
945
1073
|
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>
|
|
946
1074
|
<dt>Definition list</dt>
|
|
947
1075
|
<dd>Is something people use sometimes.</dd>
|
|
948
1076
|
|
|
949
1077
|
<dt>Markdown in HTML</dt>
|
|
950
1078
|
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
|
|
951
|
-
</dl></code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
|
|
1079
|
+
</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...
|
|
952
1080
|
|
|
953
1081
|
---
|
|
954
1082
|
|
|
@@ -965,8 +1093,9 @@ test('kitchen sink', () => {
|
|
|
965
1093
|
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
|
|
966
1094
|
|
|
967
1095
|
This line is also a separate paragraph, but...
|
|
968
|
-
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
|
|
969
|
-
|
|
1096
|
+
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...
|
|
1097
|
+
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
|
|
1098
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
970
1099
|
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>",
|
|
971
1100
|
"result": <React.Fragment>
|
|
972
1101
|
<h1>
|
|
@@ -1040,77 +1169,88 @@ test('kitchen sink', () => {
|
|
|
1040
1169
|
>
|
|
1041
1170
|
Headers
|
|
1042
1171
|
</a>
|
|
1043
|
-
|
|
1172
|
+
|
|
1173
|
+
|
|
1044
1174
|
<a
|
|
1045
1175
|
href="#emphasis"
|
|
1046
1176
|
title=""
|
|
1047
1177
|
>
|
|
1048
1178
|
Emphasis
|
|
1049
1179
|
</a>
|
|
1050
|
-
|
|
1180
|
+
|
|
1181
|
+
|
|
1051
1182
|
<a
|
|
1052
1183
|
href="#lists"
|
|
1053
1184
|
title=""
|
|
1054
1185
|
>
|
|
1055
1186
|
Lists
|
|
1056
1187
|
</a>
|
|
1057
|
-
|
|
1188
|
+
|
|
1189
|
+
|
|
1058
1190
|
<a
|
|
1059
1191
|
href="#links"
|
|
1060
1192
|
title=""
|
|
1061
1193
|
>
|
|
1062
1194
|
Links
|
|
1063
1195
|
</a>
|
|
1064
|
-
|
|
1196
|
+
|
|
1197
|
+
|
|
1065
1198
|
<a
|
|
1066
1199
|
href="#images"
|
|
1067
1200
|
title=""
|
|
1068
1201
|
>
|
|
1069
1202
|
Images
|
|
1070
1203
|
</a>
|
|
1071
|
-
|
|
1204
|
+
|
|
1205
|
+
|
|
1072
1206
|
<a
|
|
1073
1207
|
href="#code"
|
|
1074
1208
|
title=""
|
|
1075
1209
|
>
|
|
1076
1210
|
Code and Syntax Highlighting
|
|
1077
1211
|
</a>
|
|
1078
|
-
|
|
1212
|
+
|
|
1213
|
+
|
|
1079
1214
|
<a
|
|
1080
1215
|
href="#tables"
|
|
1081
1216
|
title=""
|
|
1082
1217
|
>
|
|
1083
1218
|
Tables
|
|
1084
1219
|
</a>
|
|
1085
|
-
|
|
1220
|
+
|
|
1221
|
+
|
|
1086
1222
|
<a
|
|
1087
1223
|
href="#blockquotes"
|
|
1088
1224
|
title=""
|
|
1089
1225
|
>
|
|
1090
1226
|
Blockquotes
|
|
1091
1227
|
</a>
|
|
1092
|
-
|
|
1228
|
+
|
|
1229
|
+
|
|
1093
1230
|
<a
|
|
1094
1231
|
href="#html"
|
|
1095
1232
|
title=""
|
|
1096
1233
|
>
|
|
1097
1234
|
Inline HTML
|
|
1098
1235
|
</a>
|
|
1099
|
-
|
|
1236
|
+
|
|
1237
|
+
|
|
1100
1238
|
<a
|
|
1101
1239
|
href="#hr"
|
|
1102
1240
|
title=""
|
|
1103
1241
|
>
|
|
1104
1242
|
Horizontal Rule
|
|
1105
1243
|
</a>
|
|
1106
|
-
|
|
1244
|
+
|
|
1245
|
+
|
|
1107
1246
|
<a
|
|
1108
1247
|
href="#lines"
|
|
1109
1248
|
title=""
|
|
1110
1249
|
>
|
|
1111
1250
|
Line Breaks
|
|
1112
1251
|
</a>
|
|
1113
|
-
|
|
1252
|
+
|
|
1253
|
+
|
|
1114
1254
|
<a
|
|
1115
1255
|
href="#videos"
|
|
1116
1256
|
title=""
|
|
@@ -1246,7 +1386,7 @@ test('kitchen sink', () => {
|
|
|
1246
1386
|
<code>
|
|
1247
1387
|
1. First ordered list item
|
|
1248
1388
|
2. Another item
|
|
1249
|
-
⋅⋅* Unordered sub-list.
|
|
1389
|
+
⋅⋅* Unordered sub-list.
|
|
1250
1390
|
1. Actual numbers don't matter, just that it's a number
|
|
1251
1391
|
⋅⋅1. Ordered sub-list
|
|
1252
1392
|
4. And another item.
|
|
@@ -1305,10 +1445,8 @@ test('kitchen sink', () => {
|
|
|
1305
1445
|
</p>
|
|
1306
1446
|
<p>
|
|
1307
1447
|
To have a line break without a paragraph, you will need to use two trailing spaces.
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
<br />
|
|
1311
|
-
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
1448
|
+
Note that this line is separate, but within the same paragraph.
|
|
1449
|
+
(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
|
|
1312
1450
|
</p>
|
|
1313
1451
|
</li>
|
|
1314
1452
|
</ol>
|
|
@@ -1356,8 +1494,8 @@ test('kitchen sink', () => {
|
|
|
1356
1494
|
|
|
1357
1495
|
Or leave it empty and use the [link text itself].
|
|
1358
1496
|
|
|
1359
|
-
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1360
|
-
http://www.example.com and sometimes
|
|
1497
|
+
URLs and URLs in angle brackets will automatically get turned into links.
|
|
1498
|
+
http://www.example.com and sometimes
|
|
1361
1499
|
example.com (but not on Github, for example).
|
|
1362
1500
|
|
|
1363
1501
|
Some text to show that the reference links can follow later.
|
|
@@ -1439,10 +1577,10 @@ test('kitchen sink', () => {
|
|
|
1439
1577
|
<code>
|
|
1440
1578
|
Here's our logo (hover to see the title text):
|
|
1441
1579
|
|
|
1442
|
-
Inline-style:
|
|
1580
|
+
Inline-style:
|
|
1443
1581
|

|
|
1444
1582
|
|
|
1445
|
-
Reference-style:
|
|
1583
|
+
Reference-style:
|
|
1446
1584
|
![alt text][logo]
|
|
1447
1585
|
|
|
1448
1586
|
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
|
|
@@ -1529,7 +1667,7 @@ test('kitchen sink', () => {
|
|
|
1529
1667
|
</pre>
|
|
1530
1668
|
<pre>
|
|
1531
1669
|
<code>
|
|
1532
|
-
No language indicated, so no syntax highlighting.
|
|
1670
|
+
No language indicated, so no syntax highlighting.
|
|
1533
1671
|
But let's throw in a <b>tag</b>.
|
|
1534
1672
|
</code>
|
|
1535
1673
|
</pre>
|
|
@@ -1551,7 +1689,7 @@ test('kitchen sink', () => {
|
|
|
1551
1689
|
</pre>
|
|
1552
1690
|
<pre>
|
|
1553
1691
|
<code>
|
|
1554
|
-
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1692
|
+
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
|
|
1555
1693
|
But let's throw in a <b>tag</b>.
|
|
1556
1694
|
</code>
|
|
1557
1695
|
</pre>
|
|
@@ -1579,7 +1717,7 @@ test('kitchen sink', () => {
|
|
|
1579
1717
|
| zebra stripes | are neat | $1 |
|
|
1580
1718
|
|
|
1581
1719
|
There must be at least 3 dashes separating each header cell.
|
|
1582
|
-
The outer pipes (|) are optional, and you don't need to make the
|
|
1720
|
+
The outer pipes (|) are optional, and you don't need to make the
|
|
1583
1721
|
raw Markdown line up prettily. You can also use inline Markdown.
|
|
1584
1722
|
|
|
1585
1723
|
Markdown | Less | Pretty
|
|
@@ -1758,7 +1896,7 @@ test('kitchen sink', () => {
|
|
|
1758
1896
|
|
|
1759
1897
|
Quote break.
|
|
1760
1898
|
|
|
1761
|
-
> 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.
|
|
1899
|
+
> 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.
|
|
1762
1900
|
</code>
|
|
1763
1901
|
</pre>
|
|
1764
1902
|
<blockquote>
|
|
@@ -1803,6 +1941,32 @@ test('kitchen sink', () => {
|
|
|
1803
1941
|
</dl>
|
|
1804
1942
|
</code>
|
|
1805
1943
|
</pre>
|
|
1944
|
+
<dl>
|
|
1945
|
+
<dt>
|
|
1946
|
+
Definition list
|
|
1947
|
+
</dt>
|
|
1948
|
+
<dd>
|
|
1949
|
+
Is something people use sometimes.
|
|
1950
|
+
</dd>
|
|
1951
|
+
<dt>
|
|
1952
|
+
Markdown in HTML
|
|
1953
|
+
</dt>
|
|
1954
|
+
<dd>
|
|
1955
|
+
Does
|
|
1956
|
+
<em>
|
|
1957
|
+
not
|
|
1958
|
+
</em>
|
|
1959
|
+
work
|
|
1960
|
+
<strong>
|
|
1961
|
+
very
|
|
1962
|
+
</strong>
|
|
1963
|
+
well. Use HTML
|
|
1964
|
+
<em>
|
|
1965
|
+
tags
|
|
1966
|
+
</em>
|
|
1967
|
+
.
|
|
1968
|
+
</dd>
|
|
1969
|
+
</dl>
|
|
1806
1970
|
<a
|
|
1807
1971
|
name="hr"
|
|
1808
1972
|
/>
|
|
@@ -1875,8 +2039,7 @@ test('kitchen sink', () => {
|
|
|
1875
2039
|
</p>
|
|
1876
2040
|
<p>
|
|
1877
2041
|
This line is also begins a separate paragraph, but...
|
|
1878
|
-
|
|
1879
|
-
This line is only separated by a single newline, so it's a separate line in the
|
|
2042
|
+
This line is only separated by a single newline, so it's a separate line in the
|
|
1880
2043
|
<em>
|
|
1881
2044
|
same paragraph
|
|
1882
2045
|
</em>
|
|
@@ -1901,7 +2064,7 @@ test('kitchen sink', () => {
|
|
|
1901
2064
|
<pre>
|
|
1902
2065
|
<code>
|
|
1903
2066
|
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
|
|
1904
|
-
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
2067
|
+
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
|
|
1905
2068
|
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
|
|
1906
2069
|
</code>
|
|
1907
2070
|
</pre>
|
|
@@ -1953,4 +2116,144 @@ test('code block rendering', () => {
|
|
|
1953
2116
|
}
|
|
1954
2117
|
`);
|
|
1955
2118
|
});
|
|
2119
|
+
test('code is not wrapped by p', () => {
|
|
2120
|
+
const code = `
|
|
2121
|
+
---
|
|
2122
|
+
title: createSearchParams
|
|
2123
|
+
---
|
|
2124
|
+
|
|
2125
|
+
# createSearchParams
|
|
2126
|
+
|
|
2127
|
+
[MODES: framework, data, declarative]
|
|
2128
|
+
|
|
2129
|
+
## Summary
|
|
2130
|
+
|
|
2131
|
+
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html)
|
|
2132
|
+
|
|
2133
|
+
Creates a URLSearchParams object using the given initializer.
|
|
2134
|
+
|
|
2135
|
+
This is identical to \`new URLSearchParams(init)\` except it also
|
|
2136
|
+
supports arrays as values in the object form of the initializer
|
|
2137
|
+
instead of just strings. This is convenient when you need multiple
|
|
2138
|
+
values for a given key, but don't want to use an array initializer.
|
|
2139
|
+
|
|
2140
|
+
For example, instead of:
|
|
2141
|
+
|
|
2142
|
+
\`\`\`tsx
|
|
2143
|
+
let searchParams = new URLSearchParams([
|
|
2144
|
+
["sort", "name"],
|
|
2145
|
+
["sort", "price"],
|
|
2146
|
+
]);
|
|
2147
|
+
\`\`\`
|
|
2148
|
+
|
|
2149
|
+
you can do:
|
|
2150
|
+
|
|
2151
|
+
\`\`\`
|
|
2152
|
+
let searchParams = createSearchParams({
|
|
2153
|
+
sort: ['name', 'price']
|
|
2154
|
+
});
|
|
2155
|
+
\`\`\`
|
|
2156
|
+
|
|
2157
|
+
## Signature
|
|
2158
|
+
|
|
2159
|
+
\`\`\`tsx
|
|
2160
|
+
createSearchParams(init): URLSearchParams
|
|
2161
|
+
\`\`\`
|
|
2162
|
+
|
|
2163
|
+
## Params
|
|
2164
|
+
|
|
2165
|
+
### init
|
|
2166
|
+
|
|
2167
|
+
[modes: framework, data, declarative]
|
|
2168
|
+
|
|
2169
|
+
_No documentation_
|
|
2170
|
+
|
|
2171
|
+
`;
|
|
2172
|
+
const jsx = render(code);
|
|
2173
|
+
expect(jsx.result).toMatchInlineSnapshot(`
|
|
2174
|
+
<React.Fragment>
|
|
2175
|
+
<hr />
|
|
2176
|
+
<h2>
|
|
2177
|
+
title: createSearchParams
|
|
2178
|
+
</h2>
|
|
2179
|
+
<h1>
|
|
2180
|
+
createSearchParams
|
|
2181
|
+
</h1>
|
|
2182
|
+
<p>
|
|
2183
|
+
[MODES: framework, data, declarative]
|
|
2184
|
+
</p>
|
|
2185
|
+
<h2>
|
|
2186
|
+
Summary
|
|
2187
|
+
</h2>
|
|
2188
|
+
<p>
|
|
2189
|
+
<a
|
|
2190
|
+
href="https://api.reactrouter.com/v7/functions/react_router.createSearchParams.html"
|
|
2191
|
+
title=""
|
|
2192
|
+
>
|
|
2193
|
+
Reference Documentation ↗
|
|
2194
|
+
</a>
|
|
2195
|
+
</p>
|
|
2196
|
+
<p>
|
|
2197
|
+
Creates a URLSearchParams object using the given initializer.
|
|
2198
|
+
</p>
|
|
2199
|
+
<p>
|
|
2200
|
+
This is identical to
|
|
2201
|
+
<code>
|
|
2202
|
+
new URLSearchParams(init)
|
|
2203
|
+
</code>
|
|
2204
|
+
except it also
|
|
2205
|
+
supports arrays as values in the object form of the initializer
|
|
2206
|
+
instead of just strings. This is convenient when you need multiple
|
|
2207
|
+
values for a given key, but don't want to use an array initializer.
|
|
2208
|
+
</p>
|
|
2209
|
+
<p>
|
|
2210
|
+
For example, instead of:
|
|
2211
|
+
</p>
|
|
2212
|
+
<pre>
|
|
2213
|
+
<code
|
|
2214
|
+
className="language-tsx"
|
|
2215
|
+
>
|
|
2216
|
+
let searchParams = new URLSearchParams([
|
|
2217
|
+
["sort", "name"],
|
|
2218
|
+
["sort", "price"],
|
|
2219
|
+
]);
|
|
2220
|
+
</code>
|
|
2221
|
+
</pre>
|
|
2222
|
+
<p>
|
|
2223
|
+
you can do:
|
|
2224
|
+
</p>
|
|
2225
|
+
<pre>
|
|
2226
|
+
<code>
|
|
2227
|
+
let searchParams = createSearchParams({
|
|
2228
|
+
sort: ['name', 'price']
|
|
2229
|
+
});
|
|
2230
|
+
</code>
|
|
2231
|
+
</pre>
|
|
2232
|
+
<h2>
|
|
2233
|
+
Signature
|
|
2234
|
+
</h2>
|
|
2235
|
+
<pre>
|
|
2236
|
+
<code
|
|
2237
|
+
className="language-tsx"
|
|
2238
|
+
>
|
|
2239
|
+
createSearchParams(init): URLSearchParams
|
|
2240
|
+
</code>
|
|
2241
|
+
</pre>
|
|
2242
|
+
<h2>
|
|
2243
|
+
Params
|
|
2244
|
+
</h2>
|
|
2245
|
+
<h3>
|
|
2246
|
+
init
|
|
2247
|
+
</h3>
|
|
2248
|
+
<p>
|
|
2249
|
+
[modes: framework, data, declarative]
|
|
2250
|
+
</p>
|
|
2251
|
+
<p>
|
|
2252
|
+
<em>
|
|
2253
|
+
No documentation
|
|
2254
|
+
</em>
|
|
2255
|
+
</p>
|
|
2256
|
+
</React.Fragment>
|
|
2257
|
+
`);
|
|
2258
|
+
});
|
|
1956
2259
|
//# sourceMappingURL=safe-mdx.test.js.map
|