git.iko.soy/typeable/pandoc
on master help sign in
More efficient wordcount.lua example.
e5e8350John MacFarlane
doc/lua-filters.md+1−2
@@ -408,8 +408,7 @@ words = 0
408wordcount = {
408wordcount = {
409 Str = function(el)
409 Str = function(el)
410 -- we don't count a word if it's entirely punctuation:
410 -- we don't count a word if it's entirely punctuation:
411− local s = el.text:gsub("%p","")
411+ if el.text:match("%P") then
412− if #s > 0 then
413 words = words + 1
412 words = words + 1
414 end
413 end
415 end,
414 end,