Skip to content

Commit ed2b537

Browse files
committed
Changelog update and small refactor of remove-type-meta
1 parent 7b4ae36 commit ed2b537

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ Changes can be:
4040

4141
* 💫 Cache expressions that return `nil` in memory
4242

43+
* 🐜 Turn off analyzer pass for validation of `:type` tags, fixes [#488](https://github.com/nextjournal/clerk/issues/488) @craig-latacora
44+
45+
* 🐜 Strip `:type` metadata from forms before printing them to hash, fixes [#489](https://github.com/nextjournal/clerk/issues/489) @craig-latacora
46+
4347
* 🐜 Ensure custom `print-method` supporting unreadable symbols preserves metadata
4448

4549
## 0.13.842 (2023-03-07)

src/nextjournal/clerk/analyzer.clj

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,21 +549,20 @@
549549
#_(dep/immediate-dependencies (:graph (build-graph "src/nextjournal/clerk/analyzer.clj")) #'nextjournal.clerk.analyzer/long-thing)
550550
#_(dep/transitive-dependencies (:graph (build-graph "src/nextjournal/clerk/analyzer.clj")) #'nextjournal.clerk.analyzer/long-thing)
551551

552-
(defn strip-form-meta [form]
553-
(clojure.walk/postwalk
554-
(fn [v]
555-
(if (or (instance? clojure.lang.IObj v)
556-
(instance? clojure.lang.IMeta v))
557-
(vary-meta v (constantly nil))
558-
v))
559-
form))
552+
(defn ^:private remove-type-meta
553+
"Walks given `form` removing `:type` from metadata to ensure it can be printed."
554+
[form]
555+
(walk/postwalk (fn [x] (cond-> x
556+
(contains? (meta x) :type)
557+
(vary-meta dissoc :type)))
558+
form))
560559

561560
(defn hash-codeblock [->hash {:as codeblock :keys [hash form id deps vars]}]
562561
(when (and (seq deps) (not (ifn? ->hash)))
563562
(throw (ex-info "`->hash` must be `ifn?`" {:->hash ->hash :codeblock codeblock})))
564563
(let [hashed-deps (into #{} (map ->hash) deps)]
565564
(sha1-base58 (binding [*print-length* nil]
566-
(pr-str (set/union (conj hashed-deps (if form (strip-form-meta form) hash))
565+
(pr-str (set/union (conj hashed-deps (if form (remove-type-meta form) hash))
567566
vars))))))
568567

569568
(defn hash

0 commit comments

Comments
 (0)