Skip to content

Commit

Permalink
Fix row and col viewers not showing a first map arg, fixes #567
Browse files Browse the repository at this point in the history
  • Loading branch information
mk committed Nov 5, 2023
1 parent 0fc5203 commit b95bcd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Changes can be:

## Unreleased

...
* 💫 Allow to disable welcome page in `serve!`
* 🐞 Fix `row` and `col` viewers not showing a first map argument, fixes [#567](https://github.com/nextjournal/clerk/issues/567) @teodorlu

## 0.15.957 (2023-09-28)

Expand Down
4 changes: 3 additions & 1 deletion src/nextjournal/clerk/viewer.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@
(defn with-viewer-extracting-opts [viewer & opts+items]
;; TODO: maybe support sequantial & viewer-opts?
(cond
(and (map? (first opts+items)) (not (wrapped-value? (first opts+items))))
(and (map? (first opts+items))
(not (wrapped-value? (first opts+items)))
(seq (set/intersection parser/block-settings (set (keys (first opts+items))) )))
(with-viewer viewer (first opts+items) (rest opts+items))

(and (sequential? (first opts+items)) (= 1 (count opts+items)))
Expand Down
9 changes: 9 additions & 0 deletions test/nextjournal/clerk/viewer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,12 @@
(-> (eval/eval-string "(ns test.removed-metadata\n(:require [nextjournal.clerk :as c]))\n\n^::c/no-cache (do 'this)")
view/doc->viewer
v/->value :blocks second v/->value))))

(deftest col-viewer-map-args
(testing "extracts first arg as viewer-opts"
(is (= [{:foo :bar}]
(v/->value (v/col {:nextjournal.clerk/width :wide} {:foo :bar})))))

(testing "doesn't treat plain map as viewer-opts"
(is (= [{:foo :bar} {:bar :baz}]
(v/->value (v/col {:foo :bar} {:bar :baz}))))))

0 comments on commit b95bcd7

Please sign in to comment.