From e5291798cb2d4a92293d377fb58f90cc4045c9b6 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sat, 10 Jul 2021 22:47:07 +0000 Subject: [PATCH] Remove unnecessary spaces in headers --- markdown.awk | 3 ++- test.sh | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/markdown.awk b/markdown.awk index 9db96c5..b2b8024 100644 --- a/markdown.awk +++ b/markdown.awk @@ -8,7 +8,8 @@ function parse_header(str, hnum, content) { match(str, /#+/); hnum = RLENGTH; - content = parse_line(substr(str, hnum + 1, length(str) - hnum )); + gsub(/^#+ */, "", str); + content = parse_line(str); return "" content ""; } if (match(body, /^[^\n]+\n=+$/)) { diff --git a/test.sh b/test.sh index 9abe49d..982405d 100755 --- a/test.sh +++ b/test.sh @@ -72,7 +72,7 @@ check <<-EOF # Header body --- -

Header

+

Header

body

EOF @@ -81,9 +81,9 @@ check <<-EOF ## Header2 ### Header3 --- -

Header1

-

Header2

-

Header3

+

Header1

+

Header2

+

Header3

EOF check <<-EOF