improve inc/gen-author.sh
Add START and END comments to generated HTML. Improve the rendered look of the HTML generated. Simplify echos and -v 3 -n echos. Improve pandoc wapper tool debug. Improve -v 3 parameter debugging The tool properly handles null location codes and treats them as an unknown location. Change `inc/gen-author.sh` VERSION from "1.0 2023-12-31" to "1.1 2024-01-01".
This commit is contained in:
1 parent
b108319772
commit
4c9539c762
1 file changed
+44
-20
+44
-20
@@ -9,7 +9,7 @@
|
||||
# the final arg will be in yyyy/dir form, and will be called from
|
||||
# the topdir directory under which the yyyy/dir winner directory must be found.
|
||||
#
|
||||
# Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved.
|
||||
# Copyright (c) 2023,2024 by Landon Curt Noll. All Rights Reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software and
|
||||
# its documentation for any purpose and without fee is hereby granted,
|
||||
@@ -56,7 +56,7 @@ shopt -s globstar # enable ** to match all files and zero or more directories an
|
||||
|
||||
# set variables referenced in the usage message
|
||||
#
|
||||
export VERSION="1.0 2023-12-31"
|
||||
export VERSION="1.1 2024-01-01"
|
||||
NAME=$(basename "$0")
|
||||
export NAME
|
||||
export V_FLAG=0
|
||||
@@ -316,7 +316,7 @@ function output_location_code
|
||||
|
||||
# extract Location Code from the author/author_handle.json file
|
||||
#
|
||||
grep -F location_code "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"location_code" : "//' -e 's/",.*//'
|
||||
grep -F location_code "$AUTHOR_HANDLE_JSON_PATH" | sed -e 's/.*"location_code" : "*//' -e 's/"*,.*//'
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -536,6 +536,7 @@ fi
|
||||
# parameter debugging
|
||||
#
|
||||
if [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: NAME=$NAME" 1>&2
|
||||
echo "$0: debug[3]: YEAR_DIR=$YEAR_DIR" 1>&2
|
||||
echo "$0: debug[3]: WINNER_DIR=$WINNER_DIR" 1>&2
|
||||
echo "$0: debug[3]: WINNER_ID=$WINNER_ID" 1>&2
|
||||
@@ -663,14 +664,21 @@ fi
|
||||
|
||||
# write author header to temporary markdown file
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
{
|
||||
echo '# author'
|
||||
echo
|
||||
} >> "$TMP_FILE"
|
||||
{
|
||||
echo "<!-- START: this line starts content generated by: inc/$NAME -->"
|
||||
AUTHOR_COUNT=$(echo "$AUTHOR_HANDLE_SET" | wc -l)
|
||||
if [[ $AUTHOR_COUNT -gt 1 ]]; then
|
||||
echo '<a name="author">**Authors:**</a>'
|
||||
else
|
||||
echo '<a name="author">**Author:**</a>'
|
||||
fi
|
||||
echo
|
||||
} | if [[ -z $NOOP ]]; then
|
||||
cat >> "$TMP_FILE"
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: -n disabled write: # author" 1>&2
|
||||
echo "$0: debug[3]: -n disabled write:" 1>&2
|
||||
sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2
|
||||
else
|
||||
cat >> /dev/null
|
||||
fi
|
||||
|
||||
# write each author's information to temporary markdown file
|
||||
@@ -701,24 +709,40 @@ for author_handle in $AUTHOR_HANDLE_SET; do
|
||||
|
||||
# write this author's information
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
{
|
||||
echo "[$FULL_NAME](/winners.html#$author_handle)"
|
||||
{
|
||||
echo "Name: [$FULL_NAME](/winners.html#$author_handle)<br>"
|
||||
if [[ $LOCATION_CODE == null ]]; then
|
||||
echo "Location: [unknown](/location.html#$LOCATION_CODE)"
|
||||
else
|
||||
echo "Location: [$LOCATION_CODE](/location.html#$LOCATION_CODE)"
|
||||
echo
|
||||
} >> "$TMP_FILE"
|
||||
fi
|
||||
echo
|
||||
} | if [[ -z $NOOP ]]; then
|
||||
cat >> "$TMP_FILE"
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
echo "$0: debug[3]: -n disabled write: [$FULL_NAME](/winners.html#$author_handle)" 1>&2
|
||||
echo "$0: debug[3]: -n disabled write: Location: [$LOCATION_CODE](/location.html#$LOCATION_CODE)" 1>&2
|
||||
echo "$0: debug[3]: -n disabled write:" 1>&2
|
||||
sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2
|
||||
else
|
||||
cat >> /dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# write END line
|
||||
#
|
||||
{
|
||||
echo "<!-- END: next line ends content generated by: inc/$NAME -->"
|
||||
} | if [[ -z $NOOP ]]; then
|
||||
cat >> "$TMP_FILE"
|
||||
elif [[ $V_FLAG -ge 3 ]]; then
|
||||
sed -e "s;^;$0: debug[3]: -n disabled write: ;" 1>&2
|
||||
else
|
||||
cat >> /dev/null
|
||||
fi
|
||||
|
||||
# convert temporary markdown file into HTML
|
||||
#
|
||||
if [[ -z $NOOP ]]; then
|
||||
if [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: about to execute: $PANDOC_WRAPPER -P $PANDOC_WRAPPER_OPTSTR $TMP_FILE -" 1>&2
|
||||
echo "$0: debug[1]: about to execute: $PANDOC_WRAPPER -P \"$PANDOC_WRAPPER_OPTSTR\" $TMP_FILE -" 1>&2
|
||||
fi
|
||||
"$PANDOC_WRAPPER" -P "$PANDOC_WRAPPER_OPTSTR" "$TMP_FILE" -
|
||||
status="$?"
|
||||
@@ -727,7 +751,7 @@ if [[ -z $NOOP ]]; then
|
||||
exit 118
|
||||
fi
|
||||
elif [[ $V_FLAG -ge 1 ]]; then
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER -P $PANDOC_WRAPPER_OPTSTR $TMP_FILE -" 1>&2
|
||||
echo "$0: debug[1]: -n disabled execution of: $PANDOC_WRAPPER -P \"$PANDOC_WRAPPER_OPTSTR\" $TMP_FILE -" 1>&2
|
||||
fi
|
||||
|
||||
# All Done!!! -- Jessica Noll, Age 2
|
||||
|
||||
Reference in new issue
Block a user