Debian Codegraph @

tests/test_syntax/inline/test_emphasis.py

raw
1 """
2 Python Markdown
3
4 A Python implementation of John Gruber's Markdown.
5
6 Documentation: https://python-markdown.github.io/
7 GitHub: https://github.com/Python-Markdown/markdown/
8 PyPI: https://pypi.org/project/Markdown/
9
10 Started by Manfred Stienstra (http://www.dwerg.net/).
11 Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
12 Currently maintained by Waylan Limberg (https://github.com/waylan),
13 Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
14
15 Copyright 2007-2019 The Python Markdown Project (v. 1.7 and later)
16 Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
17 Copyright 2004 Manfred Stienstra (the original version)
18
19 License: BSD (see LICENSE.md for details).
20 """
21
22 from markdown.test_tools import TestCase
23
24
25 class TestNotEmphasis(TestCase):
26
27 def test_standalone_asterisk(self):
28 self.assertMarkdownRenders(
29 '*',
30 '<p>*</p>'
31 )
32
33 def test_standalone_understore(self):
34 self.assertMarkdownRenders(
35 '_',
36 '<p>_</p>'
37 )
38
39 def test_standalone_asterisks_consecutive(self):
40 self.assertMarkdownRenders(
41 'Foo * * * *',
42 '<p>Foo * * * *</p>'
43 )
44
45 def test_standalone_understore_consecutive(self):
46 self.assertMarkdownRenders(
47 'Foo _ _ _ _',
48 '<p>Foo _ _ _ _</p>'
49 )
50
51 def test_standalone_asterisks_pairs(self):
52 self.assertMarkdownRenders(
53 'Foo ** ** ** **',
54 '<p>Foo ** ** ** **</p>'
55 )
56
57 def test_standalone_understore_pairs(self):
58 self.assertMarkdownRenders(
59 'Foo __ __ __ __',
60 '<p>Foo __ __ __ __</p>'
61 )
62
63 def test_standalone_asterisks_triples(self):
64 self.assertMarkdownRenders(
65 'Foo *** *** *** ***',
66 '<p>Foo *** *** *** ***</p>'
67 )
68
69 def test_standalone_understore_triples(self):
70 self.assertMarkdownRenders(
71 'Foo ___ ___ ___ ___',
72 '<p>Foo ___ ___ ___ ___</p>'
73 )
74
75 def test_standalone_asterisk_in_text(self):
76 self.assertMarkdownRenders(
77 'foo * bar',
78 '<p>foo * bar</p>'
79 )
80
81 def test_standalone_understore_in_text(self):
82 self.assertMarkdownRenders(
83 'foo _ bar',
84 '<p>foo _ bar</p>'
85 )
86
87 def test_standalone_asterisks_in_text(self):
88 self.assertMarkdownRenders(
89 'foo * bar * baz',
90 '<p>foo * bar * baz</p>'
91 )
92
93 def test_standalone_understores_in_text(self):
94 self.assertMarkdownRenders(
95 'foo _ bar _ baz',
96 '<p>foo _ bar _ baz</p>'
97 )
98
99 def test_standalone_asterisks_with_newlines(self):
100 self.assertMarkdownRenders(
101 'foo\n* bar *\nbaz',
102 '<p>foo\n* bar *\nbaz</p>'
103 )
104
105 def test_standalone_understores_with_newlines(self):
106 self.assertMarkdownRenders(
107 'foo\n_ bar _\nbaz',
108 '<p>foo\n_ bar _\nbaz</p>'
109 )
110
111 def test_standalone_underscore_at_begin(self):
112 self.assertMarkdownRenders(
113 '_ foo_ bar',
114 '<p>_ foo_ bar</p>'
115 )
116
117 def test_standalone_asterisk_at_end(self):
118 self.assertMarkdownRenders(
119 'foo *bar *',
120 '<p>foo *bar *</p>'
121 )
122
123 def test_standalone_understores_at_begin_end(self):
124 self.assertMarkdownRenders(
125 '_ bar _',
126 '<p>_ bar _</p>'
127 )
128
129 def test_complex_emphasis_asterisk(self):
130 self.assertMarkdownRenders(
131 'This is text **bold *italic bold*** with more text',
132 '<p>This is text <strong>bold <em>italic bold</em></strong> with more text</p>'
133 )
134
135 def test_complex_emphasis_asterisk_mid_word(self):
136 self.assertMarkdownRenders(
137 'This is text **bold*italic bold*** with more text',
138 '<p>This is text <strong>bold<em>italic bold</em></strong> with more text</p>'
139 )
140
141 def test_complex_emphasis_smart_underscore(self):
142 self.assertMarkdownRenders(
143 'This is text __bold _italic bold___ with more text',
144 '<p>This is text <strong>bold <em>italic bold</em></strong> with more text</p>'
145 )
146
147 def test_complex_emphasis_smart_underscore_mid_word(self):
148 self.assertMarkdownRenders(
149 'This is text __bold_italic bold___ with more text',
150 '<p>This is text __bold_italic bold___ with more text</p>'
151 )
152
153 def test_nested_emphasis(self):
154
155 self.assertMarkdownRenders(
156 'This text is **bold *italic* *italic* bold**',
157 '<p>This text is <strong>bold <em>italic</em> <em>italic</em> bold</strong></p>'
158 )
159
160 def test_complex_multple_emphasis_type(self):
161
162 self.assertMarkdownRenders(
163 'traced ***along*** bla **blocked** if other ***or***',
164 '<p>traced <strong><em>along</em></strong> bla <strong>blocked</strong> if other <strong><em>or</em></strong></p>' # noqa: E501
165 )
166
167 def test_complex_multple_emphasis_type_variant2(self):
168
169 self.assertMarkdownRenders(
170 'on the **1-4 row** of the AP Combat Table ***and*** receive',
171 '<p>on the <strong>1-4 row</strong> of the AP Combat Table <strong><em>and</em></strong> receive</p>'
172 )
173
174 def test_link_emphasis_outer(self):
175
176 self.assertMarkdownRenders(
177 '**[text](url)**',
178 '<p><strong><a href="url">text</a></strong></p>'
179 )
180
181 def test_link_emphasis_inner(self):
182
183 self.assertMarkdownRenders(
184 '[**text**](url)',
185 '<p><a href="url"><strong>text</strong></a></p>'
186 )
187
188 def test_link_emphasis_inner_outer(self):
189
190 self.assertMarkdownRenders(
191 '**[**text**](url)**',
192 '<p><strong><a href="url"><strong>text</strong></a></strong></p>'
193 )