From 88b9b2dee2bfef32427a2b1e9bc5a7e5d4008112 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Sun, 17 Mar 2024 19:02:27 -0400 Subject: [PATCH] src/post2html: Disable TeX-style tie parsing in fences Code fences are meant to indicate literal text, not formatted. --- src/post2html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/post2html b/src/post2html index b68ab7c..b332338 100755 --- a/src/post2html +++ b/src/post2html @@ -98,11 +98,11 @@ prefmt() } # ties - { $0 = gensub( /([^\\])~/, "\\1 ", "g" ) } - { $0 = gensub( /\\~/, "~", "g" ) } + !infence { $0 = gensub( /([^\\])~/, "\\1 ", "g" ) } + !infence { $0 = gensub( /\\~/, "~", "g" ) } # TeX-style newline removal - /%$/ { + !infence && /%$/ { gsub( /%$/, "" ) printf "%s", $0 triml = 1 @@ -113,6 +113,7 @@ prefmt() # code block is HTML and we want to render it as an example) /^```/ { gather = !gather + infence = gather if ( gather ) gblock = "" } !/^```/ && gather { gblock = gblock $0 "\n" }