diff --git a/src/nextjournal/clerk/viewer.cljc b/src/nextjournal/clerk/viewer.cljc index 78539badb..d0ed39a19 100644 --- a/src/nextjournal/clerk/viewer.cljc +++ b/src/nextjournal/clerk/viewer.cljc @@ -748,11 +748,24 @@ :cljs {:path link :title link})) +(defn process-href [^String href] + #?(:cljs href + :clj (if (.getScheme (URI. href)) + href + (let [{:keys [path fragment]} (process-internal-link href)] + (doc-url path fragment))))) + +#_(process-href "foo.bar.dang") +#_(process-internal-link "foo.bar.dang") + #_(process-internal-link "notebooks/rule_30.clj") #_(process-internal-link "viewers.html") #_(process-internal-link "how-clerk-works/hashes") #_(process-internal-link "rule-30/first-generation") +(defn update-if [m k f] (if (k m) (update m k f) m)) +#_(update-if {:n "42"} :n #(Integer/parseInt %)) + (declare html) (def markdown-viewers @@ -782,7 +795,7 @@ {:name :nextjournal.markdown/strong :transform-fn (into-markup [:strong])} {:name :nextjournal.markdown/monospace :transform-fn (into-markup [:code])} {:name :nextjournal.markdown/strikethrough :transform-fn (into-markup [:s])} - {:name :nextjournal.markdown/link :transform-fn (into-markup #(vector :a (:attrs %)))} + {:name :nextjournal.markdown/link :transform-fn (into-markup #(vector :a (update-if (:attrs %) :href process-href)))} {:name :nextjournal.markdown/internal-link :transform-fn (update-val (fn [{:keys [text]}] @@ -1169,13 +1182,6 @@ (map (juxt #(list 'quote (symbol %)) #(->> % deref deref (list 'quote)))) (extract-sync-atom-vars doc))))) -(defn update-if [m k f] - (if (k m) - (update m k f) - m)) - -#_(update-if {:n "42"} :n #(Integer/parseInt %)) - (declare html) (defn home? [{:keys [nav-path]}]