fix: complete page-reference clear block content

pull/3068/head
rcmerci 2021-11-04 16:12:56 +08:00 committed by Tienson Qin
parent c7118a4e36
commit 82276becca
1 changed files with 6 additions and 4 deletions

View File

@ -606,18 +606,20 @@
;; Add documentation
(defn replace-first [pattern s new-value]
(when-let [first-index (string/index-of s pattern)]
(str new-value (subs s (+ first-index (count pattern))))))
(if-let [first-index (string/index-of s pattern)]
(str new-value (subs s (+ first-index (count pattern))))
s))
(defn replace-last
([pattern s new-value]
(replace-last pattern s new-value true))
([pattern s new-value space?]
(when-let [last-index (string/last-index-of s pattern)]
(if-let [last-index (string/last-index-of s pattern)]
(let [prefix (subs s 0 last-index)]
(if space?
(concat-without-spaces prefix new-value)
(str prefix new-value))))))
(str prefix new-value)))
s)))
;; copy from https://stackoverflow.com/questions/18735665/how-can-i-get-the-positions-of-regex-matches-in-clojurescript
#?(:cljs