clerk

maybenot 2024-12-08T07:53:56.157649Z

Should I expect pure md notebook to render other languages with syntax highlighting? When I use `python it doesn’t seem to work maybe I need to add something else to the config?

Phil 2024-12-11T19:06:10.645779Z

Does it work if you use this instead of through markdown fenced code blocks?

(clerk/code {::clerk/opts {:language "python"}} "your-python-code-here")

maybenot 2024-12-12T03:03:11.542039Z

Unfortunately no Also the same problem is visible inside the book of clerk https://book.clerk.vision/#code in c++ / python blocks

Phil 2024-12-12T04:06:09.590129Z

Oh interesting yeah it appears to use codemirror for highlighting wonder if there is an issue there or maybe some missing update but it's definitely not highlighting properly

➕ 1
mkvlr 2024-12-13T06:45:42.395319Z

looks like a regression, could you open an issue?

maybenot 2024-12-13T08:41:15.394619Z

@mkvlr sure, opened one here https://github.com/nextjournal/clerk/issues/738 Thank you!

mkvlr 2024-12-13T08:44:57.008389Z

@romantsopin thank you!

🙌 1
maybenot 2024-12-10T20:55:50.311119Z

Seems like syntax highlighting for Forth works! Js, Python, C don’t. Please could somebody save my sanity and explain what’s going on 😅

Alex 2024-12-08T08:26:21.903509Z

Hi! How can I have both my notebook and the 🚰 Tap Inspector open at the same time? In the same browser tab, maybe? If I try opening two tabs, their content both switches to the taps or the currently edited notebook.

Alex 2024-12-11T21:07:06.622579Z

More generally, it doesn't seem to be possible to have more than one page served from the backend at the same time by having multiple tabs open. The content of the tabs seems to synchronously change with each navigation. I see this issue open since a year now w/o any reaction: https://github.com/nextjournal/clerk/issues/580

Alex 2024-12-11T21:24:58.658599Z

I commented on the above issue now and added a short video demo of the problem.

mkvlr 2024-12-13T06:41:05.145549Z

yes, it’s currently not possible. I did some work around this last year but never managed to wrap it up https://github.com/nextjournal/clerk/commit/ae8fcf8a496ec1ad04bae9cf8eb725bd1fcd42ec

mkvlr 2024-12-13T06:41:37.658399Z

can’t make any promises but maybe I’ll find the time to revive this over the holidays

Alex 2024-12-13T07:47:42.484299Z

OK, but how is one supposed to use the Tap Inspector at all? Am I missing something?

mkvlr 2024-12-13T08:24:55.085279Z

do you mean it’s not useful if you need to explicitly switch between the tap inspector and notebook?

mkvlr 2024-12-13T08:25:38.411489Z

I think you can also embed the tap inspector in your notebook, can try this in a few minutes

🚀 1
Alex 2024-12-13T08:25:38.740319Z

yes, if I can't see both at once, it's not useful for me

👍 1
Alex 2024-12-13T08:25:59.887309Z

embedding would be perfect, if it can work

mkvlr 2024-12-13T08:41:36.677389Z

a bit more work than it should be but this works

(ns foo
  (:require [nextjournal.clerk :as clerk]
            [nextjournal.clerk.tap :as tap]))

;; # Embedding the Tap Viewer

^{::clerk/viewers (clerk/add-viewers [tap/tap-viewer])}
(clerk/fragment @tap/!taps)

#_(tap> {:hello :world})

🙌🏻 1
mkvlr 2024-12-13T08:42:44.386989Z

if you want the view stream / latest and clear controls, can also copy those from the tap viewer

Alex 2024-12-13T08:48:19.300139Z

it works — thanks a lot! 🙂

mkvlr 2024-12-13T08:48:46.630459Z

great

Alex 2024-12-13T08:59:41.574189Z

trying to add the controls like this:

^{::clerk/viewer tap/switch-view}
@tap/!view
but it fails with No protocol method IDeref.-deref defined for type null:

Alex 2024-12-13T09:00:22.532419Z

(the same without deref)

mkvlr 2024-12-13T09:33:22.279209Z

yeah, sorry that’s a bit more involved, one moment…

mkvlr 2024-12-13T10:46:11.072109Z

(ns foo
  (:require [nextjournal.clerk :as clerk]
            [nextjournal.clerk.tap :as tap]
            [nextjournal.clerk.viewer :as viewer]))

;; # Embedding the Tap Viewer

^{::clerk/sync true ::clerk/viewer tap/switch-view ::clerk/visibility {:result :show}}
(defonce !view (atom {:kind :stream
                      :auto-expand-results? false}))


(defn reset-taps! []
  (reset! tap/!taps ())
  (clerk/recompute!))

^{::clerk/viewers (clerk/add-viewers [tap/tap-viewer])}
(clerk/fragment (cond->> @tap/!taps
                  (= :latest (:kind @!view)) (take 1)))

mkvlr 2024-12-13T10:46:26.300489Z

sync atoms don’t compose nicely yet

mkvlr 2024-12-13T10:46:41.969219Z

can’t yet take them from other places

Alex 2024-12-13T14:08:04.429359Z

well, that almost works, just fires a thousand of recomputations of the notebook (literally), as that's what tap/tapped seems to do... also, it doesn't like reset-taps! is doing anything either... thanks for trying, anyway