diff options
author | jwinnie <jwinnie@tilde.institute> | 2021-11-29 20:44:52 -0500 |
---|---|---|
committer | jwinnie <jwinnie@tilde.institute> | 2021-11-29 20:44:52 -0500 |
commit | 94096519799fb245e3291869d1e1d199fa948338 (patch) | |
tree | dcd96df1d70d3e7248367a8cbb97b30c47d2e360 | |
parent | aa13acda2e3e2a0300e582d01e63f30fa0b583e3 (diff) | |
download | gmi2html-94096519799fb245e3291869d1e1d199fa948338.tar.gz |
Make it actually work
-rwxr-xr-x | gmi2html.awk | 11 | ||||
-rwxr-xr-x | gmi2htmldir.sh | 29 |
2 files changed, 25 insertions, 15 deletions
diff --git a/gmi2html.awk b/gmi2html.awk index e1850a3..0193e6e 100755 --- a/gmi2html.awk +++ b/gmi2html.awk @@ -18,7 +18,10 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # usage: -# $ awk -f gmi2html.awk -- <title> <css> <url> < path/to/gmi > path/to/html +# $ awk -f gmi2html.awk \ +# -v title=<title> \ +# -v css=<css> \ +# -v url=<url> < path/to/gmi > path/to/html # # parameters: # <title>: the title of the document, used in the HTML <title> @@ -35,9 +38,9 @@ BEGIN { <link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">\ <title>%s</title>\ </head>\ -<body>", ARGV[2], ARGV[1] +<body>", css, title - pre = 0 + pre = 0 list = 0 } @@ -171,5 +174,5 @@ Also available on <a href=\"gemini://%s\">Gemini</a>\ </small>\ </footer>\ </body>\ -</html>", ARGV[3] +</html>", url } diff --git a/gmi2htmldir.sh b/gmi2htmldir.sh index bdd0234..42babfb 100755 --- a/gmi2htmldir.sh +++ b/gmi2htmldir.sh @@ -1,3 +1,4 @@ +#!/bin/sh # # gmi2htmldir.sh -- POSIX shell script to convert a folder of Gemini files to HTML files # @@ -17,19 +18,25 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # usage: -# $ sh gmi2htmldir.sh <folder> <params> +# $ ./gmi2htmldir.sh <in> <out> title=<title> css=<css> url=<url> # # parameters: -# <folder>: the folder of Gemini files to be converted; the HTML files are outputted -# to the same directory, unless the directory contains the string 'gemini' - -# in that case, the string 'gemini' is replaced with 'html' in the output -# path (this is the recommended approach for separating input and output files) -# <params>: parameters to pass to gmi2html.awk; see gmi2html.awk for more details +# <in>: the folder of Gemini files to be converted +# <out>: the folder in which to put the generated HTML files +# <title>, <css>, <url>: parameters passed to gmi2html.awk; see gmi2html.awk for more details +# + +in=$1 +out=$2 +title=$3 +css=$4 +url=$5 -folder=$1 -params=$2 +gmi2html=${PWD}/$(dirname $0)/gmi2html.awk -for f in $(find $folder -name "*.gmi"); do - HTML_FILENAME=$(echo $f | sed s/gmi/html/g | sed s/gemini/html/g) - awk -f gmi2html -- $params < $f > $HTML_FILENAME +cd $in +for f in *.gmi **/*.gmi; do + HTML_FILENAME=$out/${f%.gmi}.html + echo "processing: ${f} -> ${HTML_FILENAME}" + awk -f $gmi2html -v $title -v $css -v $url < $f > $HTML_FILENAME done |