Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active April 9, 2021 12:34
Show Gist options
  • Save cderv/d2875c85b6eef975e8641fac7b4e756f to your computer and use it in GitHub Desktop.
Save cderv/d2875c85b6eef975e8641fac7b4e756f to your computer and use it in GitHub Desktop.
Check Pandoc Version in LUA for 2.1+
--[[
This function tests the pandoc version againt a target version
For Pandoc 2.7.3, PANDOC_VERSION >= "2.8" would be enough but before 2.7.3
it is a table object
]]
local function pandocAvailable(target)
-- this function only work for Pandoc 2.1 and above. It returns false is not
if not PANDOC_VERSION then return false end
assert(target, "No target version specified in pandocAvailable.")
-- checking each version number
-- EPOCH.MAJOR.MINOR.PATCH (https://pvp.haskell.org)
for i = 1,4 do
-- some versions do not have all numbers
if not PANDOC_VERSION[i] or not target[i] then break end
if PANDOC_VERSION[i] < target[i] then return false end
if PANDOC_VERSION[i] > target[i] then return true end
end
return true
end
@cderv
Copy link
Author

cderv commented Apr 9, 2021

Thanks for the tip about Pandoc version scheme @tarleb!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment