From 94096519799fb245e3291869d1e1d199fa948338 Mon Sep 17 00:00:00 2001 From: jwinnie Date: Mon, 29 Nov 2021 20:44:52 -0500 Subject: Make it actually work --- gmi2html.awk | 11 +++++++---- 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 -- <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\ \ -", ARGV[2], ARGV[1] +", css, title - pre = 0 + pre = 0 list = 0 } @@ -171,5 +174,5 @@ Also available on Gemini\ \ \ \ -", ARGV[3] +", 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 +# $ ./gmi2htmldir.sh 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 -- cgit 1.4.1-2-gfad0