From 61b80c516ffac881d99d486c989d0deeb80c822b Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 9 Aug 2019 22:07:58 -0400 Subject: [PATCH] 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. --- src/post2html | 9 +++++++++ 1 file changed, 9 insertions(+) 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 } ' }