Skip to content

Commit

Permalink
v0.10.2 Bugfix for the pandoc version
Browse files Browse the repository at this point in the history
* The previous comparison for 'PANDOC_VERSION' did not work in some versions.
* A simple method was introduced in pandoc 2.7.3 to compare versions, but we cannot ensure that this version is always available.
* Thus, a new function was introduced to compare the versions, without requiring the 2.7.3 or higher.
  • Loading branch information
rchaput committed Jan 29, 2022
1 parent 82b1fd1 commit 7534d9e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: acronymsdown
Type: Package
Title: Acronyms and Glossaries Support for RMarkdown
Version: 0.10.1
Version: 0.10.2
Author: Remy Chaput
Maintainer: remy chaput <rchaput.pro@gmail.com>
Description: Adds support for list of acronyms (or glossaries) for RMarkdown
Expand Down
24 changes: 23 additions & 1 deletion inst/parse-acronyms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,36 @@ function warn(...)
io.stderr:write("[WARNING][acronymsdown] ", msg, "\n")
end

-- Helper function to determine pandoc's version.
-- `version` must be a table of numbers, e.g., `{2, 17, 0, 1}`
function isAtLeastVersion(version)
-- `PANDOC_VERSION` exists since 2.1, but we never know...
if PANDOC_VERSION == nil then
return false
end
-- Loop up over the components
-- e.g., `2.17.0.1` => [0]=2, [1]=17, [2]=0, [3]=1
for k, v in ipairs(version) do
if PANDOC_VERSION[k] == nil or PANDOC_VERSION[k] < version[k] then
-- Examples: 2.17 < 2.17.0.1, or 2.16 < 2.17
return false
elseif PANDOC_VERSION[k] > version[k] then
-- Example: 2.17 > 2.16.2 (we do not need to check the next!)
return true
end
end
-- At this point, all components are equal
return true
end


-- Helper function to determine whether a metadata field is a list.
function isMetaList(field)
-- We want to know whether we have multiple values (MetaList).
-- Pandoc 2.17 introduced a compatibility-breaking change for this:
-- the `.tag` is no longer present in >= 2.17 ;
-- the `pandoc.utils.type` function is only available in >= 2.17
if PANDOC_VERSION ~= nil and tostring(PANDOC_VERSION) >= "2.17" then
if isAtLeastVersion({2, 17}) then
-- Use the new `pandoc.utils.type` function
return pandoc.utils.type(field) == "List"
else
Expand Down

0 comments on commit 7534d9e

Please sign in to comment.