Skip to content

Commit

Permalink
Merge pull request Python-Markdown#317 from mitya57/doctests
Browse files Browse the repository at this point in the history
Python 3.4 and fixes for doctests
  • Loading branch information
waylan committed Jun 17, 2014
2 parents a6307cd + 580712a commit 51857fd
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 38 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ env:
- TOXENV=py27
- TOXENV=py32
- TOXENV=py33
- TOXENV=py34
before_install:
- sudo apt-get update -qq
- sudo apt-get install libtidy-0.99-0
Expand Down
2 changes: 1 addition & 1 deletion markdown/extensions/abbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
... *[ABBR]: Abbreviation
... *[REF]: Abbreviation Reference
... """
>>> print markdown.markdown(text, ['abbr'])
>>> 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
Expand Down
20 changes: 10 additions & 10 deletions markdown/extensions/fenced_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
... ~~~
... '''
>>> html = markdown.markdown(text, extensions=['fenced_code'])
>>> print html
>>> 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):
>>> print markdown.markdown(text, extensions=['fenced_code'], safe_mode='replace')
>>> 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>
Expand All @@ -32,7 +32,7 @@
...
... ~~~~
... ~~~~~~~~'''
>>> print markdown.markdown(text, extensions=['fenced_code'])
>>> print(markdown.markdown(text, extensions=['fenced_code']))
<pre><code>
~~~~
</code></pre>
Expand All @@ -43,7 +43,7 @@
... ~~~~{.python}
... # Some python code
... ~~~~'''
>>> print markdown.markdown(text, extensions=['fenced_code'])
>>> print(markdown.markdown(text, extensions=['fenced_code']))
<pre><code class="python"># Some python code
</code></pre>
Expand All @@ -54,7 +54,7 @@
... # Arbitrary code
... ~~~~~ # these tildes will not close the block
... `````'''
>>> print markdown.markdown(text, extensions=['fenced_code'])
>>> print(markdown.markdown(text, extensions=['fenced_code']))
<pre><code># Arbitrary code
~~~~~ # these tildes will not close the block
</code></pre>
Expand All @@ -67,11 +67,11 @@
... line 2
... line 3
... ```'''
>>> print markdown.markdown(text, extensions=['codehilite', 'fenced_code'])
<pre><code><span class="hilight">line 1</span>
line 2
<span class="hilight">line 3</span>
</code></pre>
>>> print(markdown.markdown(text, extensions=['codehilite', 'fenced_code']))
<div class="codehilite"><pre><span class="hll"><span class="n">line</span> <span class="mi">1</span>
</span><span class="n">line</span> <span class="mi">2</span>
<span class="hll"><span class="n">line</span> <span class="mi">3</span>
</span></pre></div>
Copyright 2007-2008 [Waylan Limberg](http://achinghead.com/).
Expand Down
12 changes: 6 additions & 6 deletions markdown/extensions/headerid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
>>> import markdown
>>> text = "# Some Header #"
>>> md = markdown.markdown(text, ['headerid'])
>>> print md
>>> print(md)
<h1 id="some-header">Some Header</h1>
All header IDs are unique:
Expand All @@ -19,7 +19,7 @@
... #Header
... #Header'''
>>> md = markdown.markdown(text, ['headerid'])
>>> print md
>>> print(md)
<h1 id="header">Header</h1>
<h1 id="header_1">Header</h1>
<h1 id="header_2">Header</h1>
Expand All @@ -30,15 +30,15 @@
... #Some Header
... ## Next Level'''
>>> md = markdown.markdown(text, ['headerid(level=3)'])
>>> print md
>>> 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'])
>>> print md
>>> 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:
Expand All @@ -47,7 +47,7 @@
... # Some Header
... # Another Header'''
>>> md = markdown.markdown(text, ['headerid(forceid=False)'])
>>> print md
>>> print(md)
<h1>Some Header</h1>
<h1>Another Header</h1>
Expand All @@ -58,7 +58,7 @@
...
... # A Header'''
>>> md = markdown.markdown(text, ['headerid', 'meta'])
>>> print md
>>> print(md)
<h2>A Header</h2>
Copyright 2007-2011 [Waylan Limberg](http://achinghead.com/).
Expand Down
8 changes: 4 additions & 4 deletions markdown/extensions/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
... The body. This is paragraph one.
... '''
>>> md = markdown.Markdown(['meta'])
>>> print md.convert(text)
>>> 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.']}
>>> print(md.Meta) # doctest: +SKIP
{'blank_data': [''], 'author': ['Waylan Limberg', 'John Doe'], 'title': ['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'])
>>> print md.convert(text)
>>> print(md.convert(text))
<pre><code>Some Code - not extra lines of meta data.
</code></pre>
>>> md.Meta
Expand Down
2 changes: 1 addition & 1 deletion markdown/extensions/nl2br.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Usage:
>>> import markdown
>>> print markdown.markdown('line 1\\nline 2', extensions=['nl2br'])
>>> print(markdown.markdown('line 1\\nline 2', extensions=['nl2br']))
<p>line 1<br />
line 2</p>
Expand Down
12 changes: 6 additions & 6 deletions markdown/extensions/smart_strong.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
Simple Usage:
>>> import markdown
>>> print markdown.markdown('Text with double__underscore__words.',
... extensions=['smart_strong'])
>>> print(markdown.markdown('Text with double__underscore__words.',
... extensions=['smart_strong']))
<p>Text with double__underscore__words.</p>
>>> print markdown.markdown('__Strong__ still works.',
... extensions=['smart_strong'])
>>> print(markdown.markdown('__Strong__ still works.',
... extensions=['smart_strong']))
<p><strong>Strong</strong> still works.</p>
>>> print markdown.markdown('__this__works__too__.',
... extensions=['smart_strong'])
>>> print(markdown.markdown('__this__works__too__.',
... extensions=['smart_strong']))
<p><strong>this__works__too</strong>.</p>
Copyright 2011
Expand Down
18 changes: 9 additions & 9 deletions markdown/extensions/wikilinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
>>> import markdown
>>> text = "Some text with a [[WikiLink]]."
>>> html = markdown.markdown(text, ['wikilinks'])
>>> print html
>>> print(html)
<p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p>
Whitespace behavior:
>>> print markdown.markdown('[[ foo bar_baz ]]', ['wikilinks'])
>>> 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'])
>>> print(markdown.markdown('foo [[ ]] bar', ['wikilinks']))
<p>foo bar</p>
To define custom settings the simple way:
>>> print markdown.markdown(text,
>>> print(markdown.markdown(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>
Custom settings the complex way:
Expand All @@ -35,7 +35,7 @@
... ('end_url', '.html'),
... ('html_class', '') ]},
... safe_mode = True)
>>> print md.convert(text)
>>> 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):
Expand All @@ -46,12 +46,12 @@
...
... Some text with a [[WikiLink]]."""
>>> md = markdown.Markdown(extensions=['meta', 'wikilinks'])
>>> print md.convert(text)
>>> 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:
>>> print md.convert("No [[MetaData]] here.")
>>> print(md.convert("No [[MetaData]] here."))
<p>No <a class="wikilink" href="/MetaData/">MetaData</a> here.</p>
Define a custom URL builder:
Expand All @@ -60,7 +60,7 @@
... return '/bar/'
>>> md = markdown.Markdown(extensions=['wikilinks'],
... extension_configs={'wikilinks' : [('build_url', my_url_builder)]})
>>> print md.convert('[[foo]]')
>>> print(md.convert('[[foo]]'))
<p><a class="wikilink" href="/bar/">foo</a></p>
From the command line:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py31, py32, py33
envlist = py26, py27, py31, py32, py33, py34

[testenv]
downloadcache = {toxworkdir}/cache
Expand Down

0 comments on commit 51857fd

Please sign in to comment.