update `pandoc` data dir

master
urosm 2024-04-22 23:44:54 +02:00
parent 3eaae9c7a2
commit 9b221c50ca
3 changed files with 19 additions and 27 deletions

View File

@ -3,19 +3,15 @@ local read, json = pandoc.read, pandoc.json
assert(#arg > 1, "\n" ..
"[ERROR] usage: pandoc lua links.lua <destination file> <input file>...")
local destination_filepath
local input_filepaths = {}
local input_filepaths_keys = {}
for _, option in ipairs(arg) do
if destination_filepath == nil then
destination_filepath = option
else
table.insert(input_filepaths, option)
input_filepaths_keys[option] = {}
end
local destination_filepath = arg[1]
local filepaths_arr = {}
local filepaths_map = {}
for i = 2, #arg do
table.insert(filepaths_arr, arg[i])
filepaths_map[arg[i]] = {}
end
for _,filepath in ipairs(input_filepaths) do
for _,filepath in ipairs(filepaths_arr) do
local f = assert(io.open(filepath), "\n" ..
"[ERROR] could not open " .. filepath)
local data = f:read("a")
@ -23,15 +19,15 @@ for _,filepath in ipairs(input_filepaths) do
local visited_map = {}
read(data):walk({
Link = function (link)
if not input_filepaths_keys[link.target] then return end
if not filepaths_map[link.target] then return end
if visited_map[link.target] then return end
table.insert(input_filepaths_keys[filepath], link.target)
table.insert(filepaths_map[filepath], link.target)
visited_map[link.target] = true
end
})
end
local data = json.encode(input_filepaths_keys)
local data = json.encode(filepaths_map)
local f = io.open(destination_filepath)
if f == nil or f:read("a") ~= data then
local f = assert(io.open(destination_filepath, "w"), "\n" ..

View File

@ -3,17 +3,13 @@ local json = pandoc.json
assert(#arg > 1, "\n" ..
"[ERROR] usage: pandoc lua sitemap.lua <destination file> <input file>...")
local destination_filepath
local input_filepaths = {}
for _, option in ipairs(arg) do
if destination_filepath == nil then
destination_filepath = option
else
table.insert(input_filepaths, option)
end
local destination_filepath = arg[1]
local filepaths_arr = {}
for i = 2, #arg do
table.insert(filepaths_arr, arg[i])
end
local data = json.encode(input_filepaths)
local data = json.encode(filepaths_arr)
local f = io.open(destination_filepath)
if f == nil or f:read("a") ~= data then
local f = assert(io.open(destination_filepath, "w"), "\n" ..

View File

@ -29,11 +29,11 @@ $endif$
$endfor$
$if(sitemap)$
<nav class="sitemap">
<h1><a href="/">bavbavhaus.net/sitemap</a></h1>
<h1><a href="/">bavbavhaus.net</a></h1>
<ul>
$for(sitemap)$
<li>$it$</li>
$endfor$
$for(sitemap)$
<li>$it$</li>
$endfor$
</ul>
</nav>
$endif$