Add more edge cases to code and header handling

This commit is contained in:
Konstantin Nazarov 2021-07-26 22:01:43 +00:00
parent da65bb16f0
commit 2f982164ef
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 12 additions and 1 deletions

View file

@ -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```$/))

10
test.sh
View file

@ -86,6 +86,12 @@ check <<-EOF
<h3>Header3</h3>
EOF
check <<-EOF
# Header ###
---
<h1>Header</h1>
EOF
check <<-EOF
underlined header 1
===================
@ -150,11 +156,15 @@ EOF
check <<-"EOF"
code
indented by
spaces
---
<pre><code>code
indented by
spaces</code></pre>
EOF