Skip to content

Commit

Permalink
Fix exception when rendering hiccup containing seqs
Browse files Browse the repository at this point in the history
  • Loading branch information
mk committed Nov 8, 2021
1 parent fd79f75 commit 1678b29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,10 @@ Changes can be:
* 🐞🐜 friendly or nasty bugs
* 🛠 dev improvements

## Unreleased

* 🐞 Fix exception when rendering hiccup containing seqs

## 0.2.214 (2021-11-04)

* 💫 Support setting `:nextjournal.clerk/no-cache` on namespaces
Expand Down
8 changes: 5 additions & 3 deletions src/nextjournal/clerk/viewer.cljc
Expand Up @@ -308,6 +308,7 @@
(describe (subs (slurp "/usr/share/dict/words") 0 1000))
(describe (plotly {:data [{:z [[1 2 3] [3 2 1]] :type "surface"}]}))
(describe (with-viewer* :html [:h1 "hi"]))
(describe (with-viewer* :html [:ul (for [x (range 3)] [:li x])]))
(describe (range))
(describe {1 [2]})
(describe (with-viewer* (->Form '(fn [name] (html [:<> "Hello " name]))) "James")))
Expand Down Expand Up @@ -367,9 +368,10 @@

(defn assign-closing-parens
([node] (assign-closing-parens {} node))
([{:as ctx :keys [closing-parens]} {:as node :nextjournal/keys [value viewer]}]
(let [closing (closing-paren viewer)
non-leaf? (vector? value) ;; TODO: what's the best way to detect non-leaf?
([{:as ctx :keys [closing-parens]} node]
(let [{:nextjournal/keys [value viewer]} node
closing (closing-paren viewer)
non-leaf? (and (vector? value) (wrapped-value? (first value)))
defer-closing? (and non-leaf?
(or (-> value last :nextjournal/viewer closing-paren) ;; the last element can carry parens
(and (= :map-entry (-> value last :nextjournal/viewer :name)) ;; the last element is a map entry whose value can carry parens
Expand Down

0 comments on commit 1678b29

Please sign in to comment.