Skip to content

Commit

Permalink
Remove duplicate require of clojure.string
Browse files Browse the repository at this point in the history
  • Loading branch information
adham-omran committed Jul 24, 2024
1 parent 5764295 commit 3cf2a73
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/scicloj/clay/v2/item.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(ns scicloj.clay.v2.item
(:require [clojure.pprint :as pp]
[clojure.string :as string]
[charred.api :as charred]
[scicloj.clay.v2.files :as files]
[scicloj.clay.v2.util.image :as util.image]
Expand All @@ -23,14 +22,13 @@

(defn escape [string]
(-> string
(string/escape
(str/escape
{\< "&lt;"
\> "&gt;"
\& "&amp;"
\" "&quot;"
\' "&apos;"})))


(defn clojure-code-item [{:keys [tag hiccup-element md-class]}]
(fn [string-or-strings]
(let [strings (->> string-or-strings
Expand All @@ -53,7 +51,7 @@
```
:::
" (name md-class) s)))
(string/join "\n"))})))
(str/join "\n"))})))

(def source-clojure
(clojure-code-item {:tag :source-clojure
Expand All @@ -65,8 +63,6 @@
:hiccup-element :code.sourceCode.language-clojure.printed-clojure
:md-class :printedClojure}))



(defn just-println [value]
(-> value
println
Expand All @@ -84,7 +80,7 @@
(defn md [text]
{:md (->> text
in-vector
(string/join "\n"))})
(str/join "\n"))})

(defn katex-hiccup [string]
[:div
Expand All @@ -98,7 +94,7 @@
{:md (->> text
in-vector
(map (partial format "$$%s$$"))
(string/join "\n"))
(str/join "\n"))
:hiccup (->> text
in-vector
(map katex-hiccup)
Expand All @@ -119,7 +115,6 @@
{:md string
:hiccup [:p string]})


(def next-id
(let [*counter (atom 0)]
#(str "id" (swap! *counter inc))))
Expand Down Expand Up @@ -165,7 +160,6 @@
};"))]]
:deps [:cytoscape]})


(defn echarts [{:as context
:keys [value]}]
{:hiccup [:div
Expand All @@ -181,7 +175,6 @@
};"))]]
:deps [:echarts]})


(defn plotly [{:as context
{:keys [data layout config]
:or {layout {}
Expand All @@ -197,7 +190,6 @@
(charred/write-json-str config))]]
:deps [:plotly]})


(defn portal [value]
{:hiccup [:div
[:script
Expand Down Expand Up @@ -226,11 +218,10 @@
[:a {:href url} path]
path)]]])]})


(defn html [html]
{:html (->> html
in-vector
(string/join "\n"))})
(str/join "\n"))})

(defn image [{:keys [value
full-target-path
Expand All @@ -245,17 +236,16 @@
image
".png")]
(when-not
(util.image/write! image "png" png-path)
(util.image/write! image "png" png-path)
(throw (ex-message "Failed to save image as PNG.")))
{:hiccup [:img {:src (-> png-path
(string/replace
(str/replace
(re-pattern (str "^"
base-target-path
"/"))
""))}]
:item-class "clay-image"}))


(defn vega-embed [{:keys [value
full-target-path
base-target-path]
Expand All @@ -270,7 +260,7 @@
".csv")]
(spit csv-path values)
{:url (-> csv-path
(string/replace
(str/replace
(re-pattern (str "^"
base-target-path
"/"))
Expand All @@ -284,7 +274,6 @@
(->> (format "vegaEmbed(document.currentScript.parentElement, %s);")))]]
:deps [:vega]}))


(defn video [{:keys [youtube-id
iframe-width
iframe-height
Expand All @@ -309,7 +298,7 @@
(defn observable [code]
{:md (->> code
in-vector
(string/join "\n")
(str/join "\n")
(format "
```{ojs}
//| echo: false
Expand Down

0 comments on commit 3cf2a73

Please sign in to comment.