From e5e8350fcb3ea321efc28aaf88413677b3c97613 Mon Sep 17 00:00:00 2001 From: John MacFarlane <jgm@berkeley.edu> Date: Sun, 12 Nov 2017 21:55:10 -0800 Subject: [PATCH] More efficient wordcount.lua example. --- doc/lua-filters.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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,