Skip to content

Commit e32e597

Browse files
committed
docs: Fix generation of TeXLive versions table
1 parent c2f96a8 commit e32e597

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

docs/filters/texlive-versions.lua

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,61 @@
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
16+
end
117
function CodeBlock (cb)
218
if not cb.classes:includes 'texlive-versions' then
319
return nil
420
end
521

6-
-- get simple table from file
7-
local fh = io.open 'versions.md'
8-
local versions = pandoc.utils.to_simple_table(
9-
-- make things more presentable by adding commas
10-
pandoc.read(fh:read 'a').blocks[1]:walk{
11-
Space = function (_) return {pandoc.Str ',', pandoc.Space()} end
12-
}
13-
)
14-
-- remove alpine and ubuntu columns
15-
for _, k in ipairs{'aligns', 'widths', 'headers'} do
16-
versions[k]:remove(4) -- ubuntu
17-
versions[k]:remove(3) -- alpine
18-
end
19-
for _, row in ipairs(versions.rows) do
20-
row:remove(4) -- ubuntu
21-
row:remove(3) -- alpine
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)
2229
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)
2340

24-
return pandoc.utils.from_simple_table(versions)
41+
local rows = pandoc.List()
42+
for release_number in release_numbers:iter() do
43+
local release = config.release[release_number]
44+
local tags = tag_strings(release['version-tags'])
45+
local row = {
46+
pandoc.Blocks(release_number),
47+
pandoc.Blocks{tags},
48+
pandoc.Blocks(release.addon.latex.texlive)
49+
}
50+
rows:insert(row)
51+
end
52+
return pandoc.utils.from_simple_table(
53+
pandoc.SimpleTable(
54+
'TeXLive version that are shipped in the images.',
55+
{pandoc.AlignDefault, pandoc.AlignDefault, pandoc.AlignDefault},
56+
{0, 0, 0},
57+
{{'pandoc version'}, {'tags'}, {'TeXLive version'}},
58+
rows
59+
)
60+
)
2561
end

0 commit comments

Comments
 (0)