Skip to content

Commit dab11df

Browse files
authored
Drop of js-interop dep (#42)
1 parent 19d945f commit dab11df

File tree

6 files changed

+16
-221
lines changed

6 files changed

+16
-221
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Bump commonmark to 0.24.0
88
* Bump markdown-it to 14.1.0
99
* Render `:code` according to spec into `<pre>` and `<code>` block with language class (see [#39](https://github.com/nextjournal/markdown/issues/39))
10+
* No longer depend on `applied-science/js-interop`
1011

1112
## 0.6.157
1213

deps.edn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{:paths ["src" "resources"]
2-
:deps {applied-science/js-interop {:mvn/version "0.3.3"}
3-
org.commonmark/commonmark {:mvn/version "0.24.0"}
2+
:deps {org.commonmark/commonmark {:mvn/version "0.24.0"}
43
org.commonmark/commonmark-ext-autolink {:mvn/version "0.24.0"}
54
org.commonmark/commonmark-ext-footnotes {:mvn/version "0.24.0"}
65
org.commonmark/commonmark-ext-task-list-items {:mvn/version "0.24.0"}
@@ -10,7 +9,7 @@
109
:aliases
1110
{:nextjournal/clerk
1211
{:extra-paths ["notebooks" "dev"]
13-
:extra-deps {io.github.nextjournal/clerk {:git/sha "f4c5488e36c8df11fe352889544e7deb9af73cb7"
12+
:extra-deps {io.github.nextjournal/clerk {:mvn/version "0.17.1102"
1413
:exclusions [io.github.nextjournal/markdown]}}
1514
:jvm-opts ["-Dclojure.main.report=stderr"
1615
#_"-Dclerk.resource_manifest={\"/js/viewer.js\" \"js/viewer.js\"}"] ;;
@@ -30,7 +29,8 @@
3029

3130
:dev
3231
{:extra-paths ["dev" "notebooks"]
33-
:extra-deps {org.babashka/http-client {:mvn/version "0.3.11"}
32+
:extra-deps {applied-science/js-interop {:mvn/version "0.3.3"}
33+
org.babashka/http-client {:mvn/version "0.3.11"}
3434
org.clojure/data.json {:mvn/version "2.4.0"}
3535
org.clojure/test.check {:mvn/version "1.1.1"}
3636
io.github.nextjournal/clerk {:git/sha "f4c5488e36c8df11fe352889544e7deb9af73cb7"

dev/nextjournal/markdown/graaljs.clj

Lines changed: 0 additions & 92 deletions
This file was deleted.

dev/old_vs_new.clj

Lines changed: 0 additions & 59 deletions
This file was deleted.

notebooks/benchmarks.clj

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/nextjournal/markdown/impl.cljs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
;; # 🧩 Parsing
22
(ns nextjournal.markdown.impl
33
(:require ["/js/markdown" :as md]
4-
[applied-science.js-interop :as j]
54
[clojure.zip :as z]
65
[nextjournal.markdown.utils :as u]))
76

@@ -123,15 +122,15 @@
123122

124123
(defn footnote-label [{:as _ctx ::keys [footnote-offset]} token]
125124
;; TODO: consider initial offset in case we're parsing multiple inputs
126-
(or (j/get-in token [:meta :label])
125+
(or (.. token -meta -label)
127126
;; inline labels won't have a label
128-
(str "inline-note-" (+ footnote-offset (j/get-in token [:meta :id])))))
127+
(str "inline-note-" (+ footnote-offset (.. token -meta -id)))))
129128

130129
;; footnotes
131130
(defmethod apply-token "footnote_ref" [{:as ctx ::keys [label->footnote-ref]} token]
132131
(let [label (footnote-label ctx token)
133132
footnote-ref (or (get label->footnote-ref label)
134-
{:type :footnote-ref :inline? (not (j/get-in token [:meta :label]))
133+
{:type :footnote-ref :inline? (not (.. token -meta -label))
135134
:ref (count label->footnote-ref) ;; was (+ (count footnotes) (j/get-in token [:meta :id])) ???
136135
:label label})]
137136
(-> ctx
@@ -144,7 +143,7 @@
144143
(-> ctx
145144
(u/update-current-loc (fn [loc]
146145
(u/zopen-node loc {:type :footnote
147-
:inline? (not (j/get-in token [:meta :label]))
146+
:inline? (not (.. token -meta -label))
148147
:label label}))))))
149148

150149
;; inline footnotes^[like this one]
@@ -252,24 +251,26 @@ _this #should be a tag_, but this [_actually #foo shouldnt_](/bar/) is not."
252251

253252
;; html
254253
(defmethod apply-token "html_inline" [doc token]
255-
(-> doc (u/update-current-loc z/append-child {:type :html-inline :content [(text-node (j/get token :content))]})))
254+
(-> doc (u/update-current-loc z/append-child {:type :html-inline :content [(text-node (.-content token))]})))
256255

257256
(defmethod apply-token "html_block" [doc token]
258-
(-> doc (u/update-current-loc z/append-child {:type :html-block :content [(text-node (j/get token :content))]})))
257+
(-> doc (u/update-current-loc z/append-child {:type :html-block :content [(text-node (.-content token))]})))
259258

260259
;; html
261260
(defmethod apply-token "html_inline" [doc token]
262-
(-> doc (u/update-current-loc z/append-child {:type :html-inline :content [(text-node (j/get token :content))]})))
261+
(-> doc (u/update-current-loc z/append-child {:type :html-inline :content [(text-node (.-content token))]})))
263262

264263
(defmethod apply-token "html_block" [doc token]
265-
(-> doc (u/update-current-loc z/append-child {:type :html-block :content [(text-node (j/get token :content))]})))
264+
(-> doc (u/update-current-loc z/append-child {:type :html-block :content [(text-node (.-content token))]})))
266265

267266
;; endregion
268267

269268
;; region data builder api
270269
(defn pairs->kmap [pairs] (into {} (map (juxt (comp keyword first) second)) pairs))
271270
(defn apply-tokens [doc tokens]
272-
(let [mapify-attrs-xf (map (fn [x] (j/update! x :attrs pairs->kmap)))]
271+
(let [mapify-attrs-xf (map (fn [x]
272+
(set! x -attrs (pairs->kmap (.-attrs x)))
273+
x))]
273274
(reduce (mapify-attrs-xf apply-token) doc tokens)))
274275

275276
(defn parse

0 commit comments

Comments
 (0)