Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix html with odd length lists #398

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions notebooks/viewers/html.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
"Go to "
[:a.text-lg {:href (v/doc-url "notebooks/viewers/image.clj")} "images"]
" notebook."]) nil)

(clerk/html
[:h1 "Title"
(list [:div "one"]
[:div "two"]
[:div "three"])])
6 changes: 3 additions & 3 deletions src/nextjournal/clerk/viewer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@
#_(process-viewer {:render-fn '#(vector :h1) :transform-fn mark-presented})

(def processed-keys
(into [:path :offset :n :nextjournal/content-type :nextjournal/value]
(into [:path :offset :n :nextjournal/content-type :nextjournal/value :nextjournal/presented?]
(-> viewer-opts-normalization vals set (disj :nextjournal/viewers))))

(defn process-wrapped-value [wrapped-value]
Expand Down Expand Up @@ -1386,9 +1386,9 @@
(reduce compute-expanded-at state' value)
state')))

(defn collect-expandable-paths [state {:nextjournal/keys [value] :keys [path]}]
(defn collect-expandable-paths [state {:nextjournal/keys [value presented?] :keys [path]}]
(let [state' (assoc-in state [:expanded-at path] false)]
(if (vector? value)
(if (and (vector? value) (not presented?))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative, we might just check that all (or just the first of) items in value are wrapped ones.

(reduce collect-expandable-paths state' value)
state')))

Expand Down