From 128cbee2729d0638ab1f753df3dfecbe23ee40c0 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 31 Dec 2024 15:35:53 +0200 Subject: feat(single): Add function which works like next but properly handles buffered printing --- single.awk | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'single.awk') diff --git a/single.awk b/single.awk index 5ddcb94..87e6734 100644 --- a/single.awk +++ b/single.awk @@ -50,6 +50,12 @@ function empty(value) { return value == "" } +function _next() { + __buffered_print() + not_paragraph = 1 + next +} + { not_paragraph_p1 = not_paragraph not_paragraph = 0 @@ -65,7 +71,7 @@ function empty(value) { # Inline HTML /^[ \t]*<\/?[0-9A-Za-z]+/ { - not_paragraph = 1 + _next() } # Blockquotes @@ -125,6 +131,9 @@ emptyP1 && !empty0 && !not_paragraph { $0 = "

" $0 } # After all $0 parsing { + __buffered_print() +} +function __buffered_print() { empty0 = empty($0) emptyP1 = empty(P1) -- cgit v1.3.1-23-gd82d