From b9d8070b73794f49223ea3ce0d312cdd63b79ec5 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sat, 3 May 2008 19:04:02 +0200 Subject: [PATCH] changed wordcount filter once more --HG-- branch : trunk --- jinja2/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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): -- 2.26.2