From 71fd4ce667980be72f7c8f9265ccb345ceb37f6a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 1 Jan 2025 14:38:19 +0200 Subject: fix(single): Properly remove identation of list item contents --- single.awk | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'single.awk') diff --git a/single.awk b/single.awk index b4b4c89..2a92373 100644 --- a/single.awk +++ b/single.awk @@ -161,7 +161,7 @@ function end_list() { PNappnd("") --list_level } -function start_list(level, type) { +function start_list(level, type, shift) { ## Every two columns we define a new level level = int((level + 2) / 2) ## If list definition is the first line inside a code block @@ -182,6 +182,7 @@ function start_list(level, type) { if (list_level < level || lists[list_level] != type) { P1 = P1 ORS "<" (type == "." ? "o" : "u") "l>
  • " lists[level] = type + lists_shift[level] = shift list_level = level } else { @@ -195,23 +196,27 @@ function start_list(level, type) { match($0, /^[ \t]*[*+-] /) level = RLENGTH - 2 type = char($0, RSTART + RLENGTH - 2) - sub(/^[^*+-]*[*+-] /, "") + match($0, /^[^*+-]*[*+-] /) + shift = RLENGTH + sub_match("") - start_list(level, type) + start_list(level, type, shift) } !inside_codeblock && /^[ \t]*[0-9]+\. / { ## Ordered list match($0, /^[ \t]*/) level = RLENGTH type = "." - sub(/^[^.]+\. /, "") + match($0, /^[^.]+\. /) + shift = RLENGTH + sub_match("") - start_list(level, type) + start_list(level, type, shift) } list_level > 0 && !list_started && /[^ \t]/ { ## Non-list line match($0, /^[ \t]*/) level = int((RLENGTH + 2) / 2) - $0 = substr($0, 2 * level - 1) not_paragraph = 1 + sub("^[ \t]{1," lists_shift[list_level] "}", "") while (list_level >= level && emptyP1) { end_list() -- cgit v1.3.1-23-gd82d