use yet even more bin/jval-wrapper.sh instead of direct grep of JSON files

We use the `bin/jval-wrapper.sh` tool to obtain information from JSON
files instead of attempting using a "GROSS HACK" that involved using
`grep(1)` (and friends) as those "GROSS HACK"s assumed that the layout of
the JSON was canonical.  The `bin/jval-wrapper.sh` tool is able to deal
with various layouts of JSON including non-canonical layouts.  Moreover,
by using the `bin/jval-wrapper.sh` tool we greatly reduce the places in
bin tools that contain "GROSS HACK"s.

Adjusted `bin/gen-status.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/gen-status.sh` VERSION from "1.5.8 2024-08-05"
to "1.6 2024-08-17".

Performed `make gen_status` to test the above under macOS.

Adjusted `bin/gen-years.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/gen-years.sh` VERSION from "1.3.7 2024-08-05"
to "1.4 2024-08-17".

Performed `make gen_years` to test the above under macOS.

Adjusted `bin/output-index-author.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/output-index-author.sh` VERSION from "1.7.3 2024-08-05"
to "1.8 2024-08-17".

Performed `make entry_index` to test the above under macOS.

Added `make quick_year_index` to generate year level index.html files
when year level `YYYY/README.md` is newer.

The `make quick_www` calls `quick_year_index` instead of `make gen_year_index`.

The `bin` directory is now sat as `BIN_PATH=$TOPDIR/bin`, where
`$TOPDIR` is determined by top of the git repo (as determined by
the command: `git rev-parse --is-inside-work-tree`) and potentially
modified by `-d topdir`.  After `cd $TOPDIR`, we set `BIN_DIR=bin`.

All tools from this repo are now assumed to under "$BIN_DIR".  Removed
command like options such as `-T md2html.sh`, and `-p tool` that used
to be able to change the location of a `bin` tool.

Changed `bin/gen-authors.sh` VERSION from "1.11 2024-08-13"
to "1.12 2024-08-18".

Changed `bin/gen-location.sh` VERSION from "1.5 2024-08-17"
to "1.6 2024-08-18".

Changed `bin/readme2index.sh` VERSION from "1.2.7 2024-08-05"
to "1.3 2024-08-17".

Modified `bin/all-run.sh` to use the `bin` directory mechanism.
Modified `bin/all-years.sh` to use the `bin` directory mechanism.
Modified `bin/gen-other-html.sh` to use the `bin` directory mechanism.
Modified `bin/gen-year-index.sh` to use the `bin` directory mechanism.
Modified `bin/md2html.sh` to use the `bin` directory mechanism.
Modified `bin/quick-readme2index.sh` to use the `bin` directory mechanism.
Modified `bin/readme2index.sh` to use the `bin` directory mechanism.

Changed `bin/all-run.sh` VERSION from "1.3.6 2024-08-05"
to "1.4 2024-08-17".

Changed `bin/all-years.sh` VERSION from "1.0.5 2024-08-05"
to "1.1 2024-08-17".

Changed `bin/gen-other-html.sh` VERSION from "1.3 2024-08-11"
to "1.4 2024-08-17".

Changed `bin/gen-year-index.sh` VERSION from "1.1.2 2024-08-05"
to "1.2 2024-08-17".

Changed `bin/quick-readme2index.sh` VERSION from "1.1.7 2024-08-05"
to "1.2 2024-08-17".

Changed `bin/md2html.sh` VERSION from "1.5.5 2024-08-05"
to "1.6 2024-08-17".

Added some whitespace in the form of empty lines to tools.

Made checks for tools under `bin` directory more consistent.

When using `-Q` (quick mode) and the prerequisite files are newer,
we force the target to be touched so that a later run will not
have to build the target HTML file.

Performed `make quick_www` to test the above under macOS.

Performed `make www` to test the above under macOS.
This commit is contained in:
Landon Curt Noll committed 2024-08-18 02:10:25 -07:00
1 parent f159369a0a
commit 0e5864b8b0
39 files changed
+1694 -795

No files matched your search

