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