You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The baseline for MDN Markdown is GitHub-Flavored Markdown (GFM): <ahref="https://github.github.com/gfm/">https://github.github.com/gfm/</a>. This means that for anything not otherwise specified in this page, you can refer to the GFM specification. GFM in turn is a superset of CommonMark (<ahref="https://spec.commonmark.org/">http://spec.commonmark.org/</a>).</p>
24
24
25
-
<p>GFM and CommonMark describe some extensions to <ahref="https://daringfireball.net/projects/markdown/syntax">the original Markdown description</a>). We'll highlight two that are going to be important to us.
26
-
27
-
<h3>Code fences and info strings</h3>
25
+
<h2>Example code blocks</h2>
28
26
29
27
<p>In GFM and CommonMark, authors can use "code fences" to demarcate <code><pre></code> blocks. The opening code fence may be followed by some text that is called the "info string". From the spec:</p>
30
28
@@ -40,39 +38,7 @@ <h3>Code fences and info strings</h3>
40
38
```
41
39
</pre>
42
40
43
-
<h3>Tables</h3>
44
-
45
-
<p>In GFM (but not CommonMark) there is a syntax for tables: <ahref="https://github.github.com/gfm/#tables-extension-">https://github.github.com/gfm/#tables-extension-</a>. We will make use of this but it should be noted that this syntax imposes limitations on the kinds of tables we can write, so in many cases this syntax will not be appropriate and we will need alternative ways of authoring tables.</p>
46
-
47
-
<p>In particular:</p>
48
-
49
-
<ul>
50
-
<li>GFM tables must have a header row.</li>
51
-
<li>GFM tables may not have a header column.</li>
52
-
<li>GFM won't parse GFM block elements in table cells.</li>
53
-
</ul>
54
-
55
-
<p>This last point means that if you write:</p>
56
-
57
-
<pre>
58
-
--------------------------------------
59
-
| i'm a test | yes i am |
60
-
|----------------|-------------------|
61
-
| `inline` is ok | * lists aren't |
62
-
--------------------------------------
63
-
</pre>
64
-
65
-
<p>...then the attempt to write a list in the bottom-right cell will just generate <code><td>* lists aren't</td></code> in the output.</p>
66
-
67
-
68
-
<h2>Extensions to GFM</h2>
69
-
70
-
<p>In this section we'll outline ways in which writers will be able to go beyond the syntax defined in the GFM spec.</p>
71
-
72
-
73
-
<h3>Example code blocks</h3>
74
-
75
-
Writers will use code fences for example code blocks. They must specify the language of the code sample using the first word of the info string, and this will be used to provide syntax highlighting for the block. The following words will be supported:
41
+
In MDN, writers will use code fences for example code blocks. They must specify the language of the code sample using the first word of the info string, and this will be used to provide syntax highlighting for the block. The following words will be supported:
76
42
77
43
<ul>
78
44
<li><code>bash</code></li>
@@ -113,7 +79,7 @@ <h3>Example code blocks</h3>
113
79
```
114
80
</pre>
115
81
116
-
<h3>Notes, warnings, and callouts</h3>
82
+
<h2>Notes, warnings, and callouts</h2>
117
83
118
84
<p>Sometimes writers want to call special attention to some piece of content. To do this, they will use a GFM blockquote with a special first paragraph. There are three types of these: notes, warnings, and callouts.</p>
119
85
@@ -258,17 +224,55 @@ <h5>Note containing a code block</h5>
258
224
<p>Like that.</p>
259
225
</div>
260
226
261
-
<h3>Definition lists</h3>
227
+
<h2>Definition lists</h2>
262
228
263
-
<h3>Tables</h3>
229
+
<h2>Tables</h2>
230
+
231
+
<p>In GFM (but not CommonMark) there is a syntax for tables: <ahref="https://github.github.com/gfm/#tables-extension-">https://github.github.com/gfm/#tables-extension-</a>. We will make use of this but the GFM syntax only supports a subset of the features available in HTML.</p>
232
+
233
+
<p>So the general principle here is: authors should use the GFM Markdown syntax when they can, and fall back to raw HTML when they have to.</p>
234
+
235
+
<p>The main limitations of GFM table syntax are:</p>
236
+
237
+
<ul>
238
+
<li>GFM tables must have a header row.</li>
239
+
<li>GFM tables may not have a header column.</li>
240
+
<li>GFM won't parse GFM block elements in table cells. For example, you can't have a list in a table cell.</li>
241
+
<li>GFM doesn't support any table elements beyond <code><table></code>, <code><tr></code>, and <code><th></code>, and <code><td></code>.</li>
242
+
<li>GFM doesn't support any table element attributes like <code>colspan</code>, <code>rowspan</code>, or <code>scope</code>.</li>
243
+
</ul>
244
+
245
+
<p>If an author needs to use any of the unsupported features, they should write the table in HTML.</p>
246
+
247
+
<p>We don't recommend the general use of <code><caption></code> elements on tables, since that would also rule out the GFM syntax.</p>
248
+
249
+
<p>In GFM table syntax, authors can omit leading and trailing pipes for rows. MDN authors must include these pipes, for the sake of readability.</p>
250
+
251
+
<p>That is, MDN authors must use this style:</p>
252
+
253
+
<pre>
254
+
| Heading 1 | Heading 2 | Heading 3 |
255
+
|-----------|-----------|-----------|
256
+
| cell 1 | cell 2 | cell 3 |
257
+
| cell 4 | cell 5 | cell 6 |
258
+
</pre>
259
+
260
+
<p>and not this style:</p>
261
+
262
+
<pre>
263
+
Heading 1 | Heading 2 | Heading 3
264
+
--- | --- | ---
265
+
cell 1 | cell 2 | cell 3
266
+
cell 4 | cell 5 | cell 6
267
+
</pre>
264
268
265
-
<h3>Heading IDs</h3>
269
+
<h2>Heading IDs</h2>
266
270
267
-
<h3>Live samples</h3>
271
+
<h2>Live samples</h2>
268
272
269
-
<h3>Inline styles</h3>
273
+
<h2>Inline styles</h2>
270
274
271
-
<h3>KumaScript</h3>
275
+
<h2>KumaScript</h2>
272
276
273
277
<p>Writers will be able to include KumaScript macro calls in prose content:</p>
0 commit comments