diff --git a/markdown.awk b/markdown.awk index a0fcc2d..405e209 100644 --- a/markdown.awk +++ b/markdown.awk @@ -5,6 +5,7 @@ BEGIN { function parse_header(str, hnum, content) { if (substr(str, 1, 1) == "#") { + gsub(/ *#* *$/, "", str); match(str, /#+/); hnum = RLENGTH; @@ -364,7 +365,7 @@ function parse_block(str) { } function line_continues(body, line) { - if (match(body, /^ /) && match(line, /^ /)) + if (match(body, /^ /) && (match(line, /^ /) || line == "")) return 1; if (match(body, /^```\n/) && !match(body, /\n```$/)) diff --git a/test.sh b/test.sh index 7ae2765..9f2f17c 100755 --- a/test.sh +++ b/test.sh @@ -86,6 +86,12 @@ check <<-EOF

Header3

EOF +check <<-EOF +# Header ### +--- +

Header

+EOF + check <<-EOF underlined header 1 =================== @@ -150,11 +156,15 @@ EOF check <<-"EOF" code + indented by + spaces ---
code
+
 indented by
+
 spaces
EOF