update `pandoc` data dir
parent
76d23194ab
commit
92f990dad4
|
@ -1,8 +1,11 @@
|
|||
---
|
||||
from: markdown
|
||||
toc: true
|
||||
citeproc: true
|
||||
csl: chicago-fullnote-sl
|
||||
filters:
|
||||
- localize-quotes.lua
|
||||
- update_internal_targets.lua
|
||||
- insert_links.lua
|
||||
to: html
|
||||
...
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
local l = require("pandoc.logging")
|
||||
local json = pandoc.json
|
||||
-- local l = require("pandoc.logging")
|
||||
local MetaList = pandoc.MetaList
|
||||
local RawBlock = pandoc.RawBlock
|
||||
|
||||
|
@ -8,23 +7,18 @@ os.setlocale("C")
|
|||
|
||||
return {
|
||||
{ Meta = function (meta)
|
||||
local input_filepath = PANDOC_STATE["input_files"][1]
|
||||
local links_filepath = meta["links-file"] or "links.json"
|
||||
local partials_dirpath = meta["partials-dir"] or "partials"
|
||||
local f = assert(io.open(links_filepath), "\n" ..
|
||||
"[ERROR] could not open " .. links_filepath)
|
||||
local links = json.decode(f:read("a"))
|
||||
f:close()
|
||||
if not links[input_filepath] then return end
|
||||
local nextlinks = MetaList({})
|
||||
for _,filepath in ipairs(links[input_filepath]) do
|
||||
local partial_filepath = filepath:gsub("^(.+)%.md$", partials_dirpath .. "/%1.html")
|
||||
local f = assert(io.open(partial_filepath), "\n" ..
|
||||
"[ERROR] could not open " .. partial_filepath)
|
||||
nextlinks:insert(RawBlock("html5", f:read("a")))
|
||||
::continue::
|
||||
if not meta["links"] then return end
|
||||
if type(meta["links"]) == "string" then
|
||||
meta["links"] = { meta["links"] }
|
||||
end
|
||||
meta["nextlinks"] = nextlinks
|
||||
local links = MetaList({})
|
||||
for _,fp in ipairs(meta["links"]) do
|
||||
local f = assert(io.open(fp), "\n" ..
|
||||
"[ERROR] could not open " .. fp .. " for reading.")
|
||||
links:insert(RawBlock("html5", f:read("a")))
|
||||
f:close()
|
||||
end
|
||||
meta["links"] = links
|
||||
return meta
|
||||
end }
|
||||
}
|
||||
|
|
|
@ -6,23 +6,7 @@ os.setlocale("C")
|
|||
|
||||
TARGET_PATTERN = { "^(.+)%.md", "%1.html" }
|
||||
|
||||
local function file_exists(filepath)
|
||||
local f = io.open(filepath)
|
||||
if f ~= nil then
|
||||
f:close()
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{ Meta = function (meta)
|
||||
if meta["url"] then
|
||||
meta["url"] = meta["url"]:gsub(table.unpack(TARGET_PATTERN))
|
||||
end
|
||||
return meta
|
||||
end },
|
||||
{ Link = function (link)
|
||||
if link.target:find(TARGET_PATTERN[1]) then
|
||||
link.target = link.target:gsub(table.unpack(TARGET_PATTERN))
|
||||
|
|
|
@ -1,37 +1,31 @@
|
|||
-- local l = require("pandoc.logging")
|
||||
local read, json = pandoc.read, pandoc.json
|
||||
local read = pandoc.read
|
||||
|
||||
assert(#arg > 1, "\n" ..
|
||||
"[ERROR] usage: pandoc lua links.lua <destination file> <input file>...")
|
||||
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]] = {}
|
||||
assert(#arg > 0, "\n" ..
|
||||
"[ERROR] usage: pandoc lua links.lua [--follow] <file>...")
|
||||
|
||||
local should_follow = arg[1] == "--follow" and true or false
|
||||
|
||||
local function file_exists (fp)
|
||||
local f = io.open(fp)
|
||||
if f ~= nil then f:close() return true else return false end
|
||||
end
|
||||
|
||||
for _,filepath in ipairs(filepaths_arr) do
|
||||
local f = assert(io.open(filepath), "\n" ..
|
||||
"[ERROR] could not open " .. filepath)
|
||||
local visited = {}
|
||||
local function find_links (fp)
|
||||
local f = assert(io.open(fp), "\n" ..
|
||||
"[ERROR] could not open " .. fp .. " for reading.")
|
||||
local data = f:read("a")
|
||||
f:close()
|
||||
local visited_map = {}
|
||||
read(data):walk({
|
||||
Link = function (link)
|
||||
if not filepaths_map[link.target] then return end
|
||||
if visited_map[link.target] then return end
|
||||
table.insert(filepaths_map[filepath], link.target)
|
||||
visited_map[link.target] = true
|
||||
end
|
||||
})
|
||||
read(data):walk({ Link = function (link)
|
||||
if not file_exists(link.target) then return end
|
||||
if visited[link.target] then return end
|
||||
visited[link.target] = true
|
||||
io.write(link.target .. "\n")
|
||||
if should_follow then find_links(link.target) end
|
||||
end })
|
||||
end
|
||||
|
||||
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" ..
|
||||
"[ERROR] could not open " .. destination_filepath .. " for writing")
|
||||
f:write(data)
|
||||
f:close()
|
||||
for i = should_follow and 2 or 1, #arg do
|
||||
find_links(arg[i])
|
||||
end
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
-- local l = require("pandoc.logging")
|
||||
local json = pandoc.json
|
||||
|
||||
assert(#arg > 1, "\n" ..
|
||||
"[ERROR] usage: pandoc lua sitemap.lua <destination file> <input file>...")
|
||||
local destination_filepath = arg[1]
|
||||
local filepaths_arr = {}
|
||||
for i = 2, #arg do
|
||||
table.insert(filepaths_arr, arg[i])
|
||||
end
|
||||
|
||||
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" ..
|
||||
"[ERROR] could not open " .. destination_filepath .. " for writing")
|
||||
f:write(data)
|
||||
f:close()
|
||||
end
|
|
@ -3,7 +3,7 @@
|
|||
xmlns="http://www.w3.org/1999/xhtml"
|
||||
lang="$if(lang)$$lang$$else$sl$endif$"
|
||||
xml:lang="$if(lang)$$lang$$else$sl$endif$"
|
||||
$if(dir)$ dir="$dir$"$endif$>
|
||||
$if(dir)$dir="$dir$"$endif$>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
|
@ -19,24 +19,31 @@ $endif$
|
|||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article>
|
||||
${ bavbavhaus.net.inline.html5() }
|
||||
<article class="post">
|
||||
<header>
|
||||
<h1>
|
||||
<a href="index.html">bavbavhaus.net</a>
|
||||
/
|
||||
<a href="$url$">$if(title)$$title$$else$$pagetitle$$endif$</a></h1>
|
||||
$if(abstract)$
|
||||
$abstract$
|
||||
$endif$
|
||||
</header>
|
||||
$if(toc)$
|
||||
<nav>
|
||||
$if(toc-title)$
|
||||
<h2>$toc-title$</h2>
|
||||
$endif$
|
||||
$table-of-contents$
|
||||
</nav>
|
||||
$endif$
|
||||
$body$
|
||||
</article>
|
||||
$for(nextlinks)$
|
||||
<article class="nextlink">
|
||||
$for(links)$
|
||||
<article class="post link">
|
||||
$it$
|
||||
</article>
|
||||
$endfor$
|
||||
$if(sitemap)$
|
||||
<nav class="sitemap">
|
||||
<h1><a href="/">bavbavhaus.net</a></h1>
|
||||
<ul>
|
||||
$for(sitemap)$
|
||||
<li>$it$</li>
|
||||
$endfor$
|
||||
</ul>
|
||||
</nav>
|
||||
$endif$
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<h1 class="title"><a href="$url$">$if(title)$$title$$else$$pagetitle$$endif$</a></h1>
|
||||
<header>
|
||||
<h1><a href="$url$">$if(title)$$title$$else$$pagetitle$$endif$</a></h1>
|
||||
$if(abstract)$
|
||||
$abstract$
|
||||
$endif$
|
||||
</header>
|
||||
$if(toc)$
|
||||
<nav class="toc">
|
||||
<nav>
|
||||
$if(toc-title)$
|
||||
<h2>$toc-title$</h2>
|
||||
$endif$
|
||||
|
|
Loading…
Reference in New Issue