Skip to content

Commit 83c9a8c

Browse files
committed
Use render-opts to defer closing parens
1 parent f73a784 commit 83c9a8c

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/nextjournal/clerk/render.cljs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,9 @@
428428
[triangle expanded?]]
429429
[:span.group-hover:text-indigo-700 opening-paren]]))
430430

431-
(defn render-coll [xs {:as opts :keys [path viewer !expanded-at] :or {path []}}]
431+
(defn render-coll [xs {:as opts :keys [closing-paren path viewer !expanded-at] :or {path []}}]
432432
(let [expanded? (get @!expanded-at path)
433-
{:keys [opening-paren closing-paren]} viewer]
433+
{:keys [opening-paren]} viewer]
434434
[:span.inspected-value.whitespace-nowrap
435435
{:class (when expanded? "inline-flex")}
436436
[:span
@@ -455,9 +455,8 @@
455455
:on-click #(when (fn? fetch-fn)
456456
(fetch-fn fetch-opts))} (- total offset) (when unbounded? "+") (if (fn? fetch-fn) " more…" " more elided")])])
457457

458-
(defn render-map [xs {:as opts :keys [path viewer !expanded-at] :or {path []}}]
459-
(let [expanded? (get @!expanded-at path)
460-
{:keys [closing-paren]} viewer]
458+
(defn render-map [xs {:as opts :keys [closing-paren path viewer !expanded-at] :or {path []}}]
459+
(let [expanded? (get @!expanded-at path)]
461460
[:span.inspected-value.whitespace-nowrap
462461
{:class (when expanded? "inline-flex")}
463462
[:span
@@ -481,8 +480,8 @@
481480
(inspect-presented opts %)))
482481
(if (string? s) [s] s))))
483482

484-
(defn render-quoted-string [s {:as opts :keys [path viewer !expanded-at] :or {path []}}]
485-
(let [{:keys [opening-paren closing-paren]} viewer]
483+
(defn render-quoted-string [s {:as opts :keys [closing-paren path viewer !expanded-at] :or {path []}}]
484+
(let [{:keys [opening-paren]} viewer]
486485
[:span.inspected-value.inline-flex
487486
[:span.cmt-string
488487
(if (some #(and (string? %) (str/includes? % "\n")) (if (string? s) [s] s))

src/nextjournal/clerk/viewer.cljc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,10 +1640,9 @@
16401640
(or (-> value last :nextjournal/viewer :closing-paren) ;; the last element can carry parens
16411641
(and (= `map-entry-viewer (-> value last :nextjournal/viewer :name)) ;; the last element is a map entry whose value can carry parens
16421642
(-> value last :nextjournal/value last :nextjournal/viewer :closing-paren))))]
1643-
(cond-> (cond
1644-
(not closing) node
1645-
defer-closing? (update node :nextjournal/viewer dissoc :closing-paren)
1646-
:else (update-in node [:nextjournal/viewer :closing-paren] cons closing-parens))
1643+
(cond-> (if (or (not closing) defer-closing?)
1644+
node
1645+
(assoc-in node [:nextjournal/opts :closing-paren] (cons closing closing-parens)))
16471646
non-leaf? (update :nextjournal/value
16481647
(fn [xs]
16491648
(into []

0 commit comments

Comments
 (0)