Skip to content

Commit

Permalink
Fix shortcodes doctests
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 23, 2015
1 parent 5392659 commit 7786dd2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nikola/shortcodes.py
Expand Up @@ -65,15 +65,13 @@ def apply_shortcodes(data, registry, site=None):
def _find_shortcodes(data):
"""Find start and end of shortcode markers.
>>> import pprint # (dict sorting for doctest)
>>> list(_find_shortcodes('{{% foo %}}{{% bar %}}'))
[['foo', ([], {}), 0, 11], ['bar', ([], {}), 11, 22]]
>>> list(_find_shortcodes('{{% foo bar baz=bat fee=fi fo fum %}}'))
[['foo', (['bar', 'fo', 'fum'], {'fee': 'fi', 'baz': 'bat'}), 0, 37]]
>>> list(_find_shortcodes('{{% foo bar bat=baz%}}some data{{% /foo %}}'))
>>> pprint.pprint(list(_find_shortcodes('{{% foo bar baz=bat fee=fi fo fum %}}')))
[['foo', (['bar', 'fo', 'fum'], {'baz': 'bat', 'fee': 'fi'}), 0, 37]]
>>> pprint.pprint(list(_find_shortcodes('{{% foo bar bat=baz%}}some data{{% /foo %}}')))
[['foo', (['bar'], {'bat': 'baz', 'data': 'some data'}), 0, 43]]
"""
# FIXME: this is really space-intolerant

Expand All @@ -100,7 +98,9 @@ def _find_shortcodes(data):

class SCParser(HTMLParser):
"""Parser for shortcode arguments."""

# Because shortcode attributes are HTML-like, we are abusing the HTML parser.
# TODO replace with self-contained parser

def parse_sc(self, data):
"""Parse shortcode arguments into a tuple."""
Expand Down

0 comments on commit 7786dd2

Please sign in to comment.