33 lines
817 B
Bash
33 lines
817 B
Bash
#!/bin/sh
|
|
set -e
|
|
command -v cmark >/dev/null || (echo "cmark: command not found" >&2 && exit 1)
|
|
test -n "$2" || (echo "Usage: $(basename "$0") \"Document title\" filename1 [filename2...]" >&2 && exit 1)
|
|
|
|
# A 160 mm width means a 25 mm margin on each side of a 210 mm A4 sheet of paper.
|
|
cat << __EOF__
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>$1</title>
|
|
<style>
|
|
body{font-family:sans-serif;font-size:12pt;margin:auto;width:160mm;}
|
|
@media screen{article{margin-bottom:100mm;}}
|
|
@media print{article{break-after:page;}}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
__EOF__
|
|
|
|
while shift
|
|
do
|
|
test -n "$1" || break # No more files.
|
|
echo "<article data-filename=\"$(basename "$1")\">"
|
|
cmark --to html --nobreaks --unsafe --smart --validate-utf8 $1
|
|
echo '</article>'
|
|
done
|
|
|
|
cat << __EOF__
|
|
</body>
|
|
</html>
|
|
__EOF__
|