| 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 TestAdmonition(TestCase): |
| 26 |
|
| 27 |
def test_with_lists(self): |
| 28 |
self.assertMarkdownRenders( |
| 29 |
self.dedent( |
| 30 |
''' |
| 31 |
- List |
| 32 |
|
| 33 |
!!! note "Admontion" |
| 34 |
|
| 35 |
- Paragraph |
| 36 |
|
| 37 |
Paragraph |
| 38 |
''' |
| 39 |
), |
| 40 |
self.dedent( |
| 41 |
''' |
| 42 |
<ul> |
| 43 |
<li> |
| 44 |
<p>List</p> |
| 45 |
<div class="admonition note"> |
| 46 |
<p class="admonition-title">Admontion</p> |
| 47 |
<ul> |
| 48 |
<li> |
| 49 |
<p>Paragraph</p> |
| 50 |
<p>Paragraph</p> |
| 51 |
</li> |
| 52 |
</ul> |
| 53 |
</div> |
| 54 |
</li> |
| 55 |
</ul> |
| 56 |
''' |
| 57 |
), |
| 58 |
extensions=['admonition'] |
| 59 |
) |
| 60 |
|
| 61 |
def test_with_big_lists(self): |
| 62 |
self.assertMarkdownRenders( |
| 63 |
self.dedent( |
| 64 |
''' |
| 65 |
- List |
| 66 |
|
| 67 |
!!! note "Admontion" |
| 68 |
|
| 69 |
- Paragraph |
| 70 |
|
| 71 |
Paragraph |
| 72 |
|
| 73 |
- Paragraph |
| 74 |
|
| 75 |
paragraph |
| 76 |
''' |
| 77 |
), |
| 78 |
self.dedent( |
| 79 |
''' |
| 80 |
<ul> |
| 81 |
<li> |
| 82 |
<p>List</p> |
| 83 |
<div class="admonition note"> |
| 84 |
<p class="admonition-title">Admontion</p> |
| 85 |
<ul> |
| 86 |
<li> |
| 87 |
<p>Paragraph</p> |
| 88 |
<p>Paragraph</p> |
| 89 |
</li> |
| 90 |
<li> |
| 91 |
<p>Paragraph</p> |
| 92 |
<p>paragraph</p> |
| 93 |
</li> |
| 94 |
</ul> |
| 95 |
</div> |
| 96 |
</li> |
| 97 |
</ul> |
| 98 |
''' |
| 99 |
), |
| 100 |
extensions=['admonition'] |
| 101 |
) |
| 102 |
|
| 103 |
def test_with_complex_lists(self): |
| 104 |
self.assertMarkdownRenders( |
| 105 |
self.dedent( |
| 106 |
''' |
| 107 |
- List |
| 108 |
|
| 109 |
!!! note "Admontion" |
| 110 |
|
| 111 |
- Paragraph |
| 112 |
|
| 113 |
!!! note "Admontion" |
| 114 |
|
| 115 |
1. Paragraph |
| 116 |
|
| 117 |
Paragraph |
| 118 |
''' |
| 119 |
), |
| 120 |
self.dedent( |
| 121 |
''' |
| 122 |
<ul> |
| 123 |
<li> |
| 124 |
<p>List</p> |
| 125 |
<div class="admonition note"> |
| 126 |
<p class="admonition-title">Admontion</p> |
| 127 |
<ul> |
| 128 |
<li> |
| 129 |
<p>Paragraph</p> |
| 130 |
<div class="admonition note"> |
| 131 |
<p class="admonition-title">Admontion</p> |
| 132 |
<ol> |
| 133 |
<li> |
| 134 |
<p>Paragraph</p> |
| 135 |
<p>Paragraph</p> |
| 136 |
</li> |
| 137 |
</ol> |
| 138 |
</div> |
| 139 |
</li> |
| 140 |
</ul> |
| 141 |
</div> |
| 142 |
</li> |
| 143 |
</ul> |
| 144 |
''' |
| 145 |
), |
| 146 |
extensions=['admonition'] |
| 147 |
) |
| 148 |
|
| 149 |
def test_definition_list(self): |
| 150 |
self.assertMarkdownRenders( |
| 151 |
self.dedent( |
| 152 |
''' |
| 153 |
- List |
| 154 |
|
| 155 |
!!! note "Admontion" |
| 156 |
|
| 157 |
Term |
| 158 |
|
| 159 |
: Definition |
| 160 |
|
| 161 |
More text |
| 162 |
|
| 163 |
: Another |
| 164 |
definition |
| 165 |
|
| 166 |
Even more text |
| 167 |
''' |
| 168 |
), |
| 169 |
self.dedent( |
| 170 |
''' |
| 171 |
<ul> |
| 172 |
<li> |
| 173 |
<p>List</p> |
| 174 |
<div class="admonition note"> |
| 175 |
<p class="admonition-title">Admontion</p> |
| 176 |
<dl> |
| 177 |
<dt>Term</dt> |
| 178 |
<dd> |
| 179 |
<p>Definition</p> |
| 180 |
<p>More text</p> |
| 181 |
</dd> |
| 182 |
<dd> |
| 183 |
<p>Another |
| 184 |
definition</p> |
| 185 |
<p>Even more text</p> |
| 186 |
</dd> |
| 187 |
</dl> |
| 188 |
</div> |
| 189 |
</li> |
| 190 |
</ul> |
| 191 |
''' |
| 192 |
), |
| 193 |
extensions=['admonition', 'def_list'] |
| 194 |
) |
| 195 |
|
| 196 |
def test_with_preceding_text(self): |
| 197 |
self.assertMarkdownRenders( |
| 198 |
self.dedent( |
| 199 |
''' |
| 200 |
foo |
| 201 |
**foo** |
| 202 |
!!! note "Admonition" |
| 203 |
''' |
| 204 |
), |
| 205 |
self.dedent( |
| 206 |
''' |
| 207 |
<p>foo |
| 208 |
<strong>foo</strong></p> |
| 209 |
<div class="admonition note"> |
| 210 |
<p class="admonition-title">Admonition</p> |
| 211 |
</div> |
| 212 |
''' |
| 213 |
), |
| 214 |
extensions=['admonition'] |
| 215 |
) |
| 216 |
|
| 217 |
def test_admontion_detabbing(self): |
| 218 |
self.assertMarkdownRenders( |
| 219 |
self.dedent( |
| 220 |
''' |
| 221 |
!!! note "Admonition" |
| 222 |
- Parent 1 |
| 223 |
|
| 224 |
- Child 1 |
| 225 |
- Child 2 |
| 226 |
''' |
| 227 |
), |
| 228 |
self.dedent( |
| 229 |
''' |
| 230 |
<div class="admonition note"> |
| 231 |
<p class="admonition-title">Admonition</p> |
| 232 |
<ul> |
| 233 |
<li> |
| 234 |
<p>Parent 1</p> |
| 235 |
<ul> |
| 236 |
<li>Child 1</li> |
| 237 |
<li>Child 2</li> |
| 238 |
</ul> |
| 239 |
</li> |
| 240 |
</ul> |
| 241 |
</div> |
| 242 |
''' |
| 243 |
), |
| 244 |
extensions=['admonition'] |
| 245 |
) |
| 246 |
|
| 247 |
def test_admonition_first_indented(self): |
| 248 |
self.assertMarkdownRenders( |
| 249 |
self.dedent( |
| 250 |
''' |
| 251 |
!!! danger "This is not" |
| 252 |
one long admonition title |
| 253 |
''' |
| 254 |
), |
| 255 |
self.dedent( |
| 256 |
''' |
| 257 |
<div class="admonition danger"> |
| 258 |
<p class="admonition-title">This is not</p> |
| 259 |
<pre><code>one long admonition title |
| 260 |
</code></pre> |
| 261 |
</div> |
| 262 |
''' |
| 263 |
), |
| 264 |
extensions=['admonition'] |
| 265 |
) |