forked from translate/pootle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b33f4a
commit aa61bcb
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) Pootle contributors. | ||
# | ||
# This file is a part of the Pootle project. It is distributed under the GPL3 | ||
# or later license. See the LICENSE file for a copy of the license and the | ||
# AUTHORS file for copyright and authorship information. | ||
|
||
import pytest | ||
|
||
from pootle.core.markup.filters import apply_markup_filter | ||
|
||
|
||
@pytest.mark.parametrize('markdown_text, expected_html', [ | ||
# Standard markdown | ||
('Paragraph', '<p>Paragraph</p>'), | ||
('## Header', '<h2>Header</h2>'), | ||
('* List', '<ul><li>List</li></ul>'), | ||
('<hr>', '<hr>'), | ||
# Accept img tags since markdown is rubbish at images | ||
('Show icon <img alt="image" src="pic.png">', | ||
'<p>Show icon <img alt="image" src="pic.png"></p>'), | ||
# Accept span and class= | ||
('Use <span class="allcaps">All Caps</span> for headers.', | ||
'<p>Use <span class="allcaps">All Caps</span> for headers.</p>'), | ||
# Escape a <script> tag | ||
('Bad hacker <script>alert("Bang!")</script>', | ||
'<p>Bad hacker <script>alert("Bang!")</script></p>'), | ||
]) | ||
def test_apply_markup_filter(settings, markdown_text, expected_html): | ||
settings.POOTLE_MARKUP_FILTER = ('markdown', {}) | ||
output_html = apply_markup_filter(markdown_text) | ||
output_html = output_html[5:-6] # Remove surrounding <div>...</div> | ||
output_html = output_html.replace('\n', '') # Remove pretty print newlines | ||
assert output_html == expected_html |