summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew G. Morgan <morgan@kernel.org>2020-07-11 17:17:28 -0700
committerAndrew G. Morgan <morgan@kernel.org>2020-07-11 17:19:52 -0700
commita83d142eca3f5852fa36ebebc7f9351b90ba26d3 (patch)
treed6e28318eff6ac576d54f9355c6c82c8a2795a83
parentcae0e745e07cf8f4cabea9e293642f1e025f7eef (diff)
downloadlibcap2-a83d142eca3f5852fa36ebebc7f9351b90ba26d3.tar.gz
More experiments with markdown as a representation for the man pages.
I'm leaning towards pandoc instead of man-to-md. Mostly because it has greater coverage in terms of supported formats. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r--doc/md2html.lua6
-rwxr-xr-xdoc/mkmd.sh16
2 files changed, 16 insertions, 6 deletions
diff --git a/doc/md2html.lua b/doc/md2html.lua
new file mode 100644
index 0000000..c2677d8
--- /dev/null
+++ b/doc/md2html.lua
@@ -0,0 +1,6 @@
+-- This is the links-to-html.lua example from stackoverflow:
+-- https://stackoverflow.com/questions/40993488/convert-markdown-links-to-html-with-pandoc
+function Link(el)
+ el.target = string.gsub(el.target, "%.md", ".html")
+ return el
+end
diff --git a/doc/mkmd.sh b/doc/mkmd.sh
index 10a2048..af835d5 100755
--- a/doc/mkmd.sh
+++ b/doc/mkmd.sh
@@ -1,10 +1,14 @@
#!/bin/bash
#
# Handy script to rebuild the markdown version of the man pages.
-# This uses https://github.com/mle86/man-to-md if it is installed.
+# This uses pandoc if it is installed.
+#
+# For rendering the md, we can use a different command:
+#
+# cd md; for x in *.md ; do pandoc -s $x --metadata pagetitle="${x%.md}" -o ${x%.md}.html --lua-filter=../md2html.lua ; done
-if [[ -z "$(which man-to-md)" ]]; then
- echo "man-to-md not found - skipping conversion"
+if [[ -z "$(which pandoc)" ]]; then
+ echo "pandoc not found - skipping conversion"
exit 0
fi
@@ -37,7 +41,7 @@ function do_page () {
return
fi
- man-to-md -f < "${m}" | sed -e 's/^\*\*\([^\*]\+\)\*\*(\([138]\+\))/[\1(\2)](\1-\2.md)/' > "${outdir}/${base}-${sect}.md"
+ pandoc -f man -t markdown < "${m}" | sed 's/\*\*\([^*]\+\)\*\*(\([138]\+\))/[\1(\2)](\1-\2.md)/g' > "${outdir}/${base}-${sect}.md"
echo "* [${base}(${sect})](${base}-${sect}.md)" >> "${index}"
}
@@ -69,7 +73,7 @@ for libcap.
## MD page generation
-These official man pages for libcap were converted to markdown using
-[man-to-md](https://github.com/mle86/man-to-md).
+These official man pages for libcap and libpsx were converted to
+markdown using [pandoc](https://pandoc.org).
EOF