format headers

We move `tmp/format-headers.sh` into `bin/format-headers.sh`.

We also add a few missing empty lines to `README.md`.

We add `bin/format-headers.sh` to the `bin/README.md`.

We run `bin/format-headers.sh` to perform the above.

Performed `make www` to accomplish the above and to test under macOS.
This commit is contained in:
Landon Curt Noll committed 2024-07-19 00:18:41 -07:00
1 parent 0ae673c24e
commit ed866b45e8
28 files changed
+90 -35

No files matched your search

+33 -1
View File
@@ -49,6 +49,7 @@ to set the verbosity level to `3`. The default for verbosity is `0`, no
verbosity, though using the [top level Makefile](%%REPO_URL%%/Makefile) will,
for some tools, set a verbosity level.
### Get version string of a tool
If you just want to know what version the tool is, you can use the `-V` option.
@@ -111,6 +112,7 @@ Or for example:
bin/all-years.sh -v 1 bin/chk-entry.sh
```
<div id="chk-entry">
### [chk-entry.sh](%%REPO_URL%%/bin/chk-entry.sh)
</div>
@@ -131,6 +133,7 @@ the top level `Makefile` by:
make verify_entry_files
```
<div id="filelist-entry-json-awk">
### [filelist.entry.json.awk](%%REPO_URL%%/bin/filelist.entry.json.awk)
</div>
@@ -186,6 +189,20 @@ We recommend that this tool be invoked via the top level `Makefile` by:
make find_missing_links
```
<div id="format-headers">
### [format-headers.sh](%%REPO_URL%%/bin/format-headers.sh)
</div>
Format select headers and preceding empty lines in entry README.md files.
Usage:
``` <!---sh-->
bin/format-headers.sh
```
<div id="gen-authors">
### [gen-authors.sh](%%REPO_URL%%/bin/gen-authors.sh)
</div>
@@ -223,6 +240,7 @@ We recommend that this tool be invoked via the top level `Makefile` by:
make gen_location
```
<div id="gen-other-html">
### [gen-other-html.sh](%%REPO_URL%%/bin/gen-other-html.sh)
</div>
@@ -242,6 +260,7 @@ We recommend that this tool be invoked via the top level `Makefile` by:
make gen_other_html
```
<div id="gen-sitemap">
### [gen-sitemap.sh](%%REPO_URL%%/bin/gen-sitemap.sh)
</div>
@@ -309,6 +328,7 @@ We recommend that this tool be invoked via the top level `Makefile` by:
unless the `contest_status` is to be changed, but since only the judges should
do that, that is not a problem.
<div id="gen-top-html">
### [gen-top-html.sh](%%REPO_URL%%/bin/gen-top-html.sh)
</div>
@@ -365,6 +385,7 @@ We recommend that this tool be invoked via the top level `Makefile` by:
which will create the `index.html` for every IOCCC year (`1984/index.html`,
`1985/index.html` etc.).
<div id="gen-years">
### [gen-years.sh](%%REPO_URL%%/bin/gen-years.sh)
</div>
@@ -447,7 +468,9 @@ This tool is used in the [bin/md2html.cfg](%%REPO_URL%%/bin/md2html.cfg) file as
the [md2html tool](index.html#md2html).
<div id="output-year-index">
### [output-year-index.sh](%%REPO_URL%%/bin/output-year-index.sh)
</div>
Output the inventory for a given year's winning entries in HTML form. In other
words in [1984](../1984/index.html) it would list, as links, the four winning
@@ -458,7 +481,9 @@ This tool is used in the [bin/md2html.cfg](%%REPO_URL%%/bin/md2html.cfg) file as
the [md2html tool](index.html#md2html).
<div id="pandoc-wrapper">
### [pandoc-wrapper.sh](%%REPO_URL%%/bin/pandoc-wrapper.sh)
</div>
Wrapper tool to run `pandoc(1)`.
@@ -595,6 +620,7 @@ Print substitutions for an entry's `index.html`.
This tool is used in the [bin/md2html.cfg](%%REPO_URL%%/bin/md2html.cfg) file.
<div id="subst-entry-navbar-awk">
### [subst.entry-navbar.awk](%%REPO_URL%%/bin/subst.entry-navbar.awk)
</div>
@@ -612,6 +638,7 @@ Print substitutions for a year level `index.html`.
This tool is used in the [bin/md2html.cfg](%%REPO_URL%%/bin/md2html.cfg) file.
<div id="subst-year-navbar-awk">
### [subst.year-navbar.awk](%%REPO_URL%%/bin/subst.year-navbar.awk)
</div>
@@ -620,6 +647,7 @@ Output substitutions for `navbar` on behalf of a year level `index.html`.
This tool is used in [subst.year-index.sh](index.html#subst-year-index).
<div id="tar-entry">
## [tar-entry.sh](%%REPO_URL%%/bin/tar-entry.sh)
</div>
@@ -766,7 +794,6 @@ For example:
will cause no HTML content to be produced during the `footer` HTML phase.
<div id="html">
## HTML phases
</div>
@@ -831,6 +858,7 @@ it is a file under topdir.
`getopt` phase 0 is the only `getopt` phase where `-d topdir` and `-c
md2html.cfg` may be used.
<div id="getopt-1">
### `getopt` phase 1
</div>
@@ -845,6 +873,7 @@ The `-o "output tool"` is not allowed to output another `"-o tool"` or a `"-O
tool=optstr"`. Instead a `-o "output tool"` may execute another `-o "output
tool"` and merge the output into its own.
<div id="getopt-2">
### `getopt` phase 2
</div>
@@ -854,6 +883,7 @@ matched by a saved argument.
The match is made with the (possibly modified) phase 0 argument.
<div id="getopt-3">
### `getopt` phase 3
</div>
@@ -868,6 +898,7 @@ The `-o "output tool"` is not allowed to output another `"-o tool"` or a `"-O
tool=optstr"`. Instead a `-o "output tool"` may execute another `-o "output
tool"` and merge the output into its own.
<div id="command-line-option-order">
### Command line option order
</div>
@@ -931,6 +962,7 @@ 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.
<div id="substitution-tokens">
### Substitution tokens
</div>
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
#
# format-headers.sh - format select headers and preceding empty lines in entry README.md files
#
# We formats headers in README.md files so that before a line that starts with
# '##' (as in '^##') that have specific names there are two blank lines (\n\n).
#
# Script written by Landon with minor improvements by Cody Boone Ferguson where
# now it only acts on files under git control rather than any README.md file in
# the [0-9]{4} directories.
#
# 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,
# provided that the above copyright, this permission notice and text
# this comment, and the disclaimer below appear in all of the following:
#
# supporting documentation
# source copies
# source works derived from this source
# binaries derived from this source or from derived source
#
# LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
# EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# chongo (Landon Curt Noll, http://www.isthe.com/chongo/index.html) /\oo/\
#
# Share and enjoy! :-)
for i in $(git ls-files '[0-9][0-9][0-9][0-9]/*README.md'); do
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(To build):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Bugs and \(Mis\)features):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(To use):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Try):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Original code):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Original build):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Original try):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Original use):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Alternate code):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Alternate build):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Alternate try):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Alternate use):?\n\n*([^\n])?/$1\n\n### $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Judges. remarks):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Author.s remarks):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Authors. remarks):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
perl -0777 -p -i -e 's/([^\n]\n)\n*##*[[:space:]]*(Copyright and CC BY-SA 4.0 License):?\n\n*([^\n])?/$1\n\n## $2:\n\n$3/' "$i"
done
+10
View File
@@ -490,6 +490,12 @@ that is <strong>NOT</strong> an IOCCC markdown best practice.</p>
details.</p>
<p>We recommend that this tool be invoked via the top level <code>Makefile</code> by:</p>
<pre><code> make find_missing_links</code></pre>
<div id="format-headers">
<h3 id="format-headers.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/format-headers.sh">format-headers.sh</a></h3>
</div>
<p>Format select headers and preceding empty lines in entry README.md files.</p>
<p>Usage:</p>
<pre><code> bin/format-headers.sh</code></pre>
<div id="gen-authors">
<h3 id="gen-authors.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/gen-authors.sh">gen-authors.sh</a></h3>
</div>
@@ -628,14 +634,18 @@ inventory, see the <a href="../1984/anonymous/index.html#inventory">inventory in
1984/anonymous</a>.</p>
<p>This tool is used in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/md2html.cfg">bin/md2html.cfg</a> file as part of
the <a href="index.html#md2html">md2html tool</a>.</p>
<div id="output-year-index">
<h3 id="output-year-index.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/output-year-index.sh">output-year-index.sh</a></h3>
</div>
<p>Output the inventory for a given year’s winning entries in HTML form. In other
words in <a href="../1984/index.html">1984</a> it would list, as links, the four winning
entries, which you can see directly at <a href="../1984/index.html#inventory">1984
inventory</a>.</p>
<p>This tool is used in the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/md2html.cfg">bin/md2html.cfg</a> file as part of
the <a href="index.html#md2html">md2html tool</a>.</p>
<div id="pandoc-wrapper">
<h3 id="pandoc-wrapper.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/pandoc-wrapper.sh">pandoc-wrapper.sh</a></h3>
</div>
<p>Wrapper tool to run <code>pandoc(1)</code>.</p>
<div id="quick-readme2index">
<h3 id="quick-readme2index.sh"><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/bin/quick-readme2index.sh">quick-readme2index.sh</a></h3>