mdpo.mdpo2html package
HTML-produced-from-Markdown files translator using PO files as reference.
- class mdpo.mdpo2html.MdPo2HTML(pofiles, ignore=frozenset({}), merge_adjacent_markups=False, code_tags=frozenset({'code'}), bold_tags=frozenset({'b', 'strong'}), italic_tags=frozenset({'em', 'i'}), link_tags=frozenset({'a'}), image_tags=frozenset({'img'}), ignore_grouper_tags=frozenset({'div', 'hr'}), po_encoding=None, command_aliases=None, _check_saved_files_changed=None)
Bases:
HTMLParser
- _merge_adyacent_tags(html, template_tags)
- _process_replacer()
- _remove_lastline_from_output_if_empty()
- handle_comment(data)
- handle_data(data)
- handle_endtag(tag)
- handle_startendtag(tag, attrs)
- handle_starttag(tag, attrs)
- translate(filepath_or_content, save=None, html_encoding='utf-8')
- mdpo.mdpo2html._html_attrs_to_str(attrs)
Converts a dictionary of HTML attributes to its HTML representation.
- mdpo.mdpo2html.markdown_pofile_to_html(filepath_or_content, pofiles, ignore=frozenset({}), save=None, po_encoding=None, html_encoding='utf-8', command_aliases=None, **kwargs)
HTML-produced-from-Markdown file translator using PO files.
Produces a translated HTML file given a previous HTML file (created by a Markdown-to-HTML processor) and a set of PO files as reference for msgstrs.
- Parameters:
filepath_or_content (str) – HTML whose content wants to be translated.
pofiles (str) – Glob for set of pofiles used as reference translating the strings to another language.
ignore (list) – List of paths to pofiles to ignore, useful if the glob patterns in
pofiles
parameter does not fit your requirements.save (str) – If you pass this parameter as a path to one HTML file, even if does not exists, will be saved in the path the output of the function.
html_encoding (str) – HTML content encoding.
po_encoding (str) – PO files encoding. If you need different encodings for each file, you must define it in the “Content-Type” field of each PO file metadata, in the form
"Content-Type: text/plain; charset=<ENCODING>\n"
.command_aliases (dict) – Mapping of aliases to use custom mdpo command names in comments. The
mdpo-
prefix in command names resolution is optional. For example, if you want to use<!-- mdpo-on -->
instead of<!-- mdpo-enable -->
, you can pass the dictionaries{"mdpo-on": "mdpo-enable"}
or{"mdpo-on": "enable"}
to this parameter.**kwargs – Extra keyword arguments passed to
mdpo.mdpo2html.MdPo2HTML
constructor.
Known limitations:
This implementation doesn’t include support for include-codeblock command.
- Returns:
HTML output translated version of the given file.
- Return type: