class documentation

class Markdown: (source)

View In Hierarchy

Convert Markdown to HTML.

Method __init__ Creates a new Markdown instance.
Method build_extension Build extension from a string name, then return an instance.
Method build_parser Build the parser from the various parts.
Method convert Convert markdown to serialized XHTML or HTML.
Method convertFile Converts a markdown file and returns the HTML as a unicode string.
Method is_block_level Check if the tag is a block level HTML tag.
Method registerExtension This gets called by the extension
Method registerExtensions Register extensions with this instance of Markdown.
Method reset Resets all state variables so that we can start with a new text.
Method set_output_format Set the output format for the class instance.
Class Variable doc_tag Undocumented
Class Variable output_formats Undocumented
Instance Variable block_level_elements Undocumented
Instance Variable docType Undocumented
Instance Variable ESCAPED_CHARS Undocumented
Instance Variable htmlStash Undocumented
Instance Variable inlinePatterns Undocumented
Instance Variable lines Undocumented
Instance Variable output_format Undocumented
Instance Variable parser Undocumented
Instance Variable postprocessors Undocumented
Instance Variable preprocessors Undocumented
Instance Variable references Undocumented
Instance Variable registeredExtensions Undocumented
Instance Variable serializer Undocumented
Instance Variable stripTopLevelTags Undocumented
Instance Variable tab_length Undocumented
Instance Variable treeprocessors Undocumented
def __init__(self, **kwargs): (source)

Creates a new Markdown instance. Keyword arguments: * extensions: A list of extensions. If an item is an instance of a subclass of `markdown.extension.Extension`, the instance will be used as-is. If an item is of type string, first an entry point will be loaded. If that fails, the string is assumed to use Python dot notation (`path.to.module:ClassName`) to load a markdown.Extension subclass. If no class is specified, then a `makeExtension` function is called within the specified module. * extension_configs: Configuration settings for extensions. * output_format: Format of output. Supported formats are: * "xhtml": Outputs XHTML style tags. Default. * "html": Outputs HTML style tags. * tab_length: Length of tabs in the source. Default: 4

def build_extension(self, ext_name, configs): (source)

Build extension from a string name, then return an instance. First attempt to load an entry point. The string name must be registered as an entry point in the `markdown.extensions` group which points to a subclass of the `markdown.extensions.Extension` class. If multiple distributions have registered the same name, the first one found is returned. If no entry point is found, assume dot notation (`path.to.module:ClassName`). Load the specified class and return an instance. If no class is specified, import the module and call a `makeExtension` function and return the Extension instance returned by that function.

def build_parser(self): (source)

Build the parser from the various parts.

def convert(self, source): (source)

Convert markdown to serialized XHTML or HTML. Keyword arguments: * source: Source text as a Unicode string. Markdown processing takes place in five steps: 1. A bunch of "preprocessors" munge the input text. 2. BlockParser() parses the high-level structural elements of the pre-processed text into an ElementTree. 3. A bunch of "treeprocessors" are run against the ElementTree. One such treeprocessor runs InlinePatterns against the ElementTree, detecting inline markup. 4. Some post-processors are run against the text after the ElementTree has been serialized into text. 5. The output is written to a string.

def convertFile(self, input=None, output=None, encoding=None): (source)

Converts a markdown file and returns the HTML as a unicode string. Decodes the file using the provided encoding (defaults to utf-8), passes the file content to markdown, and outputs the html to either the provided stream or the file with provided name, using the same encoding as the source file. The 'xmlcharrefreplace' error handler is used when encoding the output. **Note:** This is the only place that decoding and encoding of unicode takes place in Python-Markdown. (All other code is unicode-in / unicode-out.) Keyword arguments: * input: File object or path. Reads from stdin if `None`. * output: File object or path. Writes to stdout if `None`. * encoding: Encoding of input and output files. Defaults to utf-8.

def is_block_level(self, tag): (source)

Check if the tag is a block level HTML tag.

def registerExtension(self, extension): (source)

This gets called by the extension

def registerExtensions(self, extensions, configs): (source)

Register extensions with this instance of Markdown. Keyword arguments: * extensions: A list of extensions, which can either be strings or objects. * configs: A dictionary mapping extension names to config options.

def reset(self): (source)

Resets all state variables so that we can start with a new text.

def set_output_format(self, format): (source)

Set the output format for the class instance.

doc_tag: str = (source)

Undocumented

output_formats = (source)

Undocumented

block_level_elements: list[str] = (source)

Undocumented

docType: str = (source)

Undocumented

ESCAPED_CHARS: list[str] = (source)

Undocumented

htmlStash = (source)

Undocumented

inlinePatterns = (source)

Undocumented

lines = (source)

Undocumented

output_format = (source)

Undocumented

parser = (source)

Undocumented

postprocessors = (source)

Undocumented

preprocessors = (source)

Undocumented

references: dict = (source)

Undocumented

registeredExtensions: list = (source)

Undocumented

serializer = (source)

Undocumented

stripTopLevelTags: bool = (source)

Undocumented

tab_length = (source)

Undocumented

treeprocessors = (source)

Undocumented