It seems that in latest Clerk commit (b6f47cf80c49b87d3765d355c61dae173cb9c2c6), the custom viewer for dataset does not work any more. I use the same code as before:
(clerk/set-viewers! [{:pred tc/dataset?
:transform-fn #(hash-map
:nextjournal/value
(clerk/table {:head (ds/column-names %)
:rows (ds/rowvecs %)}))}])I have an other strange case by using the above simplified custom viewer. It works for a single dataset object, but for a sequence of them it shows only a lot of white space:
the hash-map and nextjournal/value shouldn't be needed anymore
can I define a var in the sci runtime for a notebook? I'd like to be able to replicate the https://github.com/nextjournal/clerk/blob/main/notebooks/interactivity.clj, but without having to hook into the clerk runtime to fetch the values. If I could pass vars through to sci at compile time, then I could build out more interactivity for notebooks that I export from clerk to static HTML, which would be very nice.
yeah, that works. There’s also with-viewer btw where you don’t need to specify a :pred. Overriding / extending the !sci-ctx atom is meant for when you’re opting into doing your own ClojureScript compilation and goes together with overriding !resource->urlhttps://github.com/nextjournal/clerk/blob/8026e1edcf119c336d015f8905451586a36c4dea/src/nextjournal/clerk/config.clj#L20
According to the changelog, I see that the sci namespace is wrapped in an atom, but I don't see how to do so or where in the clerk namespaces this atom is defined. An example of modifying the sci namespace using this atom would be helpful.
https://github.com/nextjournal/clerk/blob/main/CHANGELOG.md#04305-2021-12-13
Aha, I think I found what I'm looking for: https://github.com/nextjournal/clerk/blob/8c75ae84d52e9e60d09179678a3c4411203164b9/src/nextjournal/clerk/sci_viewer.cljs#L983-L984
^ never mind, I forgot that was a cljs and not a clj namespace, so it's inaccessible from the clj environment.
I did come up with a hacky workaround in the meantime by sneaking a def into :render-fn: