/
test_paragraphs.py
74 lines (64 loc) · 2.04 KB
/
test_paragraphs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf8 -*-
from mediawiki_parser.tests import ParserTestCase
class ParagraphsTests(ParserTestCase):
def test_single_line_paragraph(self):
source = "This is a paragraph.\n"
result = """body:
paragraphs:
paragraph:
raw_text:This is a paragraph."""
self.parsed_equal_tree(source, result, None)
def test_multi_line_paragraph(self):
source = """This is a paragraph.
With a newline in the middle.
"""
result = """body:
paragraphs:
paragraph:
paragraph_line:
raw_text:This is a paragraph.
paragraph_line:
raw_text:With a newline in the middle."""
self.parsed_equal_tree(source, result, None)
def test_2_paragraphs(self):
source = """This is a paragraph.
Followed by another one.
"""
result = """body:
paragraphs:
paragraph:
raw_text:This is a paragraph.
paragraph:
raw_text:Followed by another one."""
self.parsed_equal_tree(source, result, None)
def test_blank_line_in_paragraphs(self):
source = """This is a paragraph.
Followed a blank line and another paragraph.
"""
result = """body:
paragraphs:
paragraph:
raw_text:This is a paragraph.
blank_paragraph:
paragraph:
raw_text:Followed a blank line and another paragraph."""
self.parsed_equal_tree(source, result, None)
def test_styled_text_in_paragraph(self):
source = """Styled text such as ''italic'', '''bold''', {{templates}} and {{{template parameters}}} also work.
"""
result = """body:
paragraphs:
paragraph:
raw_text:Styled text such as ''italic'', '''bold''',
internal_link:
page_name:Template:templates
raw_text: and
allowed_char:{
allowed_char:{
allowed_char:{
raw_text:template parameters
allowed_char:}
allowed_char:}
allowed_char:}
raw_text: also work."""
self.parsed_equal_tree(source, result, None)