summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsko Nomm <asko@bien.ee>2022-04-11 00:33:47 +0200
committerAsko Nomm <asko@bien.ee>2022-04-11 00:33:47 +0200
commitda5edae76e75f904e395b1b712192a4d9be35ace (patch)
treeeac23795f03add98b3b0b1ef2e3302b8905ec674
parent8aa7f6aac2ca359b810bdc4f7a5ad143c6642a06 (diff)
Fix #12: Links where the label has dashes (`-`) do not get parsed
-rw-r--r--src/clarktown/parsers/link_and_image.clj2
-rw-r--r--test/clarktown/parsers/link_and_image_test.clj3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/clarktown/parsers/link_and_image.clj b/src/clarktown/parsers/link_and_image.clj
index fb8ad31..3be2efe 100644
--- a/src/clarktown/parsers/link_and_image.clj
+++ b/src/clarktown/parsers/link_and_image.clj
@@ -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
diff --git a/test/clarktown/parsers/link_and_image_test.clj b/test/clarktown/parsers/link_and_image_test.clj
index 5630306..348a8f9 100644
--- a/test/clarktown/parsers/link_and_image_test.clj
+++ b/test/clarktown/parsers/link_and_image_test.clj
@@ -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>"))