Avery's BlogHome Posts Projects Sitemap License
#vim: set colorcolumn=81 ft=sh:hi ColorColumn ctermbg=224 "------
# Due to ambiguity in the markup format, you probably intended to
# go to a link labeled "$/build.sh". This is really a link to
# "$/build.sh.txt" in the unformatted post. Here is a proper
# link: $/build.sh.txt. This was
# fixed in this document through a hack I'm not particularly
# proud of.
txt2html() {
	# cut off the modeline and title
	tail -n +3 |

	# convert lines starting with `##` to comments
	sed 's|^\(##.*\)$|\1|' |
	# convert <,> to HTML-compatible format
	sed 's|<|\<|g' |
	sed 's|>|\>|g' |
	# convert italics to html
	sed 's|\||g' |
	sed 's|}\*||g' |
	# convert bold to html
	sed 's|||g' |
	sed 's|||g' |
	# convert codeblocks into css-ified codeblocks
	sed 's|``[`]{|
|' |
	sed 's|}[`]``|
|' | # convert inline codeblocks into css-ified codeblocks sed 's|`[{]||g' | sed 's|[}]`||g' | # See next comment. $/url -> /url.html sed 's|\([$]/\)\([^ \)]*\)[.]txt\([,.]\)|\1\2\3|g' | sed 's|\([$]/\)\([^ \)<>]*\)[.]txt|\1\2|g' | # convert `$/url` to html links relative to root domain #sed 's|\([$]/\)\([^ \)]*\)\([,.]\)|\1\2\3|g' | sed 's!^\([$]/\)\([^ \)<>]*\)!\1\2!g;s!\([^>]\)\([$]/\)\([^ \)<>]*\)!\1\2\3!g' | # See next comment. %/url -> url.html sed 's|\(%/\)\([^ \)]*\)[.]txt\([,.]\)|\1\2\3|g' | sed 's|\(%/\)\([^ \)<>]*\)[.]txt|\1\2|g' | # convert `%/url` to html links relative to current directory sed 's!^\(%/\)\([^ \)<>]*\)!\1\2!g;s!\([^>]\)\(%/\)\([^ \)<>]*\)!\1\2\3!g' | # convert `#/url` to html links sed 's|\([#]/\)\([^ )]*\)\([,.)] \)|\1\2\3|g' | sed 's|\([#]/\)\([^ )<>]*\)|\1\2|g' | # convert `-[0-9]` into IDs sed 's|^\([ -]*\)\[\([0-9.][0-9.]*\)\]|\1[\2]|g' | # convert `[0-9]` into references to IDs sed 's|\([^\"#]\)\[\([0-9.][0-9.]*\)\]|\1[\2]|g' | # convert `-{0-9 into references to footnotes sed 's|^\(- [^{]*\){\([0-9]*\)}|\1{\2}|g' | # convert 0-9 into footnotes sed 's|{\([0-9]*\)}|{\1}|g' | # set content sed '/%%CONTENT%%/r /dev/stdin' html_template | sed '/%%CONTENT%%/d' | # set title sed "s|#Site build script|${1:-Index}|" } { # process arguments if available, else all *.txt [ $# -eq 0 ] && find . -name '*.txt' | grep -ve 'robots.txt$' | tee /dev/stderr while [ ! $# -eq 0 ]; do case "$1" in sitemap*) shift break ;; esac printf '%s\n' "$1" shift done } | while read -r PAGE; do title=$(sed '2p;d' "$PAGE") printf 'txt2html %s\n' "$title" txt2html "$title" < "$PAGE" > "${PAGE%%.txt}.html" [ "$PAGE" = ./build.sh.txt ] && sed -i 's|<|<|g;s|>|>|g' "${PAGE%%.txt}.html" done find . -type f ! -name \*.gz | while read -r FILE; do yes | gzip -9k "$FILE" >/dev/null 2>&1 done printf 'txt2html Sitemap\n' find . -name '*.html' | cut -d/ -f2- | grep -ve ^sitemap[.]html\$ -e ^latest[.]html\$ | while read -r PAGE; do printf '>$/%s\n' "$PAGE" "$(sed '2p;d' "${PAGE%%.html}.txt")" done | sed '/%%CONTENT%%/r /dev/stdin' html_template | sed '/%%CONTENT%%/d' | sed 's|#Site build script|Sitemap|' > sitemap.html
Anything But Chrome 88x31<HTML> Learn it today!Piracy Now! 88x31powered by estrogen 88x31 spinning estrogen pillmade with MY OWN TWO PAWS 88x31Made with uEMACS (Micro Emacs) 88x31uBlock Origin Now! 88x31Privacy Now! PGP 88x31TRANS RIGHTS NOW! 88x31Xenia Linux NOW! 88x31I need a nap Now! 88x31highly compressed bad apple 88x31Discord Messenger 88x31Choose Mozilla 88x31Monero Now! 88x31