Skip to content

Commit c256e03

Browse files
committed
docs: Fix creation of "supported tags" section
1 parent 66482a3 commit c256e03

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

docs/filters/supported-tags.lua

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
1-
local function tag_strings (row)
2-
return row[2][1].content:walk{
3-
Space = function (_) return {pandoc.Str',', pandoc.Space()} end,
4-
Str = function (str) return pandoc.Code(str.text) end,
5-
}
1+
local io = require 'io'
2+
local pandoc = require 'pandoc'
3+
local utils = require 'pandoc.utils'
4+
local stringify = utils.stringify
5+
6+
local function tag_strings (tags)
7+
local result = pandoc.List{}
8+
9+
for i = 1, #tags do
10+
result:insert(pandoc.Code(stringify(tags[i])))
11+
if i < #tags then
12+
result:extend{pandoc.Str ',', pandoc.Space()}
13+
end
14+
end
15+
return result
616
end
717
function CodeBlock (cb)
818
if not cb.classes:includes 'supported-tags' then
919
return nil
1020
end
1121

12-
-- get simple table from file
13-
local fh = io.open 'versions.md'
14-
local versions = pandoc.utils.to_simple_table(
15-
pandoc.read(fh:read 'a').blocks[1]
16-
)
22+
-- get YAML as metadata from file
23+
local fh = io.open 'config.yaml'
24+
local config = pandoc.read(fh:read 'a').meta
25+
26+
local release_numbers = pandoc.List{}
27+
for version in pairs(config.release) do
28+
release_numbers:insert(version)
29+
end
30+
release_numbers:sort(function (a, b)
31+
if a == 'main' then
32+
return true
33+
elseif b == 'main' then
34+
return false
35+
end
36+
local _, av = pcall(pandoc.types.Version, a)
37+
local _, bv = pcall(pandoc.types.Version, b)
38+
return av > bv
39+
end)
1740

1841
local result = pandoc.List()
19-
for i, row in ipairs(versions.rows) do
20-
local tags = tag_strings(row)
42+
for release_number in release_numbers:iter() do
43+
local release = config.release[release_number]
44+
local tags = tag_strings(release['version-tags'])
2145
result:insert{pandoc.Plain(tags)}
2246
end
2347
return pandoc.BulletList(result)

0 commit comments

Comments
 (0)