command.py

mdpo HTML commands related utilities.

mdpo.command.get_valid_mdpo_command_names()

Return valid mdpo commands names, with and without “mdpo-” prefix.

Returns

Valid mdpo command names.

Return type

list

mdpo.command.normalize_mdpo_command(value)

Normalizes a valid command and returns None if the command is invalid.

This function works for lazy command validation (the user doesn’t need to specify the mdpo- prefix used for command names).

Parameters

value (str) – Command to be normalized.

Returns

Normalized command or None if is invalid.

Return type

str or None

mdpo.command.normalize_mdpo_command_aliases(command_aliases)

Validates and normalizes a mapping of mdpo command aliases.

Parameters

command_aliases (dict) – Aliases for mdpo commands, in the form {"<new-command-name>": "<mdpo-command>"}.

Raises

ValueError – if an mdpo command resolution doesn’t exists.

Returns

Mapping validated and normalized.

Return type

dict

mdpo.command.parse_mdpo_html_command(value)

Parses a mdpo HTML command inside a string value.

This function is used by md2po implementation to discover the HTML commands used by mdpo to customize the extraction.

Parameters

value (str) – Text where will a command will be searched.

Returns

Namename of the command (not including the "mdpo" prefix) and its value.

Return type

tuple