Skip to content

Commit

Permalink
Fix #12: Links where the label has dashes (-) do not get parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
Asko Nomm committed Apr 10, 2022
1 parent 8aa7f6a commit da5edae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/clarktown/parsers/link_and_image.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"Renders all occurring links and images."
[block _]
(loop [block block
matches (-> (re-seq #"\!?\[(\w+( \w+)*)\]\((.*?)\)" block)
matches (-> (re-seq #"\!?\[([a-zA-Z0-9\-\.\,]+( [a-zA-Z0-9\-\.\,]+)*)\]\((.*?)\)" block)
distinct)]
(if (empty? matches)
block
Expand Down
3 changes: 3 additions & 0 deletions test/clarktown/parsers/link_and_image_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
(is (= (link-and-image/render "[This is a link](https://example.com)" nil)
"<a href=\"https://example.com\">This is a link</a>"))

(is (= (link-and-image/render "[This-is-a-link](https://example.com)" nil)
"<a href=\"https://example.com\">This-is-a-link</a>"))

(is (= (link-and-image/render "[x] [label](link)" nil)
"[x] <a href=\"link\">label</a>"))

Expand Down

0 comments on commit da5edae

Please sign in to comment.