Posodobitev wordcount filtra in privzetih filtrov za html
parent
d28062ffbe
commit
fe2aed6c05
|
@ -9,4 +9,5 @@ filters:
|
|||
- localize_quotes.lua
|
||||
- resolve_internal_links.lua
|
||||
- link_headings.lua
|
||||
- wordcount.lua
|
||||
...
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue