diff --git a/doc/lua-filters.md b/doc/lua-filters.md
index cee4240c7..a5c9905ab 100644
--- a/doc/lua-filters.md
+++ b/doc/lua-filters.md
@@ -408,8 +408,7 @@ words = 0
 wordcount = {
   Str = function(el)
     -- we don't count a word if it's entirely punctuation:
-    local s = el.text:gsub("%p","")
-    if #s > 0 then
+    if el.text:match("%P") then
         words = words + 1
     end
   end,