Exemple #1
0
def test_context_without_value(command, command_aliases):
    # does not raises error, is ignored
    assert markdown_pofile_to_html(
        f'<!-- {command} -->',
        '',
        command_aliases=command_aliases,
    ) == f'<!-- {command} -->'
Exemple #2
0
def test_context(command, command_aliases, tmp_file):
    html_input = f'''<!-- {command} month -->
<p>May</p>

<!-- mdpo-context might -->
<p>May</p>
'''

    html_output = '\n<p>Mayo</p>\n\n<p>Quizás</p>\n'

    pofile_content = '''#
msgid ""
msgstr ""

msgctxt "month"
msgid "May"
msgstr "Mayo"

msgctxt "might"
msgid "May"
msgstr "Quizás"
'''

    with tmp_file(pofile_content, '.po') as po_filepath:
        output = markdown_pofile_to_html(
            html_input,
            po_filepath,
            command_aliases=command_aliases,
        )
    assert output == html_output
Exemple #3
0
def test_include_codeblock(command, command_aliases, tmp_file):
    html_input = f'''<!-- {command} -->'''
    pofile_content = '''#

msgid ""
msgstr ""
'''
    with pytest.warns(SyntaxWarning) as record:
        with tmp_file(pofile_content, '.po') as po_filepath:
            markdown_pofile_to_html(
                html_input,
                po_filepath,
                command_aliases=command_aliases,
            )

    assert len(record) == 1
    assert record[0].message.args[0] == (
        'Code blocks translations are not supported by mdpo2html'
        ' implementation.')
def test_translate_markuptext(filename):
    filepath_in = os.path.join(EXAMPLES['markuptext']['dirpath'], filename)
    filepath_out = filepath_in + '.expect.html'
    po_filepath = os.path.join(
        os.path.dirname(filepath_in),
        os.path.splitext(os.path.basename(filepath_in))[0] + '.po',
    )
    if not os.path.exists(po_filepath):
        po_filepath = ''

    output = markdown_pofile_to_html(filepath_in, po_filepath)

    with open(filepath_out) as f:
        expected_output = f.read()

    assert output == expected_output