3 #=======================================================================
7 # Create HTML file from Commonmark/Markdown file
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
25 " -n "$progname" -- "$@
")"
26 test "$?" = "0" ||
exit 1
34 -h|
--help) opt_help
=1; shift ;;
35 -q|
--quiet) opt_quiet
=$
(($opt_quiet + 1)); shift ;;
36 -v|
--verbose) opt_verbose
=$
(($opt_verbose + 1)); shift ;;
37 --version) echo $progname $VERSION; exit 0 ;;
39 *) echo $progname: Internal error
>&2; exit 1 ;;
42 opt_verbose
=$
(($opt_verbose - $opt_quiet))
44 if test "$opt_help" = "1"; then
45 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 Create HTML file from Commonmark/Markdown file with .md extension.
50 Usage: $progname [options] FILENAME
57 Be more quiet. Can be repeated to increase silence.
59 Increase level of verbosity. Can be repeated.
61 Print version information.
69 if test ! -f "$filename"; then
70 echo $progname: $filename: File not found
>&2
74 fileprefix
="$(basename "$1" .md)"
75 destfile
="$fileprefix.html"
77 cat <<END >"$destfile.tmp"
78 <?xml version="1.0" encoding="UTF-8"?>
79 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
80 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
81 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
83 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
84 <title>$destfile</title>
85 <style type="text/css">
87 body { background-color: white; color: black; font-family: sans-serif; }
88 a:link { color: blue; background-color: white; }
89 a:visited { color: maroon; background-color: white; }
90 a:active { color: fuchsia; background-color: white; }
94 content="Øyvind A. Holm — sunny@sunbase.org" />
95 <meta name="copyright"
96 content="©2015- Øyvind A. Holm" />
101 cmark
"$filename" | hhi
-l 1 >>"$destfile.tmp"
103 cat <<END >>"$destfile.tmp"
108 mv "$destfile.tmp" "$destfile"