markdown.postprocessors
§
Post-processors run on the text of the entire document after is has been serialized into a string. Postprocessors should be used to work with the text just before output. Usually, they are used add back sections that were extracted in a preprocessor, fix up outgoing encodings, or wrap the whole document.
Classes:
-
Postprocessor–Postprocessors are run after the ElementTree it converted back into text.
-
RawHtmlPostprocessor–Restore raw html to the document.
-
AndSubstitutePostprocessor–Restore valid entities
-
UnescapePostprocessor–Restore escaped chars.
Functions:
-
build_postprocessors–Build the default postprocessors for Markdown.
markdown.postprocessors.build_postprocessors(md: Markdown, **kwargs: Any) -> util.Registry[Postprocessor]
§
Build the default postprocessors for Markdown.
Return a Registry instance which contains the following collection of classes with their assigned names and priorities.
| Class Instance | Name | Priority |
|---|---|---|
RawHtmlPostprocessor |
raw_html |
30 |
AndSubstitutePostprocessor |
amp_substitute |
20 |
markdown.postprocessors.Postprocessor(md: Markdown | None = None)
§
Bases: Processor
Postprocessors are run after the ElementTree it converted back into text.
Each Postprocessor implements a run method that takes a pointer to a
text string, modifies it as necessary and returns a text string.
Postprocessors must extend Postprocessor.
Methods:
-
run–Subclasses of
Postprocessorshould implement arunmethod, which
markdown.postprocessors.Postprocessor.run(text: str) -> str
§
Subclasses of Postprocessor should implement a run method, which
takes the html document as a single text string and returns a
(possibly modified) string.
markdown.postprocessors.RawHtmlPostprocessor(md: Markdown | None = None)
§
Bases: Postprocessor
Restore raw html to the document.
Methods:
-
run–Iterate over html stash and restore html.
-
isblocklevel–Check is block of HTML is block-level.
-
stash_to_string–Convert a stashed object to a string.
markdown.postprocessors.RawHtmlPostprocessor.run(text: str) -> str
§
Iterate over html stash and restore html.
markdown.postprocessors.RawHtmlPostprocessor.isblocklevel(html: str) -> bool
§
Check is block of HTML is block-level.
markdown.postprocessors.RawHtmlPostprocessor.stash_to_string(text: str) -> str
§
Convert a stashed object to a string.
markdown.postprocessors.AndSubstitutePostprocessor(md: Markdown | None = None)
§
markdown.postprocessors.UnescapePostprocessor(md: Markdown | None = None)
deprecated
§
Bases: Postprocessor
Deprecated
This class is deprecated and will be removed in the future; use UnescapeTreeprocessor instead.
Restore escaped chars.