nextjournal

grahamcarlyle 2022-02-03T12:38:23.473959Z

Hello, I am generating a static version of a notebook by calling clerk/build-static-app!, and was hoping to be able to use the :git/url :git/sha params to generate the nice link back to the git repo of the source, but the url it generates doesn't work if my code (deps.edn) isn't at the root of the git repo. I'm wondering if i'm missing a way of doing this, or whether a new option such as :git/root would be necessary to support my use case?

grahamcarlyle 2022-02-24T13:13:31.586759Z

I've created an issue and PR for this, sorry for the delay in doing this https://github.com/nextjournal/clerk/issues/99

genmeblog 2022-02-03T13:35:49.470749Z

How do you generate this url? 'build-static-app' generates a html file. Why not just use absolute url?

mkvlr 2022-02-03T13:53:53.047489Z

not supported yet. So you'd want a equivalent of :deps/root?

mkvlr 2022-02-03T13:54:36.259669Z

or :git/root, makes sense. Issue and optionally PR welcome

genmeblog 2022-02-03T20:05:17.263869Z

The idea. Currently every form is treated separately and result is rendered directly under the code, form after form. Is there a way to make a block of forms, rendered them in one piece and results in another under as a one block?

mkvlr 2022-02-04T08:08:32.163769Z

do you have an example where that would be desired?

genmeblog 2022-02-04T08:51:52.217459Z

For example here:

genmeblog 2022-02-04T08:53:38.035339Z

I think block of code lines + block of results would be better here. It can be my personal feeling though

genmeblog 2022-02-04T08:55:30.307309Z

Here are some examples from other docs:

genmeblog 2022-02-04T08:55:32.158499Z

genmeblog 2022-02-04T08:56:15.940189Z

genmeblog 2022-02-04T08:58:56.125459Z

Thinking aloud: I think it's a matter of more compact view and/or ability to overwrite certain styles.

genmeblog 2022-02-04T10:07:13.451099Z

also something like in RMarkdown:

genmeblog 2022-02-04T10:07:16.330609Z

genmeblog 2022-02-04T10:26:11.790839Z

Similarly in Jupyter:

mkvlr 2022-02-04T10:41:25.857199Z

in the jupyter example it’s showing stdout & err (which we don’t yet show in Clerk)

mkvlr 2022-02-04T10:41:35.620899Z

you can do this today:

(clerk/with-viewers
  [{:pred vector? :render-fn '#(v/html (into [:div.flex.flex-col] (v/inspect-children %2) %1))}
   {:pred #(and (string? %)
                (re-matches
                 (re-pattern
                  (str "(?i)"
                       "(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|"
                       "(rgb|hsl)a?\\((-?\\d+%?[,\\s]+){2,3}\\s*[\\d\\.]+%?\\))")) %))
    :render-fn '#(v/html [:div
                          [:div.inline-block.rounded-sm.shadow.ml-2
                           {:style {:width 16
                                    :height 16
                                    :border "1px solid rgba(0,0,0,.2)"
                                    :background-color %}}]
                          [:span.font-mono.text-xs.ml-2 %]])}]
  ["#571845"
   "rgb(144,12,62)"
   "rgba(199,0,57,1.0)"
   "hsl(11,100%,60%)"
   "hsla(46, 97%, 48%, 1.000)"])

mkvlr 2022-02-04T10:41:48.854099Z

mkvlr 2022-02-04T10:42:18.074799Z

(return a vector and modify the vector viewer to render elements vertically)

genmeblog 2022-02-04T10:44:23.395469Z

mhm... (with jupyter, I wanted to show that several froms can be combined to get forms block + results block, instead of interleaved view)

genmeblog 2022-02-04T10:46:30.815249Z

I know that vector is possible but requires smart dispatching code.

genmeblog 2022-02-04T10:47:11.359309Z

It's a feature request from my side 🙂

mkvlr 2022-02-04T10:48:07.303309Z

what do you mean by smart dispatching code?

genmeblog 2022-02-04T10:52:13.401869Z

I mean I have to write another function for seqence of colors/palettes/gradients. Or add some logic to my viewer function (🎨)

