markdown_to_mrkdwn package

Submodules

markdown_to_mrkdwn.converter module

class markdown_to_mrkdwn.converter.SlackMarkdownConverter(encoding='utf-8')

Bases: object

A converter class to transform Markdown text into Slack’s mrkdwn format.

encoding

The character encoding used for the conversion.

Type:

str

patterns

A list of regex patterns and their replacements.

Type:

List[Tuple[str, str]]

plugins

A dictionary of registered plugins.

Type:

Dict[str, Dict[str, Any]]

plugin_order

A list of plugin names in execution order.

Type:

List[str]

convert(markdown: str) str

Convert Markdown text to Slack’s mrkdwn format.

Parameters:

markdown (str) – The Markdown text to convert.

Returns:

The converted text in Slack’s mrkdwn format.

Return type:

str

get_registered_plugins() Dict[str, Dict[str, Any]]

Get a list of all registered plugins.

Returns:

A dictionary of plugin names and their properties

Return type:

Dict[str, Dict[str, Any]]

register_plugin(name: str, converter_func: Callable[[str], str], priority: int = 50, scope: str = 'line', timing: str = 'after') None

Register a custom conversion plugin.

Parameters:
  • name (str) – A unique name for the plugin

  • converter_func (callable) – A function that takes a text string and returns the converted text

  • priority (int) – Execution priority (lower numbers execute first)

  • scope (str) – Application scope - “global” (entire text), “line” (line by line), or “block” (block by block)

  • timing (str) – When to apply the plugin for line scope - “before” or “after” (default: “after”)

register_regex_plugin(name: str, pattern: str, replacement: str, priority: int = 50, timing: str = 'after') None

Register a line-scope plugin using only regex pattern and replacement. :param name: Unique name for the plugin :type name: str :param pattern: Regex pattern to search for :type pattern: str :param replacement: Replacement string :type replacement: str :param priority: Execution priority (lower numbers execute first) :type priority: int :param timing: When to apply the plugin - “before” or “after” (default: “after”) :type timing: str

remove_plugin(name: str) bool

Remove a registered plugin.

Parameters:

name (str) – The name of the plugin to remove

Returns:

True if the plugin was removed, False if it wasn’t found

Return type:

bool

Module contents

class markdown_to_mrkdwn.SlackMarkdownConverter(encoding='utf-8')

Bases: object

A converter class to transform Markdown text into Slack’s mrkdwn format.

encoding

The character encoding used for the conversion.

Type:

str

patterns

A list of regex patterns and their replacements.

Type:

List[Tuple[str, str]]

plugins

A dictionary of registered plugins.

Type:

Dict[str, Dict[str, Any]]

plugin_order

A list of plugin names in execution order.

Type:

List[str]

convert(markdown: str) str

Convert Markdown text to Slack’s mrkdwn format.

Parameters:

markdown (str) – The Markdown text to convert.

Returns:

The converted text in Slack’s mrkdwn format.

Return type:

str

get_registered_plugins() Dict[str, Dict[str, Any]]

Get a list of all registered plugins.

Returns:

A dictionary of plugin names and their properties

Return type:

Dict[str, Dict[str, Any]]

register_plugin(name: str, converter_func: Callable[[str], str], priority: int = 50, scope: str = 'line', timing: str = 'after') None

Register a custom conversion plugin.

Parameters:
  • name (str) – A unique name for the plugin

  • converter_func (callable) – A function that takes a text string and returns the converted text

  • priority (int) – Execution priority (lower numbers execute first)

  • scope (str) – Application scope - “global” (entire text), “line” (line by line), or “block” (block by block)

  • timing (str) – When to apply the plugin for line scope - “before” or “after” (default: “after”)

register_regex_plugin(name: str, pattern: str, replacement: str, priority: int = 50, timing: str = 'after') None

Register a line-scope plugin using only regex pattern and replacement. :param name: Unique name for the plugin :type name: str :param pattern: Regex pattern to search for :type pattern: str :param replacement: Replacement string :type replacement: str :param priority: Execution priority (lower numbers execute first) :type priority: int :param timing: When to apply the plugin - “before” or “after” (default: “after”) :type timing: str

remove_plugin(name: str) bool

Remove a registered plugin.

Parameters:

name (str) – The name of the plugin to remove

Returns:

True if the plugin was removed, False if it wasn’t found

Return type:

bool