From: Armin Ronacher Date: Sat, 3 May 2008 17:04:02 +0000 (+0200) Subject: changed wordcount filter once more X-Git-Tag: 2.0rc1~104 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b9d8070b73794f49223ea3ce0d312cdd63b79ec5;p=jinja2.git changed wordcount filter once more --HG-- branch : trunk --- diff --git a/jinja2/filters.py b/jinja2/filters.py index 5017156..ec0186c 100644 --- a/jinja2/filters.py +++ b/jinja2/filters.py @@ -20,6 +20,7 @@ from jinja2.exceptions import FilterArgumentError _striptags_re = re.compile(r'(|<[^>]*>)') +_word_re = re.compile(r'\w+') def contextfilter(f): @@ -373,7 +374,7 @@ def do_wordwrap(s, width=79, break_long_words=True): def do_wordcount(s): """Count the words in that string.""" - return len(s.split()) + return len(_word_re.findall(s)) def do_int(value, default=0):