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
Add new helper functions and add logic for script type tags in HTML ext
- Add `is_raw`, `is_block`, and `html_escape` helper functions
- HTML extension now has the concept of `html` tags which will store the
content as non HTML escaped content. `script` and `style` tags will
be auto detected for this mode, but this mode can be manually set
now via the `markdown` option as well.
- In the HTML extension, to protect raw and raw HTML content from the
Treprocessors, content will be placed in the stash on `on_end`.
Copy file name to clipboardExpand all lines: docs/src/markdown/extensions/blocks/plugins/html.md
+26-16
Original file line number
Diff line number
Diff line change
@@ -56,14 +56,35 @@ some *markdown* content
56
56
57
57
By default HTML blocks will automatically have the content rendering determined from tag name, so `div` blocks will be
58
58
treated as block elements, `span` will be treated as inline elements, and things like `pre` will treat the content as
59
-
raw text that should not be processed by Markdown further. With that said, there may be cases where an HTML element
60
-
isn't properly recognized yet, or the user simply wants to control how the element processes its content, in these
61
-
cases, the `markdown` option can be used to specify how Markdown content is handled.
59
+
raw text that needs HTML escaping, and things like `script` will be treated as raw content does not need HTML escaping.
60
+
With that said, there may be cases where an HTML element isn't properly recognized yet, or the user simply wants to
61
+
control how the element processes its content, in these cases, the `markdown` option can be used to specify how Markdown
62
+
content is handled.
63
+
64
+
Markdown\ Modes | Description
65
+
--------------- | -----------
66
+
`block` | Parsed block content will be handled by the Markdown parser as content under a block element.
67
+
`inline` | Parsed block content will be handled by the Markdown parser as content under an inline element.
68
+
`raw` | Parsed block content will be preserved. No additional Markdown parsing will be applied. Content will be HTML escaped to preserve the content as is.
69
+
`auto` | Depending on whether the wrapping parent is a block element, inline element, or something like a code element, Blocks will choose the best approach for the content. Decision is made based on the element returned by the [`on_add` event](#on_add-event).
70
+
`html` | Like `raw`, content will be preserved, but the content will _not_ be HTML escaped and will be passed through as unmodified HTML. Any required sanitizing should be provided by the user post Markdown processing.
71
+
72
+
/// tip | Raw and HTML Mode
73
+
When using _raw_ tags or forcing _raw_ mode with `markdown: raw` (HTML escaped) or `markdown: html` (no HTML escaping),
74
+
code must be indented. This is because Python Markdown will look for and process raw HTML in non indented blocks. The
75
+
only avoid this is to use indented code blocks. If content is not indented, the content may be missing at the end.
76
+
77
+
Recognized raw block tags: `canvas`, `math`, `option`, `pre`, and `textarea`.
78
+
79
+
Recognized raw HTML tags: `script` and `style`.
80
+
81
+
Also, make sure to have a new line before indented content so it is not recognized as an attempt to specify YAML
82
+
options.
83
+
///
62
84
63
85
In the following example we force `pre` to handle content as Markdown block content instead of the usual raw content
64
86
default.
65
87
66
-
67
88
```text title="Pre as Block"
68
89
/// html | pre
69
90
@@ -90,20 +111,9 @@ some *markdown* content
90
111
////
91
112
///
92
113
93
-
/// tip | Raw Mode
94
-
When using _raw_ tags or forcing _raw_ mode with `markdown: raw`, it is advised to indent the code. This is because
95
-
Python Markdown will look for and process raw HTML in non indented blocks. The only avoid this is to use indented
96
-
blocks. Content will automatically be dedented by the expected tab length.
97
-
98
-
Recognized raw block tags: `canvas`, `math`, `option`, `pre`, `script`, `style`, and `textarea`.
99
-
100
-
Also, make sure to have a new line before indented content so it is not recognized as an attempt to specify YAML
101
-
options.
102
-
///
103
-
104
114
## Per Block Options
105
115
106
116
Options | Type | Descriptions
107
117
------------ | ---------- | ------------
108
-
`markdown` | string | String value to control how Markdown content is processed. Valid options are: `auto`, `block`, `inline`, and `raw`.
118
+
`markdown` | string | String value to control how Markdown content is processed. Valid options are: `auto`, `block`, `inline`, `html`, and `raw`.
109
119
`attrs` | string | A string that defines attributes for the outer, wrapper element.
0 commit comments