Summary Files Commits Branches @commit @diff @stats
path: root / single.awk
diff options
context:
space:
mode:
Commit128cbee2729d0638ab1f753df3dfecbe23ee40c0 (patch)
Author
 Syndamia <kamen@syndamia.com>
2024-12-31 15:35:53 +0200
Committer
 Syndamia <kamen@syndamia.com>
2024-12-31 15:35:53 +0200
Files4922a3df073d000726130360076f2992818643e7 /single.awk
csg-128cbee2729d0638ab1f753df3dfecbe23ee40c0.tar
csg-128cbee2729d0638ab1f753df3dfecbe23ee40c0.tar.gz
csg-128cbee2729d0638ab1f753df3dfecbe23ee40c0.zip
Parent6e6789af2897b6a73766db33eb174e1ac7bb3f68 (diff)
feat(single): Add function which works like next but properly handles buffered printing
1 files changed, 10 insertions, 1 deletions
-rw-r--r--single.awk11
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 = "<p>" $0 }
# After all $0 parsing
{
+ __buffered_print()
+}
+function __buffered_print() {
empty0 = empty($0)
emptyP1 = empty(P1)