Add support for horizontal rules

This commit is contained in:
Konstantin Nazarov 2021-07-28 22:47:04 +00:00
parent b54918c9b0
commit 0ebdbe72c4
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
2 changed files with 21 additions and 0 deletions

View file

@ -354,6 +354,12 @@ function parse_block(str) {
else if (substr(str, 1, 1) == ">") {
return parse_blockquote(str);
}
else if ( \
match(str, /^[[:space:]]*\*[[:space:]]*\*[[:space:]]*\*[[:space:]]*$/) ||
match(str, /^[[:space:]]*-[[:space:]]*-[[:space:]]*-[[:space:]]*$/) ||
match(str, /^[[:space:]]*_[[:space:]]*_[[:space:]]*_[[:space:]]*$/)) {
return "<hr />";
}
else if (match(str, /^[-+*][[:space:]]/) || match(str, /^[[:digit:]]\.[[:space:]]/)) {
return parse_list(str);
}

15
test.sh
View file

@ -423,5 +423,20 @@ Link with title: [foo](/bar "baz")
<p>Link with title: <a href="/bar" title="baz">foo</a></p>
EOF
check <<-"EOF"
Horizontal rules:
- - -
* * *
_ _ _
---
<p>Horizontal rules:</p>
<hr />
<hr />
<hr />
EOF
echo
echo "All tests passed"