safe-mdx 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,31 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = __importDefault(require("react"));
8
- const dedent_1 = __importDefault(require("dedent"));
9
- const vitest_1 = require("vitest");
10
- const safe_mdx_1 = require("./safe-mdx");
11
- void react_1.default;
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import dedent from 'dedent';
4
+ import { test, expect } from 'vitest';
5
+ import { MdastToJsx } from './safe-mdx';
6
+ import { renderToStaticMarkup } from 'react-dom/server';
7
+ void React;
12
8
  const components = {
13
9
  Heading({ level, children }) {
14
- return (0, jsx_runtime_1.jsx)("h1", { children: children });
10
+ return _jsx("h1", { children: children });
15
11
  },
16
12
  };
17
13
  function render(code) {
18
- const visitor = new safe_mdx_1.MdastToJsx({ code, components });
14
+ const visitor = new MdastToJsx({ code, components });
19
15
  const result = visitor.run();
16
+ const html = renderToStaticMarkup(result);
20
17
  // console.log(JSON.stringify(result, null, 2))
21
- return { result, errors: visitor.errors || [] };
18
+ return { result, errors: visitor.errors || [], html };
22
19
  }
23
- (0, vitest_1.test)('basic', () => {
24
- (0, vitest_1.expect)(render((0, dedent_1.default) `
20
+ test('basic', () => {
21
+ expect(render(dedent `
25
22
  # Hello
26
23
 
27
24
  i am a paragraph
28
25
  `)).toMatchInlineSnapshot(`
29
26
  {
30
27
  "errors": [],
28
+ "html": "<h1>Hello</h1><p>i am a paragraph</p>",
31
29
  "result": <React.Fragment>
32
30
  <h1>
33
31
  Hello
@@ -39,12 +37,138 @@ function render(code) {
39
37
  }
40
38
  `);
41
39
  });
42
- (0, vitest_1.test)('inline jsx', () => {
43
- (0, vitest_1.expect)(render((0, dedent_1.default) `
40
+ test('table', () => {
41
+ expect(render(dedent `
42
+ # Hello
43
+
44
+ | Tables | Are | Cool |
45
+ | ------------- |:-------------:| -----:|
46
+ | col 3 is | right-aligned | $1600 |
47
+ | col 2 is | centered | $12 |
48
+ `)).toMatchInlineSnapshot(`
49
+ {
50
+ "errors": [],
51
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr></tbody></table>",
52
+ "result": <React.Fragment>
53
+ <h1>
54
+ Hello
55
+ </h1>
56
+ <table>
57
+ <thead>
58
+ <tr
59
+ className=""
60
+ >
61
+ <td
62
+ className=""
63
+ >
64
+ Tables
65
+ </td>
66
+ <td
67
+ className=""
68
+ >
69
+ Are
70
+ </td>
71
+ <td
72
+ className=""
73
+ >
74
+ Cool
75
+ </td>
76
+ </tr>
77
+ </thead>
78
+ <tbody>
79
+ <tr
80
+ className=""
81
+ >
82
+ <td
83
+ className=""
84
+ >
85
+ col 3 is
86
+ </td>
87
+ <td
88
+ className=""
89
+ >
90
+ right-aligned
91
+ </td>
92
+ <td
93
+ className=""
94
+ >
95
+ $1600
96
+ </td>
97
+ </tr>
98
+ <tr
99
+ className=""
100
+ >
101
+ <td
102
+ className=""
103
+ >
104
+ col 2 is
105
+ </td>
106
+ <td
107
+ className=""
108
+ >
109
+ centered
110
+ </td>
111
+ <td
112
+ className=""
113
+ >
114
+ $12
115
+ </td>
116
+ </tr>
117
+ </tbody>
118
+ </table>
119
+ </React.Fragment>,
120
+ }
121
+ `);
122
+ });
123
+ test('table, only head', () => {
124
+ expect(render(dedent `
125
+ # Hello
126
+
127
+ | Tables | Are | Cool |
128
+ | ------------- |:-------------:| -----:|
129
+
130
+ `)).toMatchInlineSnapshot(`
131
+ {
132
+ "errors": [],
133
+ "html": "<h1>Hello</h1><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead></table>",
134
+ "result": <React.Fragment>
135
+ <h1>
136
+ Hello
137
+ </h1>
138
+ <table>
139
+ <thead>
140
+ <tr
141
+ className=""
142
+ >
143
+ <td
144
+ className=""
145
+ >
146
+ Tables
147
+ </td>
148
+ <td
149
+ className=""
150
+ >
151
+ Are
152
+ </td>
153
+ <td
154
+ className=""
155
+ >
156
+ Cool
157
+ </td>
158
+ </tr>
159
+ </thead>
160
+ </table>
161
+ </React.Fragment>,
162
+ }
163
+ `);
164
+ });
165
+ test('inline jsx', () => {
166
+ expect(render(dedent `
44
167
  <Heading level={2}>hello</Heading>
45
168
  `)).toMatchInlineSnapshot(`
46
169
  {
47
170
  "errors": [],
171
+ "html": "<p><h1>hello</h1></p>",
48
172
  "result": <React.Fragment>
49
173
  <p>
50
174
  <Heading
@@ -57,14 +181,15 @@ function render(code) {
57
181
  }
58
182
  `);
59
183
  });
60
- (0, vitest_1.test)('block jsx', () => {
61
- (0, vitest_1.expect)(render((0, dedent_1.default) `
184
+ test('block jsx', () => {
185
+ expect(render(dedent `
62
186
  <Heading level={2}>
63
187
  > hello
64
188
  </Heading>
65
189
  `)).toMatchInlineSnapshot(`
66
190
  {
67
191
  "errors": [],
192
+ "html": "<h1><blockquote><p>hello</p></blockquote></h1>",
68
193
  "result": <React.Fragment>
69
194
  <Heading
70
195
  level={2}
@@ -79,8 +204,32 @@ function render(code) {
79
204
  }
80
205
  `);
81
206
  });
82
- (0, vitest_1.test)('missing components are ignored', () => {
83
- (0, vitest_1.expect)(render((0, dedent_1.default) `
207
+ test('complex jsx, self closing tags', () => {
208
+ expect(render(dedent `
209
+ # hello <br />
210
+
211
+ <br />
212
+
213
+ content
214
+ `)).toMatchInlineSnapshot(`
215
+ {
216
+ "errors": [],
217
+ "html": "<h1>hello <br/></h1><br/><p>content</p>",
218
+ "result": <React.Fragment>
219
+ <h1>
220
+ hello
221
+ <br />
222
+ </h1>
223
+ <br />
224
+ <p>
225
+ content
226
+ </p>
227
+ </React.Fragment>,
228
+ }
229
+ `);
230
+ });
231
+ test('missing components are ignored', () => {
232
+ expect(render(dedent `
84
233
  <MissingComponent level={2} />
85
234
  `)).toMatchInlineSnapshot(`
86
235
  {
@@ -89,12 +238,13 @@ function render(code) {
89
238
  "message": "Unsupported jsx component MissingComponent",
90
239
  },
91
240
  ],
241
+ "html": "",
92
242
  "result": <React.Fragment />,
93
243
  }
94
244
  `);
95
245
  });
96
- (0, vitest_1.test)('props parsing', () => {
97
- (0, vitest_1.expect)(render((0, dedent_1.default) `
246
+ test('props parsing', () => {
247
+ expect(render(dedent `
98
248
  <Heading
99
249
  num={2}
100
250
  doublequote={"a \" string"}
@@ -130,14 +280,15 @@ function render(code) {
130
280
  "message": "Expressions in jsx props are not supported (...{ spread: true })",
131
281
  },
132
282
  ],
283
+ "html": "<h1><p>hi</p></h1>",
133
284
  "result": <React.Fragment>
134
285
  <Heading
135
286
  backTick="some \${expr} value"
136
287
  boolean={false}
137
- doublequote="a \\" string"
288
+ doublequote="a " string"
138
289
  null={null}
139
290
  num={2}
140
- quote="a \\" string"
291
+ quote="a " string"
141
292
  someJson={
142
293
  {
143
294
  "a": 1,
@@ -152,14 +303,15 @@ function render(code) {
152
303
  }
153
304
  `);
154
305
  });
155
- (0, vitest_1.test)('breaks', () => {
156
- (0, vitest_1.expect)(render((0, dedent_1.default) `
306
+ test('breaks', () => {
307
+ expect(render(dedent `
157
308
  To have a line break without a paragraph, you will need to use two trailing spaces.
158
309
  Note that this line is separate, but within the same paragraph.
159
310
  (This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
160
311
  `)).toMatchInlineSnapshot(`
161
312
  {
162
313
  "errors": [],
314
+ "html": "<p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p>",
163
315
  "result": <React.Fragment>
164
316
  <p>
165
317
  To have a line break without a paragraph, you will need to use two trailing spaces.
@@ -173,8 +325,8 @@ function render(code) {
173
325
  `);
174
326
  });
175
327
  // https://github.com/obedm503/markdown-kitchen-sink/blob/master/README.md?plain=1
176
- (0, vitest_1.test)('kitchen sink', () => {
177
- (0, vitest_1.expect)(render((0, dedent_1.default) `
328
+ test('kitchen sink', () => {
329
+ expect(render(dedent `
178
330
  # Markdown Kitchen Sink
179
331
  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.
180
332
 
@@ -200,7 +352,7 @@ function render(code) {
200
352
 
201
353
  ## Headers
202
354
 
203
- \`\`\`no-highlight
355
+
204
356
  # H1
205
357
  ## H2
206
358
  ### H3
@@ -215,7 +367,7 @@ function render(code) {
215
367
 
216
368
  Alt-H2
217
369
  ------
218
- \`\`\`
370
+
219
371
 
220
372
  # H1
221
373
  ## H2
@@ -592,6 +744,112 @@ function render(code) {
592
744
  "message": "Unsupported jsx component dl",
593
745
  },
594
746
  ],
747
+ "html": "<h1>Markdown Kitchen Sink</h1><p>This file is <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" title="">https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet</a> plus a few fixes and additions. Used by <a href="https://github.com/obedm503/bootmark" title="">obedm503/bootmark</a> to <a href="https://obedm503.github.io/bootmark/docs/markdown-cheatsheet.html" title="">demonstrate</a> it&#x27;s styling features.</p><p>This is intended as a quick reference and showcase. For more complete info, see <a href="http://daringfireball.net/projects/markdown/" title="">John Gruber&#x27;s original spec</a> and the <a href="http://github.github.com/github-flavored-markdown/" title="">Github-flavored Markdown info page</a>.</p><p>Note that there is also a <a href="./Markdown-Here-Cheatsheet" title="">Cheatsheet specific to Markdown Here</a> if that&#x27;s what you&#x27;re looking for. You can also check out <a href="./Other-Markdown-Tools" title="">more Markdown tools</a>.</p><h5>Table of Contents</h5><p><a href="#headers" title="">Headers</a><br/><a href="#emphasis" title="">Emphasis</a><br/><a href="#lists" title="">Lists</a><br/><a href="#links" title="">Links</a><br/><a href="#images" title="">Images</a><br/><a href="#code" title="">Code and Syntax Highlighting</a><br/><a href="#tables" title="">Tables</a><br/><a href="#blockquotes" title="">Blockquotes</a><br/><a href="#html" title="">Inline HTML</a><br/><a href="#hr" title="">Horizontal Rule</a><br/><a href="#lines" title="">Line Breaks</a><br/><a href="#videos" title="">YouTube Videos</a></p><a name="headers"></a><h2>Headers</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><h1>H1</h1><h2>H2</h2><h3>H3</h3><h4>H4</h4><h5>H5</h5><h6>H6</h6><p>Alternatively, for H1 and H2, an underline-ish style:</p><h1>Alt-H1</h1><h2>Alt-H2</h2><a name="emphasis"></a><h2>Emphasis</h2><pre><code>Emphasis, aka italics, with *asterisks* or _underscores_.
748
+
749
+ Strong emphasis, aka bold, with **asterisks** or __underscores__.
750
+
751
+ Combined emphasis with **asterisks and _underscores_**.
752
+
753
+ 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
754
+ 2. Another item
755
+ ⋅⋅* Unordered sub-list.
756
+ 1. Actual numbers don&#x27;t matter, just that it&#x27;s a number
757
+ ⋅⋅1. Ordered sub-list
758
+ 4. And another item.
759
+
760
+ ⋅⋅⋅You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).
761
+
762
+ ⋅⋅⋅To have a line break without a paragraph, you will need to use two trailing spaces.⋅⋅
763
+ ⋅⋅⋅Note that this line is separate, but within the same paragraph.⋅⋅
764
+ ⋅⋅⋅(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)
765
+
766
+ * Unordered list can use asterisks
767
+ - Or minuses
768
+ + Or pluses</code></pre><ol start="1"><li><p>First ordered list item</p></li><li><p>Another item</p></li></ol><ul><li><p>Unordered sub-list.</p></li></ul><ol start="1"><li><p>Actual numbers don&#x27;t matter, just that it&#x27;s a number</p></li><li><p>Ordered sub-list</p></li><li><p>And another item.</p><p>You can have properly indented paragraphs within list items. Notice the blank line above, and the leading spaces (at least one, but we&#x27;ll use three here to also align the raw Markdown).</p><p>To have a line break without a paragraph, you will need to use two trailing spaces.<br/>Note that this line is separate, but within the same paragraph.<br/>(This is contrary to the typical GFM line break behaviour, where trailing spaces are not required.)</p></li></ol><ul><li><p>Unordered list can use asterisks</p></li></ul><ul><li><p>Or minuses</p></li></ul><ul><li><p>Or pluses</p></li></ul><a name="links"></a><h2>Links</h2><p>There are two ways to create links.</p><pre><code>[I&#x27;m an inline-style link](https://www.google.com)
769
+
770
+ [I&#x27;m an inline-style link with title](https://www.google.com &quot;Google&#x27;s Homepage&quot;)
771
+
772
+ [I&#x27;m a reference-style link][Arbitrary case-insensitive reference text]
773
+
774
+ [I&#x27;m a relative reference to a repository file](../blob/master/LICENSE)
775
+
776
+ [You can use numbers for reference-style link definitions][1]
777
+
778
+ Or leave it empty and use the [link text itself].
779
+
780
+ URLs and URLs in angle brackets will automatically get turned into links.
781
+ http://www.example.com and sometimes
782
+ example.com (but not on Github, for example).
783
+
784
+ Some text to show that the reference links can follow later.
785
+
786
+ [arbitrary case-insensitive reference text]: https://www.mozilla.org
787
+ [1]: http://slashdot.org
788
+ [link text itself]: http://www.reddit.com</code></pre><p><a href="https://www.google.com" title="">I&#x27;m an inline-style link</a></p><p><a href="https://www.google.com" title="Google&#x27;s Homepage">I&#x27;m an inline-style link with title</a></p><p><a href="https://www.mozilla.org">I&#x27;m a reference-style link</a></p><p><a href="../blob/master/LICENSE" title="">I&#x27;m a relative reference to a repository file</a></p><p><a href="http://slashdot.org">You can use numbers for reference-style link definitions</a></p><p>Or leave it empty and use the <a href="http://www.reddit.com">link text itself</a>.</p><p>URLs and URLs in angle brackets will automatically get turned into links.
789
+ <a href="http://www.example.com" title="">http://www.example.com</a> and sometimes
790
+ example.com (but not on Github, for example).</p><p>Some text to show that the reference links can follow later.</p><a name="images"></a><h2>Images</h2><pre><code>Here&#x27;s our logo (hover to see the title text):
791
+
792
+ Inline-style:
793
+ ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 1&quot;)
794
+
795
+ Reference-style:
796
+ ![alt text][logo]
797
+
798
+ [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png &quot;Logo Title Text 2&quot;</code></pre><p>Here&#x27;s our logo (hover to see the title text):</p><p>Inline-style:
799
+ <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:
800
+ </p><a name="code"></a><h2>Code and Syntax Highlighting</h2><p>Code blocks are part of the Markdown spec, but syntax highlighting isn&#x27;t. However, many renderers -- like Github&#x27;s and <em>Markdown Here</em> -- support syntax highlighting. Which languages are supported and how those language names should be written will vary from renderer to renderer. <em>Markdown Here</em> supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the <a href="http://softwaremaniacs.org/media/soft/highlight/test.html" title="">highlight.js demo page</a>.</p><pre><code>Inline \`code\` has \`back-ticks around\` it.</code></pre><p>Inline <code>code</code> has <code>back-ticks around</code> it.</p><p>Blocks of code are either fenced by lines with three back-ticks <code>\`\`\`</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they&#x27;re easier and only they support syntax highlighting.</p><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
801
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
802
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting.
803
+ But let&#x27;s throw in a &amp;lt;b&amp;gt;tag&amp;lt;/b&amp;gt;.</code></pre><pre><code>var s = &quot;JavaScript syntax highlighting&quot;;
804
+ alert(s);</code></pre><pre><code>s = &quot;Python syntax highlighting&quot;
805
+ print s</code></pre><pre><code>No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
806
+ But let&#x27;s throw in a &lt;b&gt;tag&lt;/b&gt;.</code></pre><a name="tables"></a><h2>Tables</h2><p>Tables aren&#x27;t part of the core Markdown spec, but they are part of GFM and <em>Markdown Here</em> supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.</p><pre><code>Colons can be used to align columns.
807
+
808
+ | Tables | Are | Cool |
809
+ | ------------- |:-------------:| -----:|
810
+ | col 3 is | right-aligned | $1600 |
811
+ | col 2 is | centered | $12 |
812
+ | zebra stripes | are neat | $1 |
813
+
814
+ There must be at least 3 dashes separating each header cell.
815
+ The outer pipes (|) are optional, and you don&#x27;t need to make the
816
+ raw Markdown line up prettily. You can also use inline Markdown.
817
+
818
+ Markdown | Less | Pretty
819
+ --- | --- | ---
820
+ *Still* | \`renders\` | **nicely**
821
+ 1 | 2 | 3</code></pre><p>Colons can be used to align columns.</p><table><thead><tr class=""><td class="">Tables</td><td class="">Are</td><td class="">Cool</td></tr></thead><tbody><tr class=""><td class="">col 3 is</td><td class="">right-aligned</td><td class="">$1600</td></tr><tr class=""><td class="">col 2 is</td><td class="">centered</td><td class="">$12</td></tr><tr class=""><td class="">zebra stripes</td><td class="">are neat</td><td class="">$1</td></tr></tbody></table><p>There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don&#x27;t need to make the raw Markdown line up prettily. You can also use inline Markdown.</p><table><thead><tr class=""><td class="">Markdown</td><td class="">Less</td><td class="">Pretty</td></tr></thead><tbody><tr class=""><td class=""><em>Still</em></td><td class=""><code>renders</code></td><td class=""><strong>nicely</strong></td></tr><tr class=""><td class="">1</td><td class="">2</td><td class="">3</td></tr></tbody></table><a name="blockquotes"></a><h2>Blockquotes</h2><pre><code>&gt; Blockquotes are very handy in email to emulate reply text.
822
+ &gt; This line is part of the same quote.
823
+
824
+ Quote break.
825
+
826
+ &gt; This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. </code></pre><blockquote><p>Blockquotes are very handy in email to emulate reply text.
827
+ This line is part of the same quote.</p></blockquote><p>Quote break.</p><blockquote><p>This is a very long line that will still be quoted properly when it wraps. Oh boy let&#x27;s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p></blockquote><a name="html"></a><h2>Inline HTML</h2><p>You can also use raw HTML in your Markdown, and it&#x27;ll mostly work pretty well.</p><pre><code>&lt;dl&gt;
828
+ &lt;dt&gt;Definition list&lt;/dt&gt;
829
+ &lt;dd&gt;Is something people use sometimes.&lt;/dd&gt;
830
+
831
+ &lt;dt&gt;Markdown in HTML&lt;/dt&gt;
832
+ &lt;dd&gt;Does *not* work **very** well. Use HTML &lt;em&gt;tags&lt;/em&gt;.&lt;/dd&gt;
833
+ &lt;/dl&gt;</code></pre><a name="hr"></a><h2>Horizontal Rule</h2><pre><code>Three or more...
834
+
835
+ ---
836
+
837
+ Hyphens
838
+
839
+ ***
840
+
841
+ Asterisks
842
+
843
+ ___
844
+
845
+ Underscores</code></pre><p>Three or more...</p><hr/><p>Hyphens</p><hr/><p>Asterisks</p><hr/><p>Underscores</p><a name="lines"></a><h2>Line Breaks</h2><p>My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You&#x27;ll soon learn to get what you want. &quot;Markdown Toggle&quot; is your friend.</p><p>Here are some things to try out:</p><pre><code>Here&#x27;s a line for us to start with.
846
+
847
+ This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
848
+
849
+ This line is also a separate paragraph, but...
850
+ This line is only separated by a single newline, so it&#x27;s a separate line in the *same paragraph*.</code></pre><p>Here&#x27;s a line for us to start with.</p><p>This line is separated from the one above by two newlines, so it will be a <em>separate paragraph</em>.</p><p>This line is also begins a separate paragraph, but...<br/>This line is only separated by a single newline, so it&#x27;s a separate line in the <em>same paragraph</em>.</p><p>(Technical note: <em>Markdown Here</em> uses GFM line breaks, so there&#x27;s no need to use MD&#x27;s two-space line breaks.)</p><a name="videos"></a><h2>YouTube Videos</h2><p>They can&#x27;t be added directly but you can add an image with a link to the video like this:</p><pre><code>&lt;a href=&quot;http://www.youtube.com/watch?feature=player_embedded&amp;v=YOUTUBE_VIDEO_ID_HERE
851
+ &quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg&quot;
852
+ alt=&quot;IMAGE ALT TEXT HERE&quot; width=&quot;240&quot; height=&quot;180&quot; border=&quot;10&quot; /&gt;&lt;/a&gt;</code></pre><p>Or, in pure Markdown, but losing the image sizing and border:</p><pre><code>[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)</code></pre>",
595
853
  "result": <React.Fragment>
596
854
  <h1>
597
855
  Markdown Kitchen Sink
@@ -748,24 +1006,33 @@ function render(code) {
748
1006
  <h2>
749
1007
  Headers
750
1008
  </h2>
751
- <pre>
752
- <code>
753
- # H1
754
- ## H2
755
- ### H3
756
- #### H4
757
- ##### H5
758
- ###### H6
759
-
760
- Alternatively, for H1 and H2, an underline-ish style:
761
-
762
- Alt-H1
763
- ======
764
-
765
- Alt-H2
766
- ------
767
- </code>
768
- </pre>
1009
+ <h1>
1010
+ H1
1011
+ </h1>
1012
+ <h2>
1013
+ H2
1014
+ </h2>
1015
+ <h3>
1016
+ H3
1017
+ </h3>
1018
+ <h4>
1019
+ H4
1020
+ </h4>
1021
+ <h5>
1022
+ H5
1023
+ </h5>
1024
+ <h6>
1025
+ H6
1026
+ </h6>
1027
+ <p>
1028
+ Alternatively, for H1 and H2, an underline-ish style:
1029
+ </p>
1030
+ <h1>
1031
+ Alt-H1
1032
+ </h1>
1033
+ <h2>
1034
+ Alt-H2
1035
+ </h2>
769
1036
  <h1>
770
1037
  H1
771
1038
  </h1>
@@ -1199,150 +1466,158 @@ function render(code) {
1199
1466
  Colons can be used to align columns.
1200
1467
  </p>
1201
1468
  <table>
1202
- <tr
1203
- className=""
1204
- >
1205
- <td
1206
- className=""
1207
- >
1208
- Tables
1209
- </td>
1210
- <td
1211
- className=""
1212
- >
1213
- Are
1214
- </td>
1215
- <td
1216
- className=""
1217
- >
1218
- Cool
1219
- </td>
1220
- </tr>
1221
- <tr
1222
- className=""
1223
- >
1224
- <td
1225
- className=""
1226
- >
1227
- col 3 is
1228
- </td>
1229
- <td
1469
+ <thead>
1470
+ <tr
1230
1471
  className=""
1231
1472
  >
1232
- right-aligned
1233
- </td>
1234
- <td
1473
+ <td
1474
+ className=""
1475
+ >
1476
+ Tables
1477
+ </td>
1478
+ <td
1479
+ className=""
1480
+ >
1481
+ Are
1482
+ </td>
1483
+ <td
1484
+ className=""
1485
+ >
1486
+ Cool
1487
+ </td>
1488
+ </tr>
1489
+ </thead>
1490
+ <tbody>
1491
+ <tr
1235
1492
  className=""
1236
1493
  >
1237
- $1600
1238
- </td>
1239
- </tr>
1240
- <tr
1241
- className=""
1242
- >
1243
- <td
1244
- className=""
1245
- >
1246
- col 2 is
1247
- </td>
1248
- <td
1494
+ <td
1495
+ className=""
1496
+ >
1497
+ col 3 is
1498
+ </td>
1499
+ <td
1500
+ className=""
1501
+ >
1502
+ right-aligned
1503
+ </td>
1504
+ <td
1505
+ className=""
1506
+ >
1507
+ $1600
1508
+ </td>
1509
+ </tr>
1510
+ <tr
1249
1511
  className=""
1250
1512
  >
1251
- centered
1252
- </td>
1253
- <td
1513
+ <td
1514
+ className=""
1515
+ >
1516
+ col 2 is
1517
+ </td>
1518
+ <td
1519
+ className=""
1520
+ >
1521
+ centered
1522
+ </td>
1523
+ <td
1524
+ className=""
1525
+ >
1526
+ $12
1527
+ </td>
1528
+ </tr>
1529
+ <tr
1254
1530
  className=""
1255
1531
  >
1256
- $12
1257
- </td>
1258
- </tr>
1259
- <tr
1260
- className=""
1261
- >
1262
- <td
1263
- className=""
1264
- >
1265
- zebra stripes
1266
- </td>
1267
- <td
1268
- className=""
1269
- >
1270
- are neat
1271
- </td>
1272
- <td
1273
- className=""
1274
- >
1275
- $1
1276
- </td>
1277
- </tr>
1532
+ <td
1533
+ className=""
1534
+ >
1535
+ zebra stripes
1536
+ </td>
1537
+ <td
1538
+ className=""
1539
+ >
1540
+ are neat
1541
+ </td>
1542
+ <td
1543
+ className=""
1544
+ >
1545
+ $1
1546
+ </td>
1547
+ </tr>
1548
+ </tbody>
1278
1549
  </table>
1279
1550
  <p>
1280
1551
  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.
1281
1552
  </p>
1282
1553
  <table>
1283
- <tr
1284
- className=""
1285
- >
1286
- <td
1287
- className=""
1288
- >
1289
- Markdown
1290
- </td>
1291
- <td
1292
- className=""
1293
- >
1294
- Less
1295
- </td>
1296
- <td
1297
- className=""
1298
- >
1299
- Pretty
1300
- </td>
1301
- </tr>
1302
- <tr
1303
- className=""
1304
- >
1305
- <td
1306
- className=""
1307
- >
1308
- <em>
1309
- Still
1310
- </em>
1311
- </td>
1312
- <td
1313
- className=""
1314
- >
1315
- <code>
1316
- renders
1317
- </code>
1318
- </td>
1319
- <td
1320
- className=""
1321
- >
1322
- <strong>
1323
- nicely
1324
- </strong>
1325
- </td>
1326
- </tr>
1327
- <tr
1328
- className=""
1329
- >
1330
- <td
1554
+ <thead>
1555
+ <tr
1331
1556
  className=""
1332
1557
  >
1333
- 1
1334
- </td>
1335
- <td
1558
+ <td
1559
+ className=""
1560
+ >
1561
+ Markdown
1562
+ </td>
1563
+ <td
1564
+ className=""
1565
+ >
1566
+ Less
1567
+ </td>
1568
+ <td
1569
+ className=""
1570
+ >
1571
+ Pretty
1572
+ </td>
1573
+ </tr>
1574
+ </thead>
1575
+ <tbody>
1576
+ <tr
1336
1577
  className=""
1337
1578
  >
1338
- 2
1339
- </td>
1340
- <td
1579
+ <td
1580
+ className=""
1581
+ >
1582
+ <em>
1583
+ Still
1584
+ </em>
1585
+ </td>
1586
+ <td
1587
+ className=""
1588
+ >
1589
+ <code>
1590
+ renders
1591
+ </code>
1592
+ </td>
1593
+ <td
1594
+ className=""
1595
+ >
1596
+ <strong>
1597
+ nicely
1598
+ </strong>
1599
+ </td>
1600
+ </tr>
1601
+ <tr
1341
1602
  className=""
1342
1603
  >
1343
- 3
1344
- </td>
1345
- </tr>
1604
+ <td
1605
+ className=""
1606
+ >
1607
+ 1
1608
+ </td>
1609
+ <td
1610
+ className=""
1611
+ >
1612
+ 2
1613
+ </td>
1614
+ <td
1615
+ className=""
1616
+ >
1617
+ 3
1618
+ </td>
1619
+ </tr>
1620
+ </tbody>
1346
1621
  </table>
1347
1622
  <a
1348
1623
  name="blockquotes"