aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extensions/admonition.html30
-rw-r--r--tests/extensions/admonition.txt28
-rw-r--r--tests/extensions/test.cfg3
-rw-r--r--tests/test_extensions.py35
4 files changed, 86 insertions, 10 deletions
diff --git a/tests/extensions/admonition.html b/tests/extensions/admonition.html
new file mode 100644
index 0000000..437cac6
--- /dev/null
+++ b/tests/extensions/admonition.html
@@ -0,0 +1,30 @@
+<p>Some text</p>
+<div class="admonition note">
+<p class="admonition-title">Note</p>
+<p>A normal paragraph here</p>
+<ol>
+<li>first</li>
+<li>second</li>
+</ol>
+<blockquote>
+<p>Some important quote</p>
+<p>another paragraph in the quote</p>
+</blockquote>
+<pre><code>int main() {
+ // insert some code
+}
+</code></pre>
+</div>
+<p>More text and stuff.</p>
+<div class="admonition note">
+<p class="admonition-title">Did you know?</p>
+<p>You can customize the title of the admonition</p>
+</div>
+<div class="admonition mycustomcssclass">
+<p class="admonition-title">And now...</p>
+<p>For something completely different.</p>
+<p>You can also use a custom CSS class name.</p>
+</div>
+<div class="admonition tip">
+<p>An explicitly empty string prevents the title from being rendered.</p>
+</div> \ No newline at end of file
diff --git a/tests/extensions/admonition.txt b/tests/extensions/admonition.txt
new file mode 100644
index 0000000..fd18bd6
--- /dev/null
+++ b/tests/extensions/admonition.txt
@@ -0,0 +1,28 @@
+Some text
+
+!!! note
+ A normal paragraph here
+
+ 1. first
+ 2. second
+
+ > Some important quote
+
+ > another paragraph in the quote
+
+ int main() {
+ // insert some code
+ }
+
+More text and stuff.
+
+!!! note "Did you know?"
+ You can customize the title of the admonition
+
+!!! mycustomcssclass "And now..."
+ For something completely different.
+
+ You can also use a custom CSS class name.
+
+!!! tip ""
+ An explicitly empty string prevents the title from being rendered.
diff --git a/tests/extensions/test.cfg b/tests/extensions/test.cfg
index d642bd8..4efd837 100644
--- a/tests/extensions/test.cfg
+++ b/tests/extensions/test.cfg
@@ -32,3 +32,6 @@ extensions=sane_lists
[nl2br_w_attr_list]
extensions=nl2br,attr_list
+
+[admonition]
+extensions=admonition
diff --git a/tests/test_extensions.py b/tests/test_extensions.py
index 7dab60a..fd77e5e 100644
--- a/tests/test_extensions.py
+++ b/tests/test_extensions.py
@@ -2,7 +2,7 @@
Python-Markdown Extension Regression Tests
==========================================
-A collection of regression tests to confirm that the included extensions
+A collection of regression tests to confirm that the included extensions
continue to work as advertised. This used to be accomplished by doctests.
"""
@@ -60,7 +60,7 @@ class TestFencedCode(unittest.TestCase):
def testBasicFence(self):
""" Test Fenced Code Blocks. """
- text = '''
+ text = '''
A paragraph before a fenced code block:
~~~
@@ -124,7 +124,7 @@ class TestHeaderId(unittest.TestCase):
def testBasicHeaderId(self):
""" Test Basic HeaderID """
-
+
text = "# Some Header #"
self.assertEqual(self.md.convert(text),
'<h1 id="some-header">Some Header</h1>')
@@ -202,8 +202,8 @@ The body. This is paragraph one.'''
self.assertEqual(self.md.convert(text),
'<p>The body. This is paragraph one.</p>')
self.assertEqual(self.md.Meta,
- {'author': ['Waylan Limberg', 'John Doe'],
- 'blank_data': [''],
+ {'author': ['Waylan Limberg', 'John Doe'],
+ 'blank_data': [''],
'title': ['A Test Doc.']})
def testMissingMetaData(self):
@@ -239,18 +239,18 @@ class TestWikiLinks(unittest.TestCase):
def testSimpleSettings(self):
""" Test Simple Settings. """
- self.assertEqual(markdown.markdown(self.text,
+ self.assertEqual(markdown.markdown(self.text,
['wikilinks(base_url=/wiki/,end_url=.html,html_class=foo)']),
'<p>Some text with a '
'<a class="foo" href="/wiki/WikiLink.html">WikiLink</a>.</p>')
-
+
def testComplexSettings(self):
""" Test Complex Settings. """
md = markdown.Markdown(
- extensions = ['wikilinks'],
+ extensions = ['wikilinks'],
extension_configs = {'wikilinks': [
- ('base_url', 'http://example.com/'),
+ ('base_url', 'http://example.com/'),
('end_url', '.html'),
('html_class', '') ]},
safe_mode = True)
@@ -281,8 +281,23 @@ Some text with a [[WikiLink]]."""
def my_url_builder(label, base, end):
return '/bar/'
- md = markdown.Markdown(extensions=['wikilinks'],
+ md = markdown.Markdown(extensions=['wikilinks'],
extension_configs={'wikilinks' : [('build_url', my_url_builder)]})
self.assertEqual(md.convert('[[foo]]'),
'<p><a class="wikilink" href="/bar/">foo</a></p>')
+class TestAdmonition(unittest.TestCase):
+ """ Test Admonition Extension. """
+
+ def setUp(self):
+ self.md = markdown.Markdown(extensions=['admonition'])
+
+ def testRE(self):
+ RE = self.md.parser.blockprocessors['admonition'].RE
+ tests = [
+ ('!!! note', ('note', None)),
+ ('!!! note "Please Note"', ('note', 'Please Note')),
+ ('!!! note ""', ('note', '')),
+ ]
+ for test, expected in tests:
+ self.assertEqual(RE.match(test).groups(), expected)