24 lines
498 B
Lua
24 lines
498 B
Lua
|
function file_exists(name)
|
||
|
local f=io.open(name,"r")
|
||
|
if f~=nil then io.close(f) return true else return false end
|
||
|
end
|
||
|
|
||
|
|
||
|
local function countWords()
|
||
|
local rawText = pandoc.pipe("pdftotext", {"output.pdf", "-"}, "")
|
||
|
return pandoc.pipe("wc", {"-w"}, rawText)
|
||
|
end
|
||
|
|
||
|
|
||
|
return {
|
||
|
{
|
||
|
Meta = function(meta)
|
||
|
if file_exists("output.pdf") then
|
||
|
meta["wordcount"] = countWords()
|
||
|
meta["secondpass"] = true
|
||
|
end
|
||
|
return meta
|
||
|
end,
|
||
|
}
|
||
|
}
|