Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mtg@gnu.org>2019-08-09 22:07:58 -0400
committerMike Gerwitz <mtg@gnu.org>2020-03-31 23:47:38 -0400
commit61b80c516ffac881d99d486c989d0deeb80c822b (patch)
tree974a93a7cb7b7cad308fa93fde6eb8c876a3d0a3
parentb3ad4f7599f7193519ee726017e69adce911c414 (diff)
downloadthoughts-61b80c516ffac881d99d486c989d0deeb80c822b.tar.gz
thoughts-61b80c516ffac881d99d486c989d0deeb80c822b.tar.bz2
thoughts-61b80c516ffac881d99d486c989d0deeb80c822b.zip
src/post2html: Ability to reference content of previous fence
I'll be using this to show example HTML code and then output it as actual HTML to be rendered as part of the article. Otherwise the HMTL has to be duplicated and maintained in multiple places. An alternative is to include a file, but that is much less convenient for smaller snippets.
-rwxr-xr-xsrc/post2html9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/post2html b/src/post2html
index 8fd821f..eeafa77 100755
--- a/src/post2html
+++ b/src/post2html
@@ -109,6 +109,15 @@ prefmt()
next
}
+ # reference to the content of the last fence (e.g. if a previous
+ # code block is HTML and we want to render it as an example)
+ /^```/ {
+ gather = !gather
+ if ( gather ) gblock = ""
+ }
+ !/^```/ && gather { gblock = gblock $0 "\n" }
+ !gather && /^ *@LASTFENCE@$/ { print gblock; next }
+
{ print }
'
}