From 0ebdbe72c4fd1a93e5c021d2f9e1f924c61d7f12 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Wed, 28 Jul 2021 22:47:04 +0000 Subject: [PATCH] Add support for horizontal rules --- markdown.awk | 6 ++++++ test.sh | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/markdown.awk b/markdown.awk index 600817e..8aeca14 100644 --- a/markdown.awk +++ b/markdown.awk @@ -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 "
"; + } else if (match(str, /^[-+*][[:space:]]/) || match(str, /^[[:digit:]]\.[[:space:]]/)) { return parse_list(str); } diff --git a/test.sh b/test.sh index e56b701..be8f946 100755 --- a/test.sh +++ b/test.sh @@ -423,5 +423,20 @@ Link with title: [foo](/bar "baz")

Link with title: foo

EOF +check <<-"EOF" +Horizontal rules: + +- - - + +* * * + +_ _ _ +--- +

Horizontal rules:

+
+
+
+EOF + echo echo "All tests passed"