diff options
author | Waylan Limberg <waylan@gmail.com> | 2011-08-02 09:23:49 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2011-08-02 09:23:49 -0400 |
commit | 7af553173629d8d8e36e71fbf2753dc8d6fe11d3 (patch) | |
tree | b9f2460776fe98511f3c713b5ae5fd5b3899bfaf | |
parent | 447e238186f30f3480afadb68aaf5efa4f6dfc9e (diff) | |
download | markdown-7af553173629d8d8e36e71fbf2753dc8d6fe11d3.tar.gz markdown-7af553173629d8d8e36e71fbf2753dc8d6fe11d3.tar.bz2 markdown-7af553173629d8d8e36e71fbf2753dc8d6fe11d3.zip |
Added doctests to fabfile and edited them to pass in all supported versions of python. Note: one test (meta) is still failing on Python 3 due to unicode strings.
-rw-r--r-- | fabfile.py | 1 | ||||
-rw-r--r-- | markdown/extensions/abbr.py | 4 | ||||
-rw-r--r-- | markdown/extensions/fenced_code.py | 32 | ||||
-rw-r--r-- | markdown/extensions/headerid.py | 28 | ||||
-rw-r--r-- | markdown/extensions/meta.py | 11 | ||||
-rw-r--r-- | markdown/extensions/nl2br.py | 5 | ||||
-rw-r--r-- | markdown/extensions/smart_strong.py | 12 | ||||
-rw-r--r-- | markdown/extensions/wikilinks.py | 32 |
8 files changed, 67 insertions, 58 deletions
@@ -49,6 +49,7 @@ def build_tests(version=_pyversion[:3]): local('mkdir build/test.%s/tests' % version) local('cp -r tests/* build/test.%s/tests' % version) local('cp run-tests.py build/test.%s/run-tests.py' % version) + local('cp setup.cfg build/test.%s/setup.cfg' % version) if version.startswith('3'): # Do 2to3 conversion local('2to3-%s -w -d build/test.%s/markdown' % (version, version)) diff --git a/markdown/extensions/abbr.py b/markdown/extensions/abbr.py index bc346cc..45663c0 100644 --- a/markdown/extensions/abbr.py +++ b/markdown/extensions/abbr.py @@ -13,8 +13,8 @@ Simple Usage: ... *[ABBR]: Abbreviation ... *[REF]: Abbreviation Reference ... """ - >>> markdown.markdown(text, ['abbr']) - u'<p>Some text with an <abbr title="Abbreviation">ABBR</abbr> and a <abbr title="Abbreviation Reference">REF</abbr>. Ignore REFERENCE and ref.</p>' + >>> print markdown.markdown(text, ['abbr']) + <p>Some text with an <abbr title="Abbreviation">ABBR</abbr> and a <abbr title="Abbreviation Reference">REF</abbr>. Ignore REFERENCE and ref.</p> Copyright 2007-2008 * [Waylan Limberg](http://achinghead.com/) diff --git a/markdown/extensions/fenced_code.py b/markdown/extensions/fenced_code.py index 3592d78..e5b3350 100644 --- a/markdown/extensions/fenced_code.py +++ b/markdown/extensions/fenced_code.py @@ -15,13 +15,17 @@ This extension adds Fenced Code Blocks to Python-Markdown. ... ~~~ ... ''' >>> html = markdown.markdown(text, extensions=['fenced_code']) - >>> html - u'<p>A paragraph before a fenced code block:</p>\\n<pre><code>Fenced code block\\n</code></pre>' + >>> print html + <p>A paragraph before a fenced code block:</p> + <pre><code>Fenced code block + </code></pre> Works with safe_mode also (we check this because we are using the HtmlStash): - >>> markdown.markdown(text, extensions=['fenced_code'], safe_mode='replace') - u'<p>A paragraph before a fenced code block:</p>\\n<pre><code>Fenced code block\\n</code></pre>' + >>> print markdown.markdown(text, extensions=['fenced_code'], safe_mode='replace') + <p>A paragraph before a fenced code block:</p> + <pre><code>Fenced code block + </code></pre> Include tilde's in a code block and wrap with blank lines: @@ -29,23 +33,21 @@ Include tilde's in a code block and wrap with blank lines: ... ~~~~~~~~ ... ... ~~~~ - ... ... ~~~~~~~~''' - >>> markdown.markdown(text, extensions=['fenced_code']) - u'<pre><code>\\n~~~~\\n\\n</code></pre>' + >>> print markdown.markdown(text, extensions=['fenced_code']) + <pre><code> + ~~~~ + </code></pre> -Multiple blocks and language tags: +Language tags: >>> text = ''' ... ~~~~{.python} - ... block one - ... ~~~~ - ... - ... ~~~~.html - ... <p>block two</p> + ... # Some python code ... ~~~~''' - >>> markdown.markdown(text, extensions=['fenced_code']) - u'<pre><code class="python">block one\\n</code></pre>\\n\\n<pre><code class="html"><p>block two</p>\\n</code></pre>' + >>> print markdown.markdown(text, extensions=['fenced_code']) + <pre><code class="python"># Some python code + </code></pre> Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/). diff --git a/markdown/extensions/headerid.py b/markdown/extensions/headerid.py index 42e82b0..b0e37e2 100644 --- a/markdown/extensions/headerid.py +++ b/markdown/extensions/headerid.py @@ -11,8 +11,8 @@ Basic usage: >>> import markdown >>> text = "# Some Header #" >>> md = markdown.markdown(text, ['headerid']) - >>> md - u'<h1 id="some-header">Some Header</h1>' + >>> print md + <h1 id="some-header">Some Header</h1> All header IDs are unique: @@ -21,8 +21,10 @@ All header IDs are unique: ... #Header ... #Header''' >>> md = markdown.markdown(text, ['headerid']) - >>> md - u'<h1 id="header">Header</h1>\\n<h1 id="header_1">Header</h1>\\n<h1 id="header_2">Header</h1>' + >>> print md + <h1 id="header">Header</h1> + <h1 id="header_1">Header</h1> + <h1 id="header_2">Header</h1> To fit within a html template's hierarchy, set the header base level: @@ -30,15 +32,16 @@ To fit within a html template's hierarchy, set the header base level: ... #Some Header ... ## Next Level''' >>> md = markdown.markdown(text, ['headerid(level=3)']) - >>> md - u'<h3 id="some-header">Some Header</h3>\\n<h4 id="next-level">Next Level</h4>' + >>> print md + <h3 id="some-header">Some Header</h3> + <h4 id="next-level">Next Level</h4> Works with inline markup. >>> text = '#Some *Header* with [markup](http://example.com).' >>> md = markdown.markdown(text, ['headerid']) - >>> md - u'<h1 id="some-header-with-markup">Some <em>Header</em> with <a href="http://example.com">markup</a>.</h1>' + >>> print md + <h1 id="some-header-with-markup">Some <em>Header</em> with <a href="http://example.com">markup</a>.</h1> Turn off auto generated IDs: @@ -46,8 +49,9 @@ Turn off auto generated IDs: ... # Some Header ... # Another Header''' >>> md = markdown.markdown(text, ['headerid(forceid=False)']) - >>> md - u'<h1>Some Header</h1>\\n<h1>Another Header</h1>' + >>> print md + <h1>Some Header</h1> + <h1>Another Header</h1> Use with MetaData extension: @@ -56,8 +60,8 @@ Use with MetaData extension: ... ... # A Header''' >>> md = markdown.markdown(text, ['headerid', 'meta']) - >>> md - u'<h2>A Header</h2>' + >>> print md + <h2>A Header</h2> Copyright 2007-2011 [Waylan Limberg](http://achinghead.com/). diff --git a/markdown/extensions/meta.py b/markdown/extensions/meta.py index 8983fc8..a3407da 100644 --- a/markdown/extensions/meta.py +++ b/markdown/extensions/meta.py @@ -17,17 +17,18 @@ Basic Usage: ... The body. This is paragraph one. ... ''' >>> md = markdown.Markdown(['meta']) - >>> md.convert(text) - u'<p>The body. This is paragraph one.</p>' - >>> md.Meta + >>> print md.convert(text) + <p>The body. This is paragraph one.</p> + >>> print md.Meta {u'blank_data': [u''], u'author': [u'Waylan Limberg', u'John Doe'], u'title': [u'A Test Doc.']} Make sure text without Meta Data still works (markdown < 1.6b returns a <p>). >>> text = ' Some Code - not extra lines of meta data.' >>> md = markdown.Markdown(['meta']) - >>> md.convert(text) - u'<pre><code>Some Code - not extra lines of meta data.\\n</code></pre>' + >>> print md.convert(text) + <pre><code>Some Code - not extra lines of meta data. + </code></pre> >>> md.Meta {} diff --git a/markdown/extensions/nl2br.py b/markdown/extensions/nl2br.py index bd11a74..5ba08a9 100644 --- a/markdown/extensions/nl2br.py +++ b/markdown/extensions/nl2br.py @@ -8,8 +8,9 @@ StackOverflow and GitHub flavored Markdown do. Usage: >>> import markdown - >>> markdown.markdown('line 1\\nline 2', extensions=['nl2br']) - u'<p>line 1<br />\\nline 2</p>' + >>> print markdown.markdown('line 1\\nline 2', extensions=['nl2br']) + <p>line 1<br /> + line 2</p> Copyright 2011 [Brian Neal](http://deathofagremmie.com/) diff --git a/markdown/extensions/smart_strong.py b/markdown/extensions/smart_strong.py index 4f112d6..3ed3560 100644 --- a/markdown/extensions/smart_strong.py +++ b/markdown/extensions/smart_strong.py @@ -7,15 +7,15 @@ This extention adds smarter handling of double underscores within words. Simple Usage: >>> import markdown - >>> markdown.markdown('Text with double__underscore__words.', + >>> print markdown.markdown('Text with double__underscore__words.', ... extensions=['smart_strong']) - u'<p>Text with double__underscore__words.</p>' - >>> markdown.markdown('__Strong__ still works.', + <p>Text with double__underscore__words.</p> + >>> print markdown.markdown('__Strong__ still works.', ... extensions=['smart_strong']) - u'<p><strong>Strong</strong> still works.</p>' - >>> markdown.markdown('__this__works__too__.', + <p><strong>Strong</strong> still works.</p> + >>> print markdown.markdown('__this__works__too__.', ... extensions=['smart_strong']) - u'<p><strong>this__works__too</strong>.</p>' + <p><strong>this__works__too</strong>.</p> Copyright 2011 [Waylan Limberg](http://achinghead.com) diff --git a/markdown/extensions/wikilinks.py b/markdown/extensions/wikilinks.py index cf4b633..af43bba 100644 --- a/markdown/extensions/wikilinks.py +++ b/markdown/extensions/wikilinks.py @@ -11,22 +11,22 @@ Basic usage: >>> import markdown >>> text = "Some text with a [[WikiLink]]." >>> html = markdown.markdown(text, ['wikilinks']) - >>> html - u'<p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p>' + >>> print html + <p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p> Whitespace behavior: - >>> markdown.markdown('[[ foo bar_baz ]]', ['wikilinks']) - u'<p><a class="wikilink" href="/foo_bar_baz/">foo bar_baz</a></p>' - >>> markdown.markdown('foo [[ ]] bar', ['wikilinks']) - u'<p>foo bar</p>' + >>> print markdown.markdown('[[ foo bar_baz ]]', ['wikilinks']) + <p><a class="wikilink" href="/foo_bar_baz/">foo bar_baz</a></p> + >>> print markdown.markdown('foo [[ ]] bar', ['wikilinks']) + <p>foo bar</p> To define custom settings the simple way: - >>> markdown.markdown(text, + >>> print markdown.markdown(text, ... ['wikilinks(base_url=/wiki/,end_url=.html,html_class=foo)'] ... ) - u'<p>Some text with a <a class="foo" href="/wiki/WikiLink.html">WikiLink</a>.</p>' + <p>Some text with a <a class="foo" href="/wiki/WikiLink.html">WikiLink</a>.</p> Custom settings the complex way: @@ -37,8 +37,8 @@ Custom settings the complex way: ... ('end_url', '.html'), ... ('html_class', '') ]}, ... safe_mode = True) - >>> md.convert(text) - u'<p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p>' + >>> print md.convert(text) + <p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p> Use MetaData with mdx_meta.py (Note the blank html_class in MetaData): @@ -48,13 +48,13 @@ Use MetaData with mdx_meta.py (Note the blank html_class in MetaData): ... ... Some text with a [[WikiLink]].""" >>> md = markdown.Markdown(extensions=['meta', 'wikilinks']) - >>> md.convert(text) - u'<p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p>' + >>> print md.convert(text) + <p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p> MetaData should not carry over to next document: - >>> md.convert("No [[MetaData]] here.") - u'<p>No <a class="wikilink" href="/MetaData/">MetaData</a> here.</p>' + >>> print md.convert("No [[MetaData]] here.") + <p>No <a class="wikilink" href="/MetaData/">MetaData</a> here.</p> Define a custom URL builder: @@ -62,8 +62,8 @@ Define a custom URL builder: ... return '/bar/' >>> md = markdown.Markdown(extensions=['wikilinks'], ... extension_configs={'wikilinks' : [('build_url', my_url_builder)]}) - >>> md.convert('[[foo]]') - u'<p><a class="wikilink" href="/bar/">foo</a></p>' + >>> print md.convert('[[foo]]') + <p><a class="wikilink" href="/bar/">foo</a></p> From the command line: |