Posodobitev wordcount filtra in privzetih filtrov za html

master
urosm 2024-10-01 16:07:05 +02:00
parent d28062ffbe
commit fe2aed6c05
2 changed files with 8 additions and 22 deletions

View File

@ -9,4 +9,5 @@ filters:
- localize_quotes.lua
- resolve_internal_links.lua
- link_headings.lua
- wordcount.lua
...

View File

@ -2,28 +2,13 @@
words = 0
wordcount = {
Str = function(el)
-- we don't count a word if it's entirely punctuation:
if el.text:match("%P") then
words = words + 1
end
end,
Code = function(el)
_,n = el.text:gsub("%S+","")
words = words + n
end,
CodeBlock = function(el)
_,n = el.text:gsub("%S+","")
words = words + n
end
}
function Pandoc(el)
-- skip metadata, just count body:
el.blocks:walk(wordcount)
print(words .. " words in body")
os.exit(0)
el.blocks:walk({
Str = function(el)
if el.text:match("%p") then return end
words = words + 1
end
})
print("[INFO] Wordcount: " .. words .. " words in body")
end