git.iko.soy/typeable/pandoc
on master help sign in
More efficient wordcount.lua example.
commite5e8350fcb3ea321efc28aaf88413677b3c97613 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 12 Nov 2017, 21:55 (9 years ago) parenta89d4aa
1 file changed+1−2
doc/lua-filters.md+1−2
doc/lua-filters.md+1−2
@@ -408,8 +408,7 @@ words = 0
408408wordcount = {
409409 Str = function(el)
410410 -- we don't count a word if it's entirely punctuation:
411− local s = el.text:gsub("%p","")
412− if #s > 0 then
411+ if el.text:match("%P") then
413412 words = words + 1
414413 end
415414 end,