fix: links are partially broken inside the front matter

Related to #1145
pull/1146/head
Tienson Qin 2021-01-17 16:10:15 +08:00
parent cdf9492357
commit 05f1b02d74
3 changed files with 17 additions and 17 deletions

View File

@ -40,11 +40,9 @@
(sep-by-comma-or-quote)
(map page-ref-un-brackets!)
(distinct))]
(if (and (coll? result)
(or (> (count result) 1)
;; Tag
(and (string? result)
(string/starts-with? result "#"))))
(if (or (coll? result)
(and (string? result)
(string/starts-with? result "#")))
(let [result (if coll? result [result])
result (map (fn [s] (string/replace s #"^#+" "")) result)]
(set result))

View File

@ -1,3 +1,3 @@
(ns frontend.version)
(defonce version "0.0.5.1-5")
(defonce version "0.0.5.1-6")

View File

@ -39,20 +39,22 @@
"foo bar" "foo bar"
"foo, bar" #{"foo" "bar"}
"foo \"bar\"" #{"foo" "bar"}
"[[foo]] [[bar]]" #{"[[foo]] [[bar]]"}
"[[foo]] [[bar]]" #{"foo]] [[bar"}
"[[foo]],[[bar]]" #{"foo", "bar"}
"[[foo]], [[bar]]" #{"foo", "bar"}
"[[foo]]" "foo"
"[[nested [[foo]]]]" "nested [[foo]]"
"[[nested [[foo]]]], [[foo]]" #{"nested [[foo]]" "foo"}))
"[[foo]]" #{"foo"}
"[[nested [[foo]]]]" #{"nested [[foo]]"}
"[[nested [[foo]]]], [[foo]]" #{"nested [[foo]]" "foo"}
"#tag," #{"tag"}
"#tag1,#tag2" #{"tag1" "tag2"}))
(defn extract-level-spaces
[]
(testing "markdown"
(are [x y] (= (text/extract-level-spaces x :markdown) y)
"# foobar" "# "
"## foobar" "## "
"##################### foobar" "##################### "))
"# foobar" "# "
"## foobar" "## "
"##################### foobar" "##################### "))
(testing "org mode"
(are [x y] (= (text/extract-level-spaces x :org) y)
"* foobar" "* "
@ -77,10 +79,10 @@
"** foobar" "foobar"
"********************* foobar" "foobar"))
(testing "org without spaces between the `#` and title"
(are [x y] (= (text/remove-level-spaces x :org) y)
"*foobar" "foobar"
"**foobar" "foobar"
"*********************foobar" "foobar")))
(are [x y] (= (text/remove-level-spaces x :org) y)
"*foobar" "foobar"
"**foobar" "foobar"
"*********************foobar" "foobar")))
(defn append-newline-after-level-spaces
[]