md.py

Markdown related utilities for mdpo.

Escapes " characters found inside link titles.

This is used by mdpo extracting titles of links which contains Markdown link titles delimiter characters.

Parameters
  • text (str) – Text where the links titles to escape will be searched.

  • link_start_string (str) – String that delimites the start of a link.

  • link_end_string (str) – String that delimites the end of a link.

Returns

Same text as input with escaped title delimiters characters found inside titles.

Return type

str

Examples

>>> title = '[a link](href "title with characters to escape "")'
>>> escape_links_titles(title)
'[a link](href "title with characters to escape \\"")'

Parses link references found in a Markdown content.

Parameters

content (str) – Markdown content to be parsed.

Returns

Tuples with 3 values, target, href and title for each link

reference.

Return type

list

Solve link reference targets in markdown blocks.

Given a dictionary of msgid/msgstr translations, those link references targets will be resolved and returned in a new dictionary.

Parameters

translations (dictionary) – Mapping of msgid-msgstr entries from which the resolved translations will be extracted.

Returns

New created messages with solved link reference targets.

Return type

dict