mkvlr 2022-02-04T10:57:18.815089Z

I don’t yet see how we can automatically do it… We need some way to signal that it should render multiple results?

genmeblog 2022-02-04T11:03:04.602599Z

Maybe double newline can be an indicator to render a block?

(code 1)
(code 2)

(code 3)

(code 4)
(code 5)

genmeblog 2022-02-04T11:03:17.631639Z

this could be rendered as 3 blocks

genmeblog 2022-02-04T11:05:11.737439Z

Anyway, that's just an idea. I'm aware that's a breaking change request but maybe there can be an option to set by user to choose the method of block vs line-by-line rendering.

mkvlr 2022-02-04T11:08:08.202419Z

still would like to understand a bit better what you don’t like about the vector option?

genmeblog 2022-02-04T11:09:39.453259Z

I'm not saying I don't like 🙂 I need to write a piece of code which will render it properly. That's all.

genmeblog 2022-02-04T11:11:40.688159Z

Oh, it works now almost ok (need to get rid of [] at the beginning)

mkvlr 2022-02-04T11:13:04.398999Z

yes, that’s what I mean

mkvlr 2022-02-04T11:13:24.213289Z

(clerk/set-viewers! [{:pred vector?
                      :render-fn '#(v/html (into [:div.flex.flex-col] (v/inspect-children %2) %1))}])

mkvlr 2022-02-04T11:14:25.574239Z

another possibility would be for us to add this as a default named viewer to Clerk, then it would be selectable via metadata like this

(clerk/set-viewers! [{:name :flex-col
                      :render-fn '#(v/html (into [:div.flex.flex-col] (v/inspect-children %2) %1))}])

^{::clerk/viewer :flex-col}
[:one
 :two
 :three]

genmeblog 2022-02-04T11:16:43.914799Z

ok...

genmeblog 2022-02-04T11:17:10.032039Z

So another minor issue: is there a way to get rid of meta tag?

mkvlr 2022-02-04T11:19:54.888729Z

yes, been talking to @jackrusher about this and we want this as an option as well.

genmeblog 2022-02-04T11:20:20.681889Z

Great! Thank you for taking your time for that.

mkvlr 2022-02-04T11:21:37.725419Z

I’m a bit concerned about adding it too soon though because then it’s no longer obvious how to do some of those things. @philippmarkovics maybe we find a elegant way to unhide it on demand.

genmeblog 2022-02-04T11:23:50.198609Z

What about making such switches/options as a meta for namespace?

genmeblog 2022-02-04T11:24:19.969869Z

Like global no-cache?

genmeblog 2022-02-04T11:25:35.703109Z

(ns {^:nextjournal.clerk/options #{:no-cache :hide-tags :some-other-option}} notebooks.color)

mkvlr 2022-02-04T11:30:11.071169Z

yeah, possible. (Btw think we also want to move those options out from the namespace to the form ^:nextjournal.clerk/no-cache (ns notebooks.color notebooks.color) )

genmeblog 2022-02-04T11:31:18.468379Z

that's even better

2022-02-04T15:26:22.095249Z

We've been thinking about this too, @tsulej. But our approach with Clerk is the opposite of "move fast and break things", where we really want to make sure that everything fits together well to give the most power with the least API surface. 🙂

genmeblog 2022-02-04T19:16:17.170899Z

Ha! I'm the last person who expect moving fast and breaking things 🙂 Just sharing my observations and conclusions, which are subjective for sure but may be helpful (I hope).

2022-02-05T12:30:18.097629Z

I just meant that we're listening and trying to meet everyone's concerns, even if it seems like we're a bit slow shipping a solution or we don't take someone's pull request as is. 🙂

genmeblog 2022-02-03T20:05:45.932029Z

Now it's like:

genmeblog 2022-02-03T20:06:17.813819Z

(some-form 1 2 3)
;; result
(another-form 1 2 3)
;; result

genmeblog 2022-02-03T20:06:47.406609Z

What about this?

(some-form 1 2 3)
(another-form 1 2 3)
;; first result
;; second result