1
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tex-template-builder/second-pass.lua

24 lines
496 B
Lua

function fileExists(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 fileExists("output.pdf") then
meta["wordcount"] = countWords()
meta["secondpass"] = true
end
return meta
end,
}
}