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
Markdown is a subset of HTML; anything that cannot be expressed in Markdown can always be expressed directly with raw HTML.
7
-
HTML is much less readable than plain Markdown, so you should only use it as a last resort.
6
+
Markdown is a subset of HTML; anything that cannot be expressed in Markdown can always be expressed directly with raw HTML. HTML is much less readable than plain Markdown, so you should only use it as a last resort.
8
7
9
-
Use blank lines to separate block-level HTML elements, like `<div>`, `<table>`, `<p>`, etc., from the surrounding content.
10
-
11
-
## Markdown in HTML
12
-
13
-
By default, Markdown ignores any content within a raw HTML block-level element. However, you can enable parsing of the content inside a raw HTML block-level element as Markdown by including a `markdown` attribute on the opening tag. The markdown attribute will be stripped from the output, while all other attributes will be preserved.
14
-
15
-
The markdown attribute can be assigned one of three values: "1", "block", or "span".
16
-
17
-
### `markdown="1"`
18
-
19
-
When the markdown attribute is set to "1", the parser will use the default behavior for that specific tag.
20
-
21
-
The following tags have block behavior by default: `article`, `aside`, `blockquote`, `body`, `colgroup`, `details`, `div`, `dl`, `fieldset`, `figcaption`, `figure`, `footer`, `form`, `group`, `header`, `hgroup`, `hr`, `iframe`, `main`, `map`, `menu`, `nav`, `noscript`, `object`, `ol`, `output`, `progress`, `section`, `table`, `tbody`, `tfoot`, `thead`, `tr`, `ul`, and `video`.
22
-
23
-
/// example | Default "block" markdown parsing
24
-
25
-
```md
26
-
<divmarkdown="1">
27
-
This is a *Markdown* Paragraph.
28
-
</div>
29
-
```
30
-
31
-
renders as:
32
-
33
-
```html
34
-
<div>
35
-
<p>This is a <em>Markdown</em> Paragraph.</p>
36
-
</div>
37
-
```
8
+
The content inside HTML tags is treated differently depending if the HTML tags are inline or blocks.
38
9
39
-
///
10
+
## Inline syntax
40
11
41
-
The following tags have span behavior by default: `address`, `dd`, `dt`, `h[1-6]`, `legend`, `li`, `p`, `td`, and `th`.
42
-
43
-
/// example | Default "span" markdown parsing
12
+
Only inline syntax, such as links, strong, emphasis, etc., is rendered as regular Markdown code. For example:
44
13
45
14
```md
46
-
<pmarkdown="1">
47
-
This is not a *Markdown* Paragraph.
48
-
</p>
15
+
So <spanclass="special">**many**_books_</span>. So little time.
49
16
```
50
17
51
18
renders as:
52
19
53
20
```html
54
-
<p>
55
-
This is not a <em>Markdown</em> Paragraph.
56
-
</p>
21
+
<p>So <spanclass="special"><strong>>many<strong>
22
+
<em>books</em></span>. So little time.<p>
57
23
```
58
24
59
-
///
60
-
61
-
Note how an implicit paragraph was added in the first example but not in the second.
62
-
63
-
### `markdown="block"`
64
-
65
-
When the markdown attribute is set to "block", the parser will force block behavior on the contents of the element, as long as it is one of the block or span tags.
25
+
## Block syntax
66
26
67
-
The content of a block element is parsed into block-level content. In other words, the text is rendered as paragraphs, headers, lists, blockquotes, etc. Any inline syntax within those elements is processed as well.
68
-
69
-
:::: div example
70
-
**Example: Forced "block" markdown parsing**
27
+
For any block-level element everything inside that element is ignored, including child elements. For example:
71
28
72
29
```md
73
-
<sectionmarkdown="block">
74
-
# A header.
75
-
76
-
A *Markdown* paragraph.
77
-
78
-
* A list item.
79
-
* A second list item.
80
-
81
-
</section>
82
-
```
83
-
84
-
renders as:
85
-
86
-
```html
87
-
<section>
88
-
<h1>A header.</h1>
89
-
<p>A <em>Markdown</em> paragraph.</p>
90
-
<ul>
91
-
<li>A list item.</li>
92
-
<li>A second list item.</li>
93
-
</ul>
94
-
</section>
95
-
```
96
-
97
-
::::
98
-
99
-
::: warning
100
-
Forcing elements to be parsed as `block` elements when they are not by default could result in invalid HTML.
101
-
102
-
For example, one could force a `<p>` element to be nested within another `<p>` element. In most cases, it is
103
-
recommended to use the default behavior of `markdown="1"`.
104
-
:::
105
-
106
-
107
-
### `markdown="span"`
108
-
109
-
When the markdown attribute is set to "span", the parser will force span behavior on the contents of the element, as long as it is one of the block or span tags.
110
-
111
-
The content of a span element is not parsed into block-level content. In other words, the content will not be rendered as paragraphs, headers, etc. Only inline syntax will be rendered, such as links, strong, emphasis, etc.
112
-
113
-
:::: div example
114
-
**Example: Forced "span" markdown parsing**
115
-
116
-
```md
117
-
<divmarkdown="span">
30
+
<div>
118
31
# *Not* a header
119
32
</div>
120
33
```
@@ -127,53 +40,30 @@ renders as:
127
40
</div>
128
41
```
129
42
130
-
::::
131
-
132
-
133
-
## Nesting
43
+
Use blank lines to separate block-level HTML elements, like `<div>`, `<table>`, `<p>`, etc., from the surrounding content.
134
44
135
-
When nesting multiple levels of raw HTML elements, a markdown attribute must be defined for each block-level element. For any block-level element that does not have a markdown attribute, everything inside that element is ignored, including child elements with markdown attributes.
45
+
### Indentation
136
46
137
-
:::: div example
138
-
**Example: Markdown in nested HTML
47
+
Block-level HTML elements must have no indentation at all. Unless they are inside a list elementy, in which case must be indented only the same as the list text.
0 commit comments