This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-15
Channels
- # ai (1)
- # announcements (1)
- # aws (4)
- # babashka (9)
- # biff (1)
- # calva (1)
- # clerk (15)
- # clj-kondo (24)
- # clojure (23)
- # clojure-austin (7)
- # clojure-europe (19)
- # clojure-nl (2)
- # clojure-norway (33)
- # clojurescript (43)
- # conjure (4)
- # data-science (2)
- # datahike (5)
- # datomic (14)
- # defnpodcast (27)
- # domino-clj (1)
- # events (1)
- # honeysql (13)
- # hyperfiddle (44)
- # introduce-yourself (1)
- # java (4)
- # jobs (1)
- # jobs-discuss (11)
- # lsp (3)
- # malli (14)
- # missionary (5)
- # off-topic (44)
- # pedestal (2)
- # podcasts-discuss (1)
- # releases (8)
- # remote-jobs (2)
- # shadow-cljs (3)
Finally got around to simplifying modifying child viewers and setting the :page-size
for the table viewer in https://github.com/nextjournal/clerk/pull/515.
;; To customize the number of rows in the table viewer, set
;; `::clerk/page-size`. Use a value of `nil` to show all rows.
(clerk/table {::clerk/page-size 7} (map (comp vector (partial str "Row #")) (range 1 31)))
as always, this also works with metadata
^{::clerk/page-size 7 ::clerk/viewer clerk/table}
(map (comp vector (partial str "Row #")) (range 1 31))
this feels to me like it was the most difficult part of the viewer api until now. Curious to hear from others if things are easier now.
This print-method override is causing conflicts with my own print-method override to solve the same problem 8^) https://github.com/nextjournal/clerk/blob/fbc5d8d9fb413e53a68e76a952ac744acfc8e00c/src/nextjournal/clerk/viewer.cljc#L362
Here is the solution we had in place to be "good neighbors", perhaps clerk could do something similiar?
(defmacro defpatchmethod
"An anaphoric macro for patching existing multimethods. Original method is bound to the symbol 'this'.
Safe to execute multiple times, 'this' will always refer to the original implementation and never
the previously patched implementation."
[multifn dispatch-val bindings & body]
`(let [multi# ~multifn
dispatch# ~dispatch-val
original# (get-method multi# dispatch#)]
(letfn [(define# [orig#]
(.addMethod ^clojure.lang.MultiFn multi# dispatch#
(let [~'this orig#]
(with-meta (fn ~bindings ~@body)
(merge (meta orig#)
{::original orig#})))))]
(define# (or (some-> original# meta ::original) original#)))))
(def ^:dynamic *my-edn-print-mode* false)
(defpatchmethod print-method clojure.lang.Keyword [v w]
(if *my-edn-print-mode*
(let [writer (java.io.StringWriter.)]
(if (try
(this v writer)
(= v (edn/read-string (str writer)))
(catch Exception e
false))
(.write w (str writer))
(print-method (tagged-literal 'keyword [(.getNamespace v) (name v)]) w)))
(this v w)))
The key thing here is to use the existing print method unless in our own edn print mode
also, we don't use an eval there, tho I grok why clerk may. We do keyword tagged literal.
In the end, I think there needs to be a totally distinct edn printing stack 8^)
Not filing an issue with clerk, because I think clerk is doing the best it can here
Prolly best just to leap to transit for this use case 8^). Enjoying using Clerk, thanks for all the great work!