clerk 2024-12-08

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?

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

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

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

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

looks like a regression, could you open an issue?

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

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.

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

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

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

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

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

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

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

🚀 1

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

👍 1

embedding would be perfect, if it can work

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

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

it works — thanks a lot! 🙂

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:

(the same without deref)

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

(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)))

sync atoms don’t compose nicely yet

can’t yet take them from other places

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