Markup interface

The main class for interacting with markups is AbstractMarkup.

However, you shouldn’t create direct instances of that class. Instead, use one of the standard markup classes.

class markups.abstract.AbstractMarkup(filename: Optional[str] = None)

Abstract class for markup languages.


filename – optional name of the file

attributes: Dict[int, Any]

various attributes, like links to website and syntax documentation

static available() bool

whether the markup is ready for use

(for example, whether the required third-party modules are importable)

convert(text: str) markups.abstract.ConvertedMarkup

a ConvertedMarkup instance (or a subclass thereof) containing the markup converted to HTML

default_extension: str

the default file extension

file_extensions: Tuple[str, ...]

indicates which file extensions are associated with the markup

name: str

name of the markup visible to user

When AbstractMarkup’s convert() method is called it will return an instance of ConvertedMarkup or a subclass thereof that provides access to the conversion results.

class markups.abstract.ConvertedMarkup(body: str, title: str = '', stylesheet: str = '', javascript: str = '')

This class encapsulates the title, body, stylesheet and javascript of a converted document.

Instances of this class are created by AbstractMarkup.convert() method, usually it should not be instantiated directly.

get_document_body() str

the contents of the <body> HTML tag

get_document_title() str

the document title

get_javascript(webenv: bool = False) str

one or more HTML tags to be inserted into the document <head>.


webenv – if true, the specific markups may optimize the document for being used in the World Wide Web (for example, a remote version of MathJax script can be inserted instead of the local one).

get_stylesheet() str

the contents of <style type="text/css"> HTML tag

get_whole_html(custom_headers: str = '', include_stylesheet: bool = True, fallback_title: str = '', webenv: bool = False) str

the full contents of the HTML document (unless overridden this is a combination of the previous methods)

  • custom_headers – custom HTML to be inserted into the document <head>

  • include_stylesheet – if false, the stylesheet will not be included in the document <head>

  • fallback_title – when impossible to get the <title> from the document, this string can be used as a fallback

  • webenv – like in get_javascript() above