Last active
April 9, 2021 12:34
-
-
Save cderv/d2875c85b6eef975e8641fac7b4e756f to your computer and use it in GitHub Desktop.
Check Pandoc Version in LUA for 2.1+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the tip about Pandoc version scheme @tarleb!