|
|
@@ -44,6 +44,14 @@
|
|
|
(when (string? result)
|
|
|
result)))
|
|
|
|
|
|
+(defn- markdown-link?
|
|
|
+ [markup current-line pos]
|
|
|
+ (and current-line
|
|
|
+ (= (util/nth-safe markup pos) "]")
|
|
|
+ (= (util/nth-safe markup (inc pos)) "(")
|
|
|
+ (string/includes? (subs current-line 0 pos) "[")
|
|
|
+ (string/includes? (subs current-line pos) ")")))
|
|
|
+
|
|
|
;; (find-position "** hello _w_" "hello w")
|
|
|
(defn find-position
|
|
|
[markup text]
|
|
|
@@ -66,7 +74,8 @@
|
|
|
(recur t1 r2 i1 (inc i2))
|
|
|
|
|
|
:else
|
|
|
- (recur r1 t2 (inc i1) i2))))]
|
|
|
+ (recur r1 t2 (inc i1) i2))))
|
|
|
+ current-line (get-current-line-by-pos markup pos)]
|
|
|
(cond
|
|
|
(and (= (util/nth-safe markup pos)
|
|
|
(util/nth-safe markup (inc pos))
|
|
|
@@ -76,12 +85,15 @@
|
|
|
(contains? inline-special-chars (util/nth-safe markup pos))
|
|
|
(let [matched (->> (take-while inline-special-chars (util/safe-subs markup pos))
|
|
|
(apply str))
|
|
|
- current-line (get-current-line-by-pos markup pos)
|
|
|
matched? (and current-line (string/includes? current-line (string/reverse matched)))]
|
|
|
(if matched?
|
|
|
(+ pos (count matched))
|
|
|
pos))
|
|
|
|
|
|
+ (markdown-link? markup current-line pos)
|
|
|
+ (let [idx (string/index-of (subs current-line pos) ")")]
|
|
|
+ (+ pos (inc idx)))
|
|
|
+
|
|
|
:else
|
|
|
pos))
|
|
|
(catch js/Error e
|