+200 -134
View File
@@ -78,6 +78,7 @@
#
# Share and enjoy! :-)
# firewall - run only with a bash that is version 5.1.8 or later
#
# The "/usr/bin/env bash" command must result in using a bash that
@@ -121,6 +122,7 @@ if [[ -z ${BASH_VERSINFO[0]} ||
exit 4
fi
# setup bash file matching
#
# We must declare arrays with -ag or -Ag, and we need loops to "export" modified variables.
@@ -133,15 +135,17 @@ shopt -u nocaseglob # disable strict case matching
shopt -u extglob # enable extended globbing patterns
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
# other required bash options
#
# Requires bash with a version 4.2 or later
#
shopt -s lastpipe # run last command of a pipeline not executed in the background in the current shell environment
# set variables referenced in the usage message
#
export VERSION="1.5.5 2024-08-05"
export VERSION="1.6 2024-08-17"
NAME=$(basename "$0")
export NAME
export V_FLAG=0
@@ -164,18 +168,18 @@ if [[ -z "$PERL_TOOL" ]]; then
fi
export TOPDIR
export DOCROOT_SLASH="./"
export PANDOC_WRAPPER="bin/pandoc-wrapper.sh"
export REPO_TOP_URL="https://github.com/ioccc-src/temp-test-ioccc"
# GitHub puts individual files under the "blob/master" sub-directory.
export REPO_URL="$REPO_TOP_URL/blob/master"
export SITE_URL="https://ioccc-src.github.io/temp-test-ioccc"
export URL="#"
# set usage message
#
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
[-c md2html.cfg] [-H phase=name ..] [-t tagline]
[-b tool] [-p tool] [-a tool]
[-b tool] [-a tool]
[-s token=value ..] [-S] [-o tool ..]
[-U url] [-w site_url] [-m mdtag] [-e string ..] [-E exitcode]
[match.md] input.md output.html
@@ -208,10 +212,6 @@ export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-D docroot/] [-n] [-N]
-b tool run 'before tool' during HTML phase number 20 (def: do not output before pandoc wrapper tool)
-b . skip HTML phase number 20 (def: do nothing during HTML phase number 20)
-p tool run 'pandoc wrapper tool' (not pandoc path) during HTML phase number 21 (def: use $PANDOC_WRAPPER)
-p . skip HTML phase number 21 (def: do nothing during HTML phase number 21)
NOTE: The '-p tool' will be passed as leading options on the -b tool and -a tool command lines.
-a tool run 'after tool' during HTML phase number 20 (def: do not output after pandoc wrapper tool)
-a . skip HTML phase number 22 (def: do nothing during HTML phase number 22)
@@ -256,10 +256,12 @@ Exit codes:
$NAME version: $VERSION"
##################################
# command line parsing functions #
##################################
# global_variable_setup - setup global variables
#
# Call this once at the start of the shell script.
@@ -338,7 +340,7 @@ function global_variable_setup
unset PHASE_NAME
declare -ag PHASE_NAME
PHASE_NAME=(top head body topbar header navbar before-content
after-content footer bottom)
after-content footer bottom)
unset HTML_PHASE_NAME
declare -Ag HTML_PHASE_NAME
for n in "${PHASE_NAME[@]}"; do
@@ -351,6 +353,7 @@ function global_variable_setup
return 0
}
# print_usage - print the usage message, exit code and version information
#
# Call this to print the usage message, by default to stdout.
@@ -366,6 +369,7 @@ function print_usage
return 0
}
# parse_command_line - parse command line arguments
#
# You MUST call this function at least once AND after calling global_variable_setup.
@@ -412,7 +416,7 @@ function parse_command_line
# parse command line
#
while getopts :hv:VnNd:D:c:H:t:m:b:p:a:s:So:U:w:e:E: flag; do
while getopts :hv:VnNd:D:c:H:t:m:b:a:s:So:U:w:e:E: flag; do
case "$flag" in
h) print_usage 1>&2
exit 2
@@ -546,7 +550,7 @@ function parse_command_line
;;
m) MDTAG="$OPTARG"
;;
b) # parse: -p tool
b) # parse: -b tool
if [[ $OPTARG == . ]]; then
# unset before tool
BEFORE_TOOL=
@@ -555,19 +559,6 @@ function parse_command_line
BEFORE_TOOL="$OPTARG"
fi
;;
p) # parse -p tool
if [[ $OPTARG == . ]]; then
# unset pandoc wrapper tool
PANDOC_WRAPPER=
else
# change pandoc wrapper tool
PANDOC_WRAPPER="$OPTARG"
fi
B_OPTION+=("-p")
B_OPTION+=("$PANDOC_WRAPPER")
A_OPTION+=("-p")
A_OPTION+=("$PANDOC_WRAPPER")
;;
a) # parse: -a tool
if [[ $OPTARG == . ]]; then
# unset after tool
@@ -678,6 +669,7 @@ function parse_command_line
return 0
}
# debug_parameters - if verbose enough, print parameters
#
# usage:
@@ -716,7 +708,6 @@ function debug_parameters
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: PERL_TOOL=$PERL_TOOL" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: TOPDIR=$TOPDIR" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: REPO_URL=$REPO_URL" 1>&2
echo "$0: debug[$DEBUG_LEVEL]: $DBG_PREFIX: SITE_URL=$SITE_URL" 1>&2
@@ -766,10 +757,12 @@ function debug_parameters
return 0
}
#################################
# md2html.cfg related functions #
#################################
# match_md2html - first file_glob match for md2html.cfg file
#
# usage:
@@ -897,10 +890,12 @@ function match_md2html
return 1
}
################################
# HTML phase related functions #
################################
# append_html_phase - append a sed modified HTML phase file to a growing temporary HTML file
#
# usage:
@@ -1033,24 +1028,30 @@ function append_html_phase
return 0
}
###################################
# required initial variable setup #
###################################
global_variable_setup
##################
# getopt phase 0 #
##################
# set getopt phase to 0
#
GETOPT_PHASE=0
# process command line options
#
parse_command_line "$@"
# parse the command line arguments
#
if [[ $V_FLAG -ge 3 ]]; then
@@ -1088,6 +1089,7 @@ if [[ $MATCH_MD == - ]]; then
exit 3
fi
# determine working directory
#
# We will use the dirname of match.md as our working directory. This is path from
@@ -1099,6 +1101,7 @@ fi
WORKING_DIR=$(dirname "$MATCH_MD")
export WORKING_DIR
# verify that we have a topdir directory
#
REPO_NAME=$(basename "$REPO_TOP_URL")
@@ -1119,6 +1122,7 @@ if [[ ! -d $TOPDIR ]]; then
exit 6
fi
# cd to topdir
#
if [[ ! -e $TOPDIR ]]; then
@@ -1142,14 +1146,6 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
fi
# verify that we have an inc subdirectory
#
export INC_PATH="$TOPDIR/inc"
if [[ ! -d $INC_PATH ]]; then
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
exit 6
fi
export INC_DIR="inc"
# verify that we have a bin subdirectory
#
@@ -1161,6 +1157,33 @@ fi
export BIN_DIR="bin"
# verify that the bin/pandoc-wrapper.sh tool is executable
#
export PANDOC_WRAPPER="$BIN_DIR/pandoc-wrapper.sh"
if [[ ! -e $PANDOC_WRAPPER ]]; then
echo "$0: ERROR: bin/md2html.sh does not exist: $PANDOC_WRAPPER" 1>&2
exit 5
fi
if [[ ! -f $PANDOC_WRAPPER ]]; then
echo "$0: ERROR: bin/md2html.sh is not a regular file: $PANDOC_WRAPPER" 1>&2
exit 5
fi
if [[ ! -x $PANDOC_WRAPPER ]]; then
echo "$0: ERROR: bin/md2html.sh is not an executable file: $PANDOC_WRAPPER" 1>&2
exit 5
fi
# verify that we have an inc subdirectory
#
export INC_PATH="$TOPDIR/inc"
if [[ ! -d $INC_PATH ]]; then
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
exit 6
fi
export INC_DIR="inc"
# verify that we have a readable .top file
#
export TOP="$TOPDIR/.top"
@@ -1177,6 +1200,7 @@ if [[ ! -r $TOP ]]; then
exit 6
fi
# verify we have a readable md2html.cfg file
#
if [[ -z $MD2HTML_CFG ]]; then
@@ -1195,6 +1219,7 @@ if [[ ! -r $MD2HTML_CFG ]]; then
exit 5
fi
# new parameter debugging
#
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
@@ -1203,10 +1228,12 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
##################
# getopt phase 1 #
##################
# set getopt phase to 1
#
GETOPT_PHASE=1
@@ -1215,6 +1242,7 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
# run output tools and parse output as more options
#
# report output tools and output tool options
@@ -1224,6 +1252,7 @@ if [[ $V_FLAG -ge 5 ]]; then
done
fi
# verify output tools are executable
#
for n in "${!OUTPUT_TOOL[@]}"; do
@@ -1242,6 +1271,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
fi
done
# pre-clear our output tool options array
#
# NOTE: The OUTPUT_TOOL_OPTIONS array contains the options that an "output tool" produces.
@@ -1250,6 +1280,7 @@ done
unset OUTPUT_TOOL_OPTIONS
declare -ag OUTPUT_TOOL_OPTIONS
# execute each output tool and parse the output tool's options and arguments
#
for n in "${!OUTPUT_TOOL[@]}"; do
@@ -1272,6 +1303,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
done
done
# process command line arguments from all output tools
#
if [[ ${#OUTPUT_TOOL_OPTIONS[@]} -gt 0 ]]; then
@@ -1286,6 +1318,7 @@ fi
#
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
# clear output tools and output tool options
#
unset OUTPUT_TOOL
@@ -1297,10 +1330,12 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
##################
# getopt phase 2 #
##################
# set getopt phase to 2
#
GETOPT_PHASE=2
@@ -1309,11 +1344,13 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
# setup an empty MATCH_OPTIONS array for match_md2html to append options
#
unset MATCH_OPTIONS
declare -ag MATCH_OPTIONS
# find the first match md2html.cfg for the 'match.md' argument
#
match_md2html "$MD2HTML_CFG" "$MATCH_MD"
@@ -1323,6 +1360,7 @@ status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: Warning: $MATCH_MD does not match any lines in: $MD2HTML_CFG, match_md2html return code: $status" 1>&2
# case: MATCH_MD matched and command line options were appended to MATCH_OPTIONS
#
elif [[ ${#MATCH_OPTIONS[@]} -gt 0 ]]; then
@@ -1341,6 +1379,7 @@ elif [[ ${#MATCH_OPTIONS[@]} -gt 0 ]]; then
#
parse_command_line "${MATCH_OPTIONS[@]}"
# case: MATCH_MD matched and no command line options found
#
elif [[ $V_FLAG -ge 5 ]]; then
@@ -1353,10 +1392,12 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
##################
# getopt phase 3 #
##################
# set getopt phase to 3
#
GETOPT_PHASE=3
@@ -1365,6 +1406,7 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: begin getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
# run output tools and parse output as more options
#
# report output tools and output tool options
@@ -1374,6 +1416,7 @@ if [[ $V_FLAG -ge 5 ]]; then
done
fi
# verify output tools are executable
#
for n in "${!OUTPUT_TOOL[@]}"; do
@@ -1392,6 +1435,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
fi
done
# pre-clear our output tool options array
#
# NOTE: The OUTPUT_TOOL_OPTIONS array contains the options that an "output tool" produces.
@@ -1400,6 +1444,7 @@ done
unset OUTPUT_TOOL_OPTIONS
declare -ag OUTPUT_TOOL_OPTIONS
# execute each output tool and parse the output tool's options and arguments
#
for n in "${!OUTPUT_TOOL[@]}"; do
@@ -1422,6 +1467,7 @@ for n in "${!OUTPUT_TOOL[@]}"; do
done
done
# process command line arguments from all output tools
#
if [[ ${#OUTPUT_TOOL_OPTIONS[@]} -gt 0 ]]; then
@@ -1436,6 +1482,7 @@ fi
#
debug_parameters 5 "after parse in getopt phase: $GETOPT_PHASE"
# clear output tools and output tool options
#
unset OUTPUT_TOOL
@@ -1447,10 +1494,12 @@ if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: end getopt phase ${GETOPT_PHASE} debug level: $V_FLAG" 1>&2
fi
############################################
# debugging after getopt phase is complete #
############################################
# set getopt phase to 4
#
GETOPT_PHASE=4
@@ -1464,7 +1513,6 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: V_FLAG=$V_FLAG" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: GIT_TOOL=$GIT_TOOL" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: DOCROOT_SLASH=$DOCROOT_SLASH" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_TOP_URL=$REPO_TOP_URL" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_URL=$REPO_URL" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: SITE_URL=$SITE_URL" 1>&2
@@ -1473,12 +1521,16 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: REPO_NAME=$REPO_NAME" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: INC_PATH=$INC_PATH" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: INC_DIR=$INC_DIR" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: BIN_PATH=$BIN_PATH" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: BIN_DIR=$BIN_DIR" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: PANDOC_WRAPPER=$PANDOC_WRAPPER" 1>&2
echo "$0: debug[3]: after parse in getopt phase: $GETOPT_PHASE: TOP=$TOP" 1>&2
fi
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: finished all getopt parsing" 1>&2
fi
# validate HTML phase names
#
for n in "${PHASE_NAME[@]}"; do
@@ -1506,6 +1558,7 @@ for n in "${PHASE_NAME[@]}"; do
fi
done
# validate before tool
#
if [[ -n $BEFORE_TOOL ]]; then
@@ -1528,27 +1581,6 @@ if [[ -n $BEFORE_TOOL ]]; then
fi
fi
# validate pandoc wrapper tool
#
if [[ -n $PANDOC_WRAPPER ]]; then
if [[ $V_FLAG -ge 5 ]]; then
if [[ -n $PANDOC_WRAPPER ]]; then
echo "$0: debug[5]: -p pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
fi
fi
if [[ ! -e "$PANDOC_WRAPPER" ]]; then
echo "$0: ERROR: -p pandoc wrapper tool not found: $PANDOC_WRAPPER" 1>&2
exit 5
fi
if [[ ! -f "$PANDOC_WRAPPER" ]]; then
echo "$0: ERROR: -p pandoc wrapper tool not a file: $PANDOC_WRAPPER" 1>&2
exit 5
fi
if [[ ! -x "$PANDOC_WRAPPER" ]]; then
echo "$0: ERROR: -p pandoc wrapper tool not an executable file: $PANDOC_WRAPPER" 1>&2
exit 5
fi
fi
# validate after tool
#
@@ -1572,6 +1604,7 @@ if [[ -n $AFTER_TOOL ]]; then
fi
fi
# report TOKEN sed patterns
#
if [[ $V_FLAG -ge 7 ]]; then
@@ -1589,10 +1622,12 @@ if [[ -n $DO_NOT_PROCESS ]]; then
exit 0
fi
##########################
# HTML pre-0 phase setup #
##########################
# create a temporary sed script
#
export TMP_SED_SCRIPT=".tmp.$NAME.SED_SCRIPT.$$.tmp"
@@ -1634,6 +1669,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: the temporary sed script that would have been written ends above: $TMP_SED_SCRIPT" 1>&2
fi
# create a temporary HTML phase file
#
# NOTE: This file, when we are finished building it, will be come the final index.html file.
@@ -1661,6 +1697,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, temporary HTML file is not formed: $TMP_PHASE" 1>&2
fi
# create a temporary index HTML file
#
# NOTE: This file, when we are finished building it, will be come the final index.html file.
@@ -1688,6 +1725,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, temporary index HTML file is not formed: $TMP_INDEX_HTML" 1>&2
fi
# input.md is -, we will need to capture standard input into a new temporary file
#
export ORIG_INPUT_MD="$MATCH_MD"
@@ -1733,6 +1771,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, temporary stdin file is not formed: $TMP_INPUT_MD" 1>&2
fi
# strip commented language after markdown code block
#
if [[ -z $NOOP ]]; then
@@ -1784,6 +1823,7 @@ fi
# HTML phase 0: inc/top.__name__.html #
#######################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
export CUR_PHASE_NUM=0
@@ -1799,10 +1839,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
########################################
# HTML phase 1: inc/head.__name__.html #
########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=1
@@ -1818,6 +1860,7 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
# Special output to indicate which tool was used
#
if [[ -z $NOOP && ${HTML_PHASE_NAME[$CUR_PHASE_NAME]} != . ]]; then
@@ -1849,10 +1892,12 @@ fi
} >> "$TMP_INDEX_HTML"
fi
########################################
# HTML phase 2: inc/body.__name__.html #
########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=2
@@ -1868,10 +1913,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
########################################
# HTML phase 3: inc/topbar.__name__.html #
########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=3
@@ -1887,10 +1934,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
##########################################
# HTML phase 4: inc/header.__name__.html #
##########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=4
@@ -1906,10 +1955,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
##########################################
# HTML phase 5: inc/navbar.__name__.html #
##########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=5
@@ -1925,10 +1976,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
###################################################
# HTML phase 6: inc/before-content.__name__.html #
###################################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=6
@@ -1944,10 +1997,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
##############################
# HTML phase 20: before tool #
##############################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=20
@@ -2004,10 +2059,12 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM ($CUR_PHASE_NAME)" 1>&2
fi
######################################
# HTML phase 21: pandoc wrapper tool #
######################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=21
@@ -2019,100 +2076,98 @@ if [[ $V_FLAG -ge 5 ]]; then
done
fi
#
if [[ -n $PANDOC_WRAPPER ]]; then
if [[ -z $NOOP ]]; then
if [[ -z $NOOP ]]; then
# write START of section comment
#
{
echo "<!-- START: this line starts content for HTML phase $CUR_PHASE_NUM" \
"by: $PANDOC_WRAPPER via bin/$NAME -->"
echo
} >> "$TMP_INDEX_HTML"
# write START of section comment
#
{
echo "<!-- START: this line starts content for HTML phase $CUR_PHASE_NUM" \
"by: $PANDOC_WRAPPER via bin/$NAME -->"
echo
} >> "$TMP_INDEX_HTML"
# append pandoc wrapper tool output
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to execute:" \
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - >> $TMP_INDEX_HTML" 1>&2
fi
"$PANDOC_WRAPPER" "${P_OPTION[@]}" -- "$TMP_STRIPPED_MD" - >> "$TMP_INDEX_HTML"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: pandoc wrapper tool:" \
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - failed," \
"error code: $status" 1>&2
exit 100
fi
# fix any pandoc footnote bogons
#
# The pandoc(1) tool will generate the following BOGUS HTML 5 code
# when any markdown footnotes are used:
#
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
# <hr />
#
# The section element lacks any HTML h1..h6 heading element inside it,
# and "<hr />" has no effect in standard HTML 5 and interacts badly with
# unquoted attribute values.
#
# We replace such HTML 5 with HTML 5 code as follows:
#
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
# <hr style="width:10%;text-align:left;margin-left:0">
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
# <h5>Footnotes</h5>
#
# It is easier to compose a perl script inline than to use an external file
# because we then have to test for that perl script to be a non-empty readable file,
# and perhaps allow some arg to specify an alternate location for the perl script/
# So instead we just build the perl script inline.
#
PERL_LINE='s|(<!-- AFTER: last line of markdown file: \S+ -->)\n'
PERL_LINE="$PERL_LINE"'(<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">)\n'
PERL_LINE="$PERL_LINE"'<hr />|'
PERL_LINE="$PERL_LINE\$1"'\n'
PERL_LINE="$PERL_LINE"'<hr style="width:10%;text-align:left;margin-left:0">\n'
PERL_LINE="$PERL_LINE\$2"'\n'
PERL_LINE="$PERL_LINE"'<h5>Footnotes</h5>|gms'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to execute:" \
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML" 1>&2
fi
"$PERL_TOOL" -0 -p -i -e "$PERL_LINE" -- "$TMP_INDEX_HTML"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: pandoc wrapper tool:" \
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML - failed," \
"error code: $status" 1>&2
exit 101
fi
# write START of section comment
#
{
echo
echo "<!-- END: this line ends content for HTML phase $CUR_PHASE_NUM" \
"by: $PANDOC_WRAPPER via bin/$NAME -->"
} >> "$TMP_INDEX_HTML"
elif [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: because of -n, disabled use of pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
# append pandoc wrapper tool output
#
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to execute:" \
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - >> $TMP_INDEX_HTML" 1>&2
fi
"$PANDOC_WRAPPER" "${P_OPTION[@]}" -- "$TMP_STRIPPED_MD" - >> "$TMP_INDEX_HTML"
status="$?"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: pandoc wrapper tool:" \
"$PANDOC_WRAPPER ${P_OPTION[*]} -- $TMP_STRIPPED_MD - failed," \
"error code: $status" 1>&2
exit 100
fi
# fix any pandoc footnote bogons
#
# The pandoc(1) tool will generate the following BOGUS HTML 5 code
# when any markdown footnotes are used:
#
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
# <hr />
#
# The section element lacks any HTML h1..h6 heading element inside it,
# and "<hr />" has no effect in standard HTML 5 and interacts badly with
# unquoted attribute values.
#
# We replace such HTML 5 with HTML 5 code as follows:
#
# <!-- AFTER: last line of markdown file: PATH/FILE/NAME -->
# <hr style="width:10%;text-align:left;margin-left:0">
# <section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">
# <h5>Footnotes</h5>
#
# It is easier to compose a perl script inline than to use an external file
# because we then have to test for that perl script to be a non-empty readable file,
# and perhaps allow some arg to specify an alternate location for the perl script/
# So instead we just build the perl script inline.
#
PERL_LINE='s|(<!-- AFTER: last line of markdown file: \S+ -->)\n'
PERL_LINE="$PERL_LINE"'(<section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes">)\n'
PERL_LINE="$PERL_LINE"'<hr />|'
PERL_LINE="$PERL_LINE\$1"'\n'
PERL_LINE="$PERL_LINE"'<hr style="width:10%;text-align:left;margin-left:0">\n'
PERL_LINE="$PERL_LINE\$2"'\n'
PERL_LINE="$PERL_LINE"'<h5>Footnotes</h5>|gms'
if [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: about to execute:" \
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML" 1>&2
fi
"$PERL_TOOL" -0 -p -i -e "$PERL_LINE" -- "$TMP_INDEX_HTML"
if [[ $status -ne 0 ]]; then
echo "$0: ERROR: pandoc wrapper tool:" \
"$PERL_TOOL -0 -p -i -e $PERL_LINE -- $TMP_INDEX_HTML - failed," \
"error code: $status" 1>&2
exit 101
fi
# write START of section comment
#
{
echo
echo "<!-- END: this line ends content for HTML phase $CUR_PHASE_NUM" \
"by: $PANDOC_WRAPPER via bin/$NAME -->"
} >> "$TMP_INDEX_HTML"
elif [[ $V_FLAG -ge 5 ]]; then
echo "$0: debug[5]: because of -p ., use of pandoc wrapper tool was disabled" 1>&2
echo "$0: debug[5]: because of -n, disabled use of pandoc wrapper tool: $PANDOC_WRAPPER" 1>&2
fi
#
if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM ($CUR_PHASE_NAME)" 1>&2
fi
#############################
# HTML phase 22: after tool #
#############################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=22
@@ -2169,10 +2224,12 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: successfully completed HTML phase $CUR_PHASE_NUM" 1>&2
fi
##################################################
# HTML phase 30: inc/after-content.__name__.html #
##################################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=30
@@ -2188,10 +2245,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
###########################################
# HTML phase 31: inc/footer.__name__.html #
###########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=31
@@ -2207,10 +2266,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
###########################################
# HTML phase 32: inc/bottom.__name__.html #
###########################################
# NOTE: See bin/md2html.cfg for details on HTML phase numbers, HTML phase names, and HTML phase files
#
CUR_PHASE_NUM=32
@@ -2226,10 +2287,12 @@ if [[ $status -ne 0 ]]; then
exit "$status"
fi
################################
# finalize the index.html file #
################################
# sanity check - temporary index HTML file must be a readable file
#
if [[ -z $NOOP ]]; then
@@ -2252,6 +2315,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, disabled readable file check of: $TMP_PHASE_FILE 2>/dev/null" 1>&2
fi
# move temporary index HTML in place
#
if [[ -z $NOOP ]]; then
@@ -2312,6 +2376,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, disabled: mv -f -- $TMP_INDEX_HTML $OUTPUT_HTML" 1>&2
fi
# file cleanup
#
if [[ -z $NOOP ]]; then
@@ -2321,6 +2386,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
"$TMP_SED_SCRIPT $TMP_PHASE $TMP_INDEX_HTML $TMP_INPUT_MD $TMP_STRIPPED_MD" 1>&2
fi
# All Done!!! All Done!!! -- Jessica Noll, Age 2
#
if [[ -n $NOOP ]]; then