aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
Diffstat (limited to 'assets')
-rw-r--r--assets/manual/filter_man.lua73
-rw-r--r--assets/manual/filter_man_md2tex.lua31
-rw-r--r--assets/manual/man/man7advtrains/rwt.7advtrains.md9
-rw-r--r--assets/manual/man/man7advtrains/speed.7advtrains.md7
4 files changed, 87 insertions, 33 deletions
diff --git a/assets/manual/filter_man.lua b/assets/manual/filter_man.lua
new file mode 100644
index 0000000..0178462
--- /dev/null
+++ b/assets/manual/filter_man.lua
@@ -0,0 +1,73 @@
+local filters = {}
+
+local function add_filter(x)
+ table.insert(filters, x)
+end
+
+local is_latex = FORMAT:match "latex"
+local is_man = FORMAT:match "man"
+
+add_filter {
+ Pandoc = function(elem)
+ local seealso = elem.meta.seealso
+ if not seealso then
+ return
+ end
+ local blocks = elem.blocks
+ blocks:insert(pandoc.Header(1, pandoc.Str("SEE ALSO")))
+ if is_man then
+ for k, v in pairs(seealso) do
+ seealso[k] = v[1].text
+ end
+ blocks:insert(pandoc.Str(table.concat(seealso, ", ")))
+ else
+ local list = {}
+ for _, i in ipairs(seealso) do
+ local page = i[1].text
+ local pgname, pgsection = string.match(page, "^([^%)]+)%(([^%)]+)%)$")
+ local item = pandoc.Str(page)
+ if is_latex and pgname and pgsection then
+ pgname = pgname:gsub("_","\\string_")
+ item = pandoc.RawInline("latex", string.format("\\manref{%s}{%s}", pgname, pgsection))
+ end
+ table.insert(list, item)
+ end
+ blocks:insert(pandoc.BulletList(list))
+ end
+ return elem
+ end
+}
+
+if is_latex then
+ add_filter {
+ Str = function(elem)
+ if elem.tex == "Advtrains" then
+ return pandoc.RawInline("latex", "\\advtrains{}")
+ end
+ end
+ }
+ add_filter {
+ Header = function(elem)
+ local attr = {
+ class = "unnumbered unlisted",
+ }
+ return pandoc.Header(elem.level+1, elem.content, attr)
+ end,
+ }
+ add_filter {
+ Pandoc = function(elem)
+ local outputfn = PANDOC_STATE.output_file or error("No output file specified")
+ local pgname, pgsection = outputfn:match("([^%./\\]+)%.([^%.]+)%.tex$")
+ assert(pgname and pgsection, "Cannot fetch manpage name and section")
+ local blocks = elem.blocks
+ local titlestr = string.format("%s(%s)", pgname, pgsection)
+ local titleid = string.format("man:%s.%s", pgname, pgsection)
+ local titleobj = pandoc.Header(1, pandoc.Code(titlestr))
+ titleobj.identifier = titleid
+ blocks:insert(1, titleobj)
+ return elem
+ end,
+ }
+end
+
+return filters
diff --git a/assets/manual/filter_man_md2tex.lua b/assets/manual/filter_man_md2tex.lua
deleted file mode 100644
index fb21405..0000000
--- a/assets/manual/filter_man_md2tex.lua
+++ /dev/null
@@ -1,31 +0,0 @@
-return {
- {
- Str = function(elem)
- if elem.text == "Advtrains" then
- return pandoc.RawInline("latex", "\\advtrains{}")
- end
- end
- },
- {
- Header = function(elem)
- local attr = {
- class = "unnumbered unlisted",
- }
- return pandoc.Header(elem.level+1, elem.content, attr)
- end,
- },
- {
- Pandoc = function(elem)
- local outputfn = PANDOC_STATE.output_file or error("No output file specified")
- local pgname, pgsection = outputfn:match("([^%./\\]+)%.([^%.]+)%.tex$")
- assert(pgname and pgsection, "Cannot fetch manpage name and section")
- local blocks = elem.blocks
- local titlestr = string.format("%s(%s)", pgname, pgsection)
- local titleid = string.format("man:%s.%s", pgname, pgsection)
- local titleobj = pandoc.Header(1, pandoc.Code(titlestr))
- titleobj.identifier = titleid
- blocks:insert(1, titleobj)
- return elem
- end,
- },
-}
diff --git a/assets/manual/man/man7advtrains/rwt.7advtrains.md b/assets/manual/man/man7advtrains/rwt.7advtrains.md
index 5e04d5e..5e15406 100644
--- a/assets/manual/man/man7advtrains/rwt.7advtrains.md
+++ b/assets/manual/man/man7advtrains/rwt.7advtrains.md
@@ -1,4 +1,11 @@
-% RWT(7ADVTRAINS) | Advtrains Developer's Manual
+---
+title: 'RWT(7ADVTRAINS) | Advtrains Developer''s Manual'
+seealso:
+- rwt_add(3advtrains)
+- rwt_copy(3advtrains)
+- rwt_last_rpt(3advtrains)
+- rwt_now(3advtrains)
+---
# NAME
`rwt` - Advtrains railway time
diff --git a/assets/manual/man/man7advtrains/speed.7advtrains.md b/assets/manual/man/man7advtrains/speed.7advtrains.md
index bf8ed08..0977546 100644
--- a/assets/manual/man/man7advtrains/speed.7advtrains.md
+++ b/assets/manual/man/man7advtrains/speed.7advtrains.md
@@ -1,4 +1,9 @@
-% SPEED(7ADVTRAINS) | Advtrains Developer's Manual
+---
+title: 'SPEED(7ADVTRAINS) | Advtrains Developer''s Manual'
+seealso:
+- speed_lessp(3advtrains)
+- speed_set_restriction(3advtrains)
+---
# NAME
`speed` - Advtrains speed limit library