blag.markdown

Markdown Processing.

This module contains the methods responsible for blag’s markdown processing.

Functions

convert_markdown(md, markdown)

Convert markdown into html and extract meta data.

markdown_factory()

Create a Markdown instance.

Classes

MarkdownLinkExtension(**kwargs)

markdown.extension that converts relative .md- to .html-links.

MarkdownLinkTreeprocessor([md])

Converts relative links to .md files to .html

class blag.markdown.MarkdownLinkExtension(**kwargs)

markdown.extension that converts relative .md- to .html-links.

__module__ = 'blag.markdown'
extendMarkdown(md: Markdown) None

Add the various processors and patterns to the Markdown Instance.

This method must be overridden by every extension.

Keyword arguments:

  • md: The Markdown instance.

class blag.markdown.MarkdownLinkTreeprocessor(md=None)

Converts relative links to .md files to .html

__module__ = 'blag.markdown'
convert(url: str) str
run(root: Element) Element

Subclasses of Treeprocessor should implement a run method, which takes a root ElementTree. This method can return another ElementTree object, and the existing root ElementTree will be replaced, or it can modify the current tree and return None.

blag.markdown.convert_markdown(md: Markdown, markdown: str) tuple[str, dict[str, str]]

Convert markdown into html and extract meta data.

Some meta data is treated special:
  • date is converted into datetime with local timezone

  • tags is interpreted as a comma-separeted list of strings. All strings are stripped and converted to lower case.

Parameters:
  • md – the Markdown instance

  • markdown – the markdown text that should be converted

Returns:

html and metadata

Return type:

str, dict[str, str]

blag.markdown.markdown_factory() Markdown

Create a Markdown instance.

This method exists only to ensure we use the same Markdown instance for tests as for the actual thing.

Return type:

markdown.Markdown