From 7fc2422f038e0f56a9ac489eb4676b7b4bf2b6b1 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 25 Feb 2024 15:37:46 +0200 Subject: (awk-edits/MEL) Properly implemented one line tags --- awk-edits/MEL-parser.awk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index 248eff2..6cf0514 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -35,6 +35,8 @@ BEGIN { function usesMEL() { MELOPEN = "o" MELCLOSE = "c" + MELLINEOPEN = "lo" + MELLINECLOSE = "lc" MELINSERT = "i" MELPARAGRAPH = "p" MELLINE = "l" @@ -52,6 +54,7 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { newLine = "" lineCopy = $0 paragraphed = 0 + append = "" while (match(lineCopy, /&(((::|[[{(:.])[^[:space:].:;[{(<>)}\]&]+)|[\]})])/)) { RSTART += 5 RLENGTH -= 5 @@ -67,12 +70,12 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELINSERT] } - # Inside one line TODO + # Inside one line else if (substr(lineCopy, RSTART, 2) == "::") { name = substr(lineCopy, RSTART + 2, RLENGTH - 2) - # RLENGTH = length(lineCopy) - replaceWith = MEL[name, MELLINE] + replaceWith = MEL[name, MELLINEOPEN] + append = append MEL[name, MELLINECLOSE] } # Inside paragraph else if (substr(lineCopy, RSTART, 1) == ":") { @@ -93,7 +96,7 @@ melInsideCode == 0 && /^[ \t]*(

|

)?&[{[()\]}:.]/ { newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith lineCopy = substr(lineCopy, RSTART + RLENGTH) } - $0 = newLine lineCopy - if (paragraphed == 0 && length(newLine) > 0) + $0 = newLine lineCopy append + if (paragraphed == 0 && newLine != "") gsub(/(

|<\/p>)/, "") } -- cgit v1.3.1-23-gd82d