From f16ff5bcfe78fbf6cb02f7aa9f5cbc2ae8c8dc05 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Sun, 10 Dec 2023 20:52:58 -0800 Subject: [PATCH] improve even more, the md2html.cfg design and option doc --- inc/md2html.cfg | 99 +++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/inc/md2html.cfg b/inc/md2html.cfg index 54569f6fa..883874aeb 100644 --- a/inc/md2html.cfg +++ b/inc/md2html.cfg @@ -28,11 +28,13 @@ # Any "options.." are processed between the options from the command line # and any filename arguments on the command line. For example: # -# command [command_options ..] [cfg_options ..] [--] [filename_arg ..] +# command [command_options ..] [cfg_options ..] [output_tool_options ..] [--] [filename_arg ..] # # Here the "command" first processes any command line options, then -# any cfg_options from this file from a 1st match of a given file_glob, -# followed by an optional -- and then zero of more "filename_arg" filename arguments. +# it processes "cfg_options" obtained from this file from a 1st match of a given file_glob, then +# it processes "output tool" (i.e., -o tool) options found in "command_options", and "cfg_options", then +# an optional -- (end of all options), then +# zero of more "filename_arg" filename arguments. ################## # import options # @@ -48,54 +50,56 @@ # -n go thru the actions, but do not update any files (def: do the action) # -N do not process file, just ignore the file (def: process the file) # -# -i dir inc files are under topdir/dir (def: inc files are under topdir/inc) -# # -d topdir set topdir (def: if "git rev-parse --is-inside-work-tree" is true, then # topdir is output of "git rev-parse --show-toplevel") # -D def "def" is default HTML phase name (def: "default" is default phase name) # +# -i inc inc files are located under topdir/inc (def: inc files are under topdir/inc) +# # -c md2html.cfg Use md2html.cfg as the configuration file (def: use inc/md2html.cfg) # -C dir cd dir (def: if "git rev-parse --is-inside-work-tree" is true, then # cd to the output of "git rev-parse --show-cdup") # -# -H phase=name use "phase.name.html" for HTML phase (def: use phase.default.html) +# -H phase=name use "phase.name.html" file for HTML phase named "phase" (def: use "phase.default.html") # -H phase=. ignore processing for HTML phase "phase" (def: process HTML phase) -# NOTE: The "phase" string may not contain contain = (equal). +# NOTE: The "phase" string may not contain = (equal), nor / (slash). +# NOTE: The "phase.name.html" file is assumed under the "topdir/inc" directory. # -# -b tool before pandoc processing, add tool to in HTML phase 20 (def: do not output before pandoc) -# -b . ignore use of "before tool" (def: do not use "before tool") -# -B optstr run the "before tool" with options found in "optstr" (def: do not add any options) +# -b tool run "before tool" during HTML phase number 20 (def: do not output before pandoc tool) +# -b . skip HTML phase number 20 (def: do nothing during HTML phase number 20) +# -B optstr run "before tool" with options found in "optstr" (def: do not add any options to "before tool") # -# -p tool path to pandoc wrapper used in HTML phase 21 is "tool" (def: use inc/pandoc.sh) -# -p . ignore use of pandoc, just output content (def: process file with pandoc) -# -P optstr run pandoc with with options found in "optstr" (def: do not add any options) +# -p tool path to "pandoc tool" wrapper used in HTML phase number 21 is "tool" (def: use inc/pandoc.sh) +# -p . skip HTML phase number 21 (def: do nothing during HTML phase number 21) +# NOTE: The "tool" is a "pandoc tool" wrapper tool, NOT the path to the actual pandoc application. +# -P optstr run "pandoc tool" with options found in "optstr" (def: use only the "pandoc tool" default options) # -# -a tool after pandoc processing, add tool to in HTML phase 22 (def: do not output after pandoc) -# -a . ignore use of "after tool" (def: do not use an "after tool") -# -A optstr run the "after tool" with options found in "optstr" (def: do not add any options) +# -a tool run "after tool" during HTML phase number 20 (def: do not output after pandoc tool) +# -a . skip HTML phase number 22 (def: do nothing during HTML phase number 22) +# -A optstr run "after tool" with options found in "optstr" (def: do not add any options to "after tool") # -# -s token=value substitute %%token%% with value except in HTML phases 20-29 (def: do not substitute any tokens) -# NOTE: The "token" string may not contain ; (semicolon), nor = (equal). +# -s token=value substitute %%token%% with value except in HTML phase numbers 20-29 (def: do not substitute any tokens) +# NOTE: The "token" string may not contain ; (semicolon), nor = (equal), nor % (percent). # NOTE: The "value" string may not contain ; (semicolon). # -S failure to replace a %%token%% is not an error (def: exit non-zero for non-substituted tokens) # -# -o tool Use the output of tool to generate option lines (def: do not) +# -o tool Use output tool, "tool", to generate option lines (def: do not) # -o . disable use of "output tool" (def: do not use an "output tool") # -O tool=optstr run the "token replace" named "tool" with options found in "optstr" (def: do not add any options) -# NOTE: The "tool" string may not contain = (equal). +# NOTE: The "tool" string may not contain = (equal), nor double-quote, nor single-quote. # # -e exitcode force exit with exitcode (def: exit based on success or failure of the action) # -E string output string, followed by newline, to stderr (def: do not) # -# The output from "-b tool" (unless -b .) will be used in HTML phase 20 before pandoc processing. -# The output from pandoc (unless -p .) will be used HTML phase 21. -# The output from "-a tool" (unless -a .) will be used in HTML phase 22 after pandoc processing. +# The output from "before tool" (unless -b .) will be used in HTML phase number 20 (before pandoc processing). +# The output from "pandoc tool" (unless -p .) will be used HTML phase number 21 (pandoc processing). +# The output from "after tool" (unless -a .) will be used in HTML phase number 22 (after pandoc processing). # # When the "before tool" (i.e., -b tool) is executed, it is given options found in the most recent # "optstr" (i.e., -B optstr), followed by "--", and ending in the path from the topdir # to the file that matched the "file_glob". # -# When the pandoc (i.e., -p tool) is executed, it is given options found in the most recent +# When the "pandoc tool" (i.e., -p tool) is executed, it is given options found in the most recent # "optstr" (i.e., -P optstr), followed by "--", and ending in the path from the topdir # to the file that matched the "file_glob". # @@ -104,40 +108,45 @@ # to the file that matched the "file_glob". # # When the "options tool" (i.e., -o tool) is executed, it is given any options found in the most recent -# "optstr" associated with "tool" (i.e., -O tool=option). followed by "--", and ending in the path from the topdir +# "optstr" associated with "tool" (i.e., -O tool=option), followed by "--", and ending in the path from the topdir # to the file that matched the "file_glob". # -# The "tool" path (for -b tool, -a tool, -o tool), if not an absolute path then it is assumed to be under topdir. +# If the "tool" path (for -b tool, -p tool, -a tool, -o tool) is not an absolute path, then it is assumed to be under topdir. # If the "tool" path is "." (dot), then the use of the given tool is ignored. # -# Command line options are evaluated in order. For example, when "-e exitcode" is evaluated, the application -# will exit with the "exitcode" value. If one wishes to also output a message to stderr, the "-E string" -# must come BEFORE any "-e exitcode" in the command line. +# The "optstr" is a quoted string of command line options to used with the respective tool. +# The command line options for the tool specific to the given tool and are not necessarily +# the command line options listed above. # -# The command options are evaluated in the follow phases: +# The command options are evaluated in the following getopt phases: # # 0. collect command line options, up to but not including any "--" or up to the command line filename argument(s) -# 0a. ((evaluate all phase 0 options)) +# 0a. ((evaluate all getopt phase 0 options)) # # 1. collect "cfg_options" from the first md2html.cfg line where "file_glob" matched the filename argument -# 1a. ((evaluate all phase 1 options)) +# 1a. ((evaluate all getopt phase 1 options)) # -# 2. collect output of "-o tool" from phase 0a and then from phase 1a, in the order collected -# 2a. ((evaluate all phase 2 options, except that any new "-o tool" are ignored)) +# 2. collect output of "-o tool" from getopt phase 0a and then from getopt phase 1a, in the order collected +# 2a. ((evaluate all getopt phase 2 options, except that any new "-o tool" are ignored)) +# +# Command line options are evaluated in order, during each getopt phase (i.e., getopt phase 0a, then 1a, phase 2a). # # The "-o tool" should NOT output any "-o tool" options as "-o tool" is NOT RECURSIVE. -# Command line options output from a "-o tool" are accumulated for phase 2, -# and then evaluated in phase 2a. However, any "-o tool" found during phase 2a WILL BE IGNORED. +# Command line options output from a "-o tool" are accumulated for getopt phase 2, +# and then evaluated in getopt phase 2a. However, any "-o tool" found during getopt phase 2a WILL BE IGNORED. # # Most command line options override earlier copies of the same option. However in the case of # "-H phase=name", later "-H phase=name" only overrides an earlier use of "-H" for the same "phase" only. # Also in the case of "-s token=value", later "-s token=value" only overrides an earlier use of "-s" # for the same "token" only. # -# All tokens (i.e., strings of the form "%%token%%") must be substituted (by some -s token=value) -# in the content output (i.e., from any "before tool" (-b tool), from pandoc (-p tool), or -# from "after tool" (-a tool)), or the command will exit non-zero, unless -S is given. -# If -S is given, only a warning will be written to stderr. +# When "-e exitcode" is evaluated, the application will exit with the "exitcode" value. If one wishes to also +# output a message to stderr, the "-E string" must come BEFORE any "-e exitcode" in the command line. +# +# All tokens (i.e., strings of the form "%%token%%") MUST be substituted (by some -s token=value) +# in all HTML output, except during phase numbers 20-29 (i.e., except "before tool" output, pandoc output, +# and except "after tool" output), or command will exit non-zero, unless -S is given. If -S is given, +# only a warning about un-substituted tokens will be written to stderr. # # While above list is not a complete list of options, it does list options that are required of # tools that use this configuration file. @@ -162,9 +171,9 @@ # # Phases 11-19 are reserved for future use. # -# 20. ((insert before pandoc tool output)) -# 21. ((insert pandoc tool output)) -# 22. ((insert after pandoc tool output)) +# 20. ((insert "before tool" output)) +# 21. ((insert "pandoc tool" output)) +# 22. ((insert "after tool" output)) # # Phases 23-29 are reserved for future use. # @@ -176,7 +185,9 @@ # # Phases 35-39 are reserved for future use. # -# In the above HTML phases, except HTML phases 20-29, symbols of the form %%TOKEN%% are substituted. +# In the above HTML phase numbers, except during HTML phase numbers 20-29, symbols of the form %%TOKEN%% are substituted. +# Any %%TOKEN%% printed by the "before tool" (-b tool), the "pandoc tool" (-p tool), and the "after tool" (-a tool) +# are ignored (i.e., not substituted). ################# # Configuration #