From 7af553173629d8d8e36e71fbf2753dc8d6fe11d3 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 2 Aug 2011 09:23:49 -0400 Subject: 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. --- markdown/extensions/abbr.py | 4 ++-- markdown/extensions/fenced_code.py | 32 +++++++++++++++++--------------- markdown/extensions/headerid.py | 28 ++++++++++++++++------------ markdown/extensions/meta.py | 11 ++++++----- markdown/extensions/nl2br.py | 5 +++-- markdown/extensions/smart_strong.py | 12 ++++++------ markdown/extensions/wikilinks.py | 32 ++++++++++++++++---------------- 7 files changed, 66 insertions(+), 58 deletions(-) (limited to 'markdown') 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'

Some text with an ABBR and a REF. Ignore REFERENCE and ref.

' + >>> print markdown.markdown(text, ['abbr']) +

Some text with an ABBR and a REF. Ignore REFERENCE and ref.

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'

A paragraph before a fenced code block:

\\n
Fenced code block\\n
' + >>> print html +

A paragraph before a fenced code block:

+
Fenced code block
+    
Works with safe_mode also (we check this because we are using the HtmlStash): - >>> markdown.markdown(text, extensions=['fenced_code'], safe_mode='replace') - u'

A paragraph before a fenced code block:

\\n
Fenced code block\\n
' + >>> print markdown.markdown(text, extensions=['fenced_code'], safe_mode='replace') +

A paragraph before a fenced code block:

+
Fenced code block
+    
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'
\\n~~~~\\n\\n
' + >>> print markdown.markdown(text, extensions=['fenced_code']) +

+    ~~~~
+    
-Multiple blocks and language tags: +Language tags: >>> text = ''' ... ~~~~{.python} - ... block one - ... ~~~~ - ... - ... ~~~~.html - ...

block two

+ ... # Some python code ... ~~~~''' - >>> markdown.markdown(text, extensions=['fenced_code']) - u'
block one\\n
\\n\\n
<p>block two</p>\\n
' + >>> print markdown.markdown(text, extensions=['fenced_code']) +
# Some python code
+    
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'

Some Header

' + >>> print md +

Some Header

All header IDs are unique: @@ -21,8 +21,10 @@ All header IDs are unique: ... #Header ... #Header''' >>> md = markdown.markdown(text, ['headerid']) - >>> md - u'

Header

\\n

Header

\\n

Header

' + >>> print md +

Header

+

Header

+

Header

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'

Some Header

\\n

Next Level

' + >>> print md +

Some Header

+

Next Level

Works with inline markup. >>> text = '#Some *Header* with [markup](http://example.com).' >>> md = markdown.markdown(text, ['headerid']) - >>> md - u'

Some Header with markup.

' + >>> print md +

Some Header with markup.

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'

Some Header

\\n

Another Header

' + >>> print md +

Some Header

+

Another Header

Use with MetaData extension: @@ -56,8 +60,8 @@ Use with MetaData extension: ... ... # A Header''' >>> md = markdown.markdown(text, ['headerid', 'meta']) - >>> md - u'

A Header

' + >>> print md +

A Header

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'

The body. This is paragraph one.

' - >>> md.Meta + >>> print md.convert(text) +

The body. This is paragraph one.

+ >>> 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

). >>> text = ' Some Code - not extra lines of meta data.' >>> md = markdown.Markdown(['meta']) - >>> md.convert(text) - u'

Some Code - not extra lines of meta data.\\n
' + >>> print md.convert(text) +
Some Code - not extra lines of meta data.
+    
>>> 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'

line 1
\\nline 2

' + >>> print markdown.markdown('line 1\\nline 2', extensions=['nl2br']) +

line 1
+ line 2

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'

Text with double__underscore__words.

' - >>> markdown.markdown('__Strong__ still works.', +

Text with double__underscore__words.

+ >>> print markdown.markdown('__Strong__ still works.', ... extensions=['smart_strong']) - u'

Strong still works.

' - >>> markdown.markdown('__this__works__too__.', +

Strong still works.

+ >>> print markdown.markdown('__this__works__too__.', ... extensions=['smart_strong']) - u'

this__works__too.

' +

this__works__too.

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'

Some text with a WikiLink.

' + >>> print html +

Some text with a WikiLink.

Whitespace behavior: - >>> markdown.markdown('[[ foo bar_baz ]]', ['wikilinks']) - u'

foo bar_baz

' - >>> markdown.markdown('foo [[ ]] bar', ['wikilinks']) - u'

foo bar

' + >>> print markdown.markdown('[[ foo bar_baz ]]', ['wikilinks']) +

foo bar_baz

+ >>> print markdown.markdown('foo [[ ]] bar', ['wikilinks']) +

foo bar

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'

Some text with a WikiLink.

' +

Some text with a WikiLink.

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'

Some text with a WikiLink.

' + >>> print md.convert(text) +

Some text with a WikiLink.

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'

Some text with a WikiLink.

' + >>> print md.convert(text) +

Some text with a WikiLink.

MetaData should not carry over to next document: - >>> md.convert("No [[MetaData]] here.") - u'

No MetaData here.

' + >>> print md.convert("No [[MetaData]] here.") +

No MetaData here.

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'

foo

' + >>> print md.convert('[[foo]]') +

foo

From the command line: -- cgit v1.2.3