Fork me on GitHub
#clerk
<
2023-02-09
>
sheluchin12:02:46

Disabling eliding: is there an easier way than creating a custom viewer?

mkvlr14:02:00

see https://book.clerk.vision/#elisions

(clerk/reset-viewers! (clerk/update-viewers (clerk/get-default-viewers) {:page-size #(dissoc % :page-size)}))

mkvlr14:02:11

this turns off elisions for the namespace you’re in

mkvlr14:02:30

or gobally

(nextjournal.clerk.viewer/reset-viewers!
 :default
 (nextjournal.clerk.viewer/update-viewers nextjournal.clerk.viewer/default-viewers
                                          {:page-size #(dissoc % :page-size)}))

sheluchin15:02:37

Thanks, @mkvlr. I skimmed the Elisions section but your recipe wasn't obvious to me. That would be nice for a Clerk cheatsheet or something like that.

sheluchin20:02:58

Is there also a way to prevent it from collapsing tables and other content with the 8 more... thing? I thought ^#::clerk{:result :show}, but guess that's not it.

mkvlr09:02:08

@UPWHQK562 Shouldn’t turning off elisions do that? can you show me what you mean exactly?

sheluchin14:02:41

@mkvlr If I'm not mistaken, it's different from an elision. My understanding is that the elision mechanism completely hides remaining content behind a 4 more elided... sort of message, with no ability to view the rest. What I'm looking at in this case is the collapsing mechanism which does allow you to view the rest. Basically, my code produces some long tables and I want to show them in their entirety.

mkvlr15:02:11

it’s the same. You might be running into the per-result budget. Can you share a repro so I can take a look?

sheluchin15:02:32

It's probably the per-result budget. I'm on a bit of a time crunch right now. I'll try share a repro in the next few days or so. Thanks!

eraderna12:03:16

I'm trying to disable elision in clerk/table: I can do so by creating a custom viewer using the https://clojurians.slack.com/archives/C035GRLJEP8/p1666123149177549?thread_ts=1666116500.374339&amp;cid=C035GRLJEP8 @mkvlr shared back in October 2022, but cannot get the <http://(clerk/reset-viewers!%20(clerk/update-viewers%20(clerk/get-default-viewers)%20{:page-size%20#(dissoc%20%%20:page-size)}))|recipe above to turn off elisions for the current namespace> to work: after

(clerk/reset-viewers! (clerk/update-viewers (clerk/get-default-viewers) {:page-size #(dissoc % :page-size)}))
clerk/table is still eliding. What am I missing!?

Andrea13:03:52

clerk/table no longer dispatches by viewer name, but uses a fixed viewer instead, you could write your own unelided table helper with the custom viewer you mention, following the definition: https://github.com/nextjournal/clerk/blob/711a1b2fae3c212d2c8c2323cf4d53c178766114/src/nextjournal/clerk.clj#L257-L273 (if I understand your problem correctly)

Andrea13:03:15

if it’d use dispatch by name, you’d have to change the reset-viewers! + dissoc trick to target child viewers (as in the example you pasted)

Andrea13:03:46

by “dispatch by name” I mean

(clerk/with-viewer `v/table-viewer my-table)

eraderna10:03:06

Thanks for that: I understand more now. As I only needed to suppress elision on tables, I followed your suggestion and wrote a table helper to use the custom unelided viewer created per @mkvlr’s https://clojurians.slack.com/archives/C035GRLJEP8/p1666123149177549?thread_ts=1666116500.374339&amp;cid=C035GRLJEP8, giving:

(defn transform-child-viewers [viewer & update-args]
  (update viewer :transform-fn (partial comp #(apply update % :nextjournal/viewers v/update-viewers update-args))))

(def table-viewer-no-pagination
  (transform-child-viewers v/table-viewer {:page-size #(dissoc % :page-size)}))

(defn clerk-table-no-pagination
  ([xs] (clerk-table-no-pagination {} xs))
  ([viewer-opts xs] (clerk/with-viewer table-viewer-no-pagination viewer-opts xs)))
after which I use clerk-table-no-pagination rather than clerk/table.

🙌 4
sheluchin18:02:29

Is there a way to render multiple items in a single let, rather than just the item it returns?

mkvlr18:02:16

multiple returns from a let: no, but that’s just clojure semantics. But you can return a sequence and render it with clerk/col

eraderna12:03:16

I'm trying to disable elision in clerk/table: I can do so by creating a custom viewer using the https://clojurians.slack.com/archives/C035GRLJEP8/p1666123149177549?thread_ts=1666116500.374339&amp;cid=C035GRLJEP8 @mkvlr shared back in October 2022, but cannot get the <http://(clerk/reset-viewers!%20(clerk/update-viewers%20(clerk/get-default-viewers)%20{:page-size%20#(dissoc%20%%20:page-size)}))|recipe above to turn off elisions for the current namespace> to work: after

(clerk/reset-viewers! (clerk/update-viewers (clerk/get-default-viewers) {:page-size #(dissoc % :page-size)}))
clerk/table is still eliding. What am I missing!?