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
Copy file name to clipboardExpand all lines: docs/extensions/extra.txt
+96Lines changed: 96 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,3 +41,99 @@ therefore, not part of Python-Markdown Extra. If you really would
41
41
like Extra to include additional extensions, we suggest creating
42
42
your own clone of Extra under a different name
43
43
(see the [Extension API](api.html)).
44
+
45
+
Markdown Inside HTML Blocks
46
+
---------------------------
47
+
48
+
Unlike the other Extra features, this feature is build into the markdown core and is turned on when `extra` is enabled.
49
+
50
+
The content of any block-level element can be Markdown-formatted simply by adding a `markdown` attribute to the opening tag. The markdown attribute will be stripped from the output, but all other attributes will be preserved.
51
+
52
+
If the markdown value is set to `1` (recommended) or any value other than `span` or `block`, the default behavior will be executed: `p`,`h[1-6]`,`li`,`dd`,`dt`,`td`,`th`,`legend`, and `address` elements skip block parsing while others do not. If the default is overrident by a value of `span`, *block parsing will be skipped* regardless of tag. If the default is overriden by a value of `block`, *block parsing will occur* regardless of tag.
53
+
54
+
*An opening tag with the markdown attribute must start immediately on a line following a blank line.*
55
+
56
+
#### Simple Example:
57
+
```
58
+
This is *true* markdown text.
59
+
60
+
<div markdown="1">
61
+
This is *true* markdown text.
62
+
</div>
63
+
```
64
+
#### Result:
65
+
```
66
+
<p>This is <em>true</em> markdown text.</p>
67
+
<div>
68
+
<p>This is <em>true</em> markdown text.</p>
69
+
</div>
70
+
```
71
+
72
+
### Nested Markdown Inside HTML BLocks
73
+
Nested elements are more sensitive and must be used cautiously. Violation of the following will lead to unexpected behavior or unhandled exceptions.
74
+
* Only block mode elements may have further elements nested within them.
75
+
* The closing tag of inner elements must be followed by a blank line.
76
+
* More than one level of nesting is not supported (i.e., elements nested within elements nested within elements). This feature is not an alternative to templating.
77
+
78
+
#### Complex Example:
79
+
```
80
+
<div markdown="1" name="Example">
81
+
82
+
The text of the `Example` element.
83
+
84
+
<div markdown="1" name="DefaultBlockMode">
85
+
This text gets wrapped in `p` tags.
86
+
</div>
87
+
88
+
The tail of the `DefaultBlockMode` subelement.
89
+
90
+
<p markdown="1" name="DefaultSpanMode">
91
+
This text *is not* wrapped in additional `p` tags.
92
+
</p>
93
+
94
+
The tail of the `DefaultSpanMode` subelement.
95
+
96
+
<div markdown="span" name="SpanModeOverride">
97
+
This `div` block is not wrapped in paragraph tags.
98
+
Note: Subelements are not required to have tail text.
99
+
</div>
100
+
101
+
<p markdown="block" name="BlockModeOverride">
102
+
This `p` block *is* foolishly wrapped in further paragraph tags.
103
+
</p>
104
+
105
+
The tail of the `BlockModeOverride` subelement.
106
+
107
+
<div name="RawHtml">
108
+
Raw html blocks may also be nested.
109
+
</div>
110
+
111
+
</div>
112
+
113
+
This text is after the markdown in html.
114
+
```
115
+
#### Result:
116
+
```
117
+
<div name="Example">
118
+
<p>The text of the <code>Example</code> element.</p>
119
+
<div name="DefaultBlockMode">
120
+
<p>This text gets wrapped in <code>p</code> tags.</p>
121
+
</div>
122
+
<p>The tail of the <code>DefaultBlockMode</code> subelement.</p>
123
+
<p name="DefaultSpanMode">
124
+
This text <em>is not</em> wrapped in additional <code>p</code> tags.</p>
125
+
<p>The tail of the <code>DefaultSpanMode</code> subelement.</p>
126
+
<div name="SpanModeOverride">
127
+
This <code>div</code> block is not wrapped in paragraph tags.
128
+
Note: Subelements are not required to have tail text.</div>
129
+
<p name="BlockModeOverride">
130
+
<p>This <code>p</code> block <em>is</em> foolishly wrapped in further paragraph tags.</p>
131
+
</p>
132
+
<p>The tail of the <code>BlockModeOverride</code> subelement.</p>
0 commit comments