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
The `on_markdown` event is used to declare how the content of the block should be handled by the Markdown parser. A
276
-
string with one of the following values _must_ be returned. All content is stored under the [etree][etree] element
277
-
returned via the [`on_add` event](#on_add-event), regardless of what mode is returned.
276
+
string with one of the following values _must_ be returned. All content is treated as HTML content and is stored under
277
+
the [etree][etree] element returned via the [`on_add` event](#on_add-event).
278
+
279
+
Only during the [`on_end` event](#on_end-event) will all the content be fully accumulated and processed by relevant
280
+
block processors, and only during the [`on_inline_end` event](#on_inline_end-event) will both block and inline
281
+
processing be completed.
278
282
279
283
Result\ Value | Description
280
284
------------- | -----------
281
285
`block` | Parsed block content will be handled by the Markdown parser as content under a block element.
282
286
`inline` | Parsed block content will be handled by the Markdown parser as content under an inline element.
283
-
`raw` | Parsed block content will be preserved as is. No additional Markdown parsing will be applied.
287
+
`raw` | Parsed block content will be preserved as is. No additional Markdown parsing will be applied. Content is expected to be indented and should be documented as such.
284
288
`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).
285
289
286
-
Only during the [`on_end` event](#on_end-event) will all the content be fully accumulated and processed by relevant
287
-
block processors, and only during the [`on_inline_end` event](#on_inline_end-event) will both block and inline
288
-
processing be completed.
289
-
290
-
When using `raw` mode, all text will be accumulated and fully available during the [`on_end` event](#on_end-event).
291
-
Content is accessible under the element returned by the [`on_add` event](#on_add-event) and can be accessed via
292
-
`element.text`. Text content is stored as a Python Markdown [`AtomicString`][atomic]. If desired, the content can be
293
-
stored in the [HTML stash][stash] during the [`on_add` event](#on_add-event)to ensure it makes it through any and all
294
-
Treeprocessors after inline handling. Additionally, when storing in the stash, the developer can HTML escape the content
295
-
to have the text present as literal or store without HTML escaping to present as an altered HTML content.
296
-
297
-
A `raw` block expects the content to be an indented code block as this is necessary to avoid some Python Markdown's
298
-
internal HTML parser. Content will not have the extra indentation in the final output.
299
-
300
-
It should be noted that `raw` mode cannot prevent transformations that are applied during Python Markdown's preprocessor
301
-
steps. Blocks will attempt to revert any placeholders within the content that are currently found in the HTML stash.
290
+
When using `raw` mode, all text will be accumulated under the specified element as an [`AtomicString`][atomic]. If
291
+
nothing is done with the content during the [`on_end` event](#on_end-event), all the content will be HTML escaped by the
292
+
Python Markdown parser. If desired, the content can be placed into the Python Markdown [HTML stash][stash] which will
293
+
protect it from any other rouge Treeprocessors. Keep in mind, if the content is stashed HTML escaping will not be
294
+
applied automatically, so HTML escape if it is required.
295
+
296
+
/// warning | Indent Raw Content
297
+
Because Python Markdown implements HTML processing as a preprocessor, content for a `raw` block must be indented 4
298
+
spaces to avoid the HTML processing step. The content will not be indented when it reaches the [`on_end` event](#on_end-event).
299
+
Failure to indent will still allow the code to be processed, but it may not process as expected. An extension that uses
300
+
`raw` should make clear that this is a requirement to avoid unexpected results.
0 commit comments