Fork me on GitHub
#nextjournal
<
2022-03-01
>
Carsten Behring16:03:52

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 %)}))}])

mkvlr16:03:19

the hash-map and nextjournal/value shouldn't be needed anymore

Carsten Behring21:03:21

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:

respatialized20:03:03

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.

respatialized20:03:27

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

respatialized22:03:45

^ 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:

mkvlr09:03:16

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