From b54918c9b0b85a7c41747c770d0c3e6e6995155e Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Wed, 28 Jul 2021 22:31:44 +0000 Subject: [PATCH] Lists within blockquotes and tabs in lists --- markdown.awk | 53 +++++++++++++++++++++++++++++++++++++--------------- test.sh | 17 +++++++++++++++++ 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/markdown.awk b/markdown.awk index 405e209..600817e 100644 --- a/markdown.awk +++ b/markdown.awk @@ -84,8 +84,8 @@ function join_lines(first, second, sep) { } function strip_list(str) { - gsub(/^ *[-+*] /, "", str); - gsub(/^ *[[:digit:]]*\. /, "", str); + gsub(/^[[:space:]]*[-+*][[:space:]]/, "", str); + gsub(/^[[:space:]]*[[:digit:]]*\.[[:space:]]/, "", str); return str; } @@ -99,7 +99,8 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) for (i in lines) { line = lines[i]; - if (match(line, /^ *[-+*] /) || match(line, /^ *[[:digit:]]+\. /)) + if (match(line, /^[[:space:]]*[-+*][[:space:]]/) || + match(line, /^[[:space:]]*[[:digit:]]+\.[[:space:]]/)) str = join_lines(str, line, "\n"); else str = join_lines(rstrip(str), lstrip(line), " "); @@ -108,7 +109,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) split(str, lines, "\n") indent = match(str, /[^ ]/); - is_bullet = match(str, /^ *[-+*] /) + is_bullet = match(str, /^[[:space:]]*[-+*][[:space:]]/) if (is_bullet) result = "\n
    \n"; } - if (is_bullet == 0 && match(line, / *[-+*] /)) { + if (is_bullet == 0 && match(line, /[[:space:]]*[-+*][[:space:]]/)) { is_bullet = 1; result = result "
\n