Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mtg@gnu.org>2019-07-27 14:27:35 -0400
committerMike Gerwitz <mtg@gnu.org>2020-03-31 23:47:12 -0400
commit5b84305d8e0223f163c1f5ec606d6e96c3b5fc77 (patch)
tree6b6818baf094094ac2e980e4da5666c367b951ab
parent1f6ea32a459e0d800ffc06bbe4f01774847ef028 (diff)
downloadthoughts-5b84305d8e0223f163c1f5ec606d6e96c3b5fc77.tar.gz
thoughts-5b84305d8e0223f163c1f5ec606d6e96c3b5fc77.tar.bz2
thoughts-5b84305d8e0223f163c1f5ec606d6e96c3b5fc77.zip
src/post2html (prefmt): Ties and newline stripping
I hate Markdown as a format for disciplined writing, especially when I want macros (mostly semantic), indexes, and such. I was originally going to use LaTeX with Pandoc, but it lacks support for inline HTML and such, and I do not want to distract too much from the work that I want to be doing.
-rwxr-xr-xsrc/post2html33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/post2html b/src/post2html
index 803fef7..8fd821f 100755
--- a/src/post2html
+++ b/src/post2html
@@ -83,6 +83,37 @@ hgroup-wrap()
}
+# Pre-format Markdown files before they get to Pandoc
+#
+# These may be able to be implemented as Pandoc filters, but I haven't had
+# the time to research that yet. This is actually a fitting real-world
+# demonstration of incremental development / MVP that I'm writing about at
+# the time that this comment was written (MyCustomBB Part I)!
+prefmt()
+{
+ awk '
+ triml {
+ gsub( /^ +/, "" )
+ triml = 0
+ }
+
+ # ties
+ { $0 = gensub( /([^\\])~/, "\\1 ", "g" ) }
+ { $0 = gensub( /\\~/, "~", "g" ) }
+
+ # TeX-style newline removal
+ /%$/ {
+ gsub( /%$/, "" )
+ printf "%s", $0
+ triml = 1
+ next
+ }
+
+ { print }
+ '
+}
+
+
# Generate HTML from post. Note that `pagetitle' is set just to suppress
# Pandoc warnings about it missing; it is unused.
main()
@@ -97,7 +128,7 @@ main()
--base-header-level=1 \
-B <( src/mkheader post @__PAGE_TITLE__@ ) \
-A src/footer.tpl.htm \
- < "$file" \
+ < <( prefmt < "$file" ) \
| src/h12title @__PAGE_TITLE__@ \
| hgroup-wrap "$date" "$file"
}