clerk

Drew Verlee 2024-11-09T01:53:59.874599Z

Is there a way to get a clerk notebook to run javascript? If note, what do people use for multi language notebooks? Is org mode still a strong contender if your an emacs user (which i am).

mkvlr 2024-11-11T08:02:13.385529Z

clerk’s js bundle has react in it, and you can use it from sci. I haven’t tried using it from plain js. Could probably hack something together to get this working, e.g.

(clerk/eval-cljs '(do (ns foo (:require ["react" :as react]))
                      (set! (.. js/window -react) react)))

(clerk/eval-cljs '(js/eval "react"))

Sam Ritchie 2024-11-09T15:34:54.046819Z

The viewer code can run javascript / is javascript

Drew Verlee 2024-11-10T02:27:59.562919Z

How do you ask it to eval javascript inside a .clj file? Can you bring in Js libraries like react?

Drew Verlee 2024-11-10T02:29:58.937859Z

should i be read the clerk docs on writing viewers?

Sam Ritchie 2024-11-10T15:43:16.471739Z

probably, cc @mkvlr for pointers

Sam Ritchie 2024-11-10T15:43:31.020989Z

the viewers are already reagent forms

Sam Ritchie 2024-11-10T16:20:10.822229Z

@drewverlee sorry, a better question from me might have been — what are you trying to do, and what have you tried?

Drew Verlee 2024-11-10T16:28:43.337239Z

I'm trying to write a mult programming language document. It's obvious to me how to write clj using clerk as I'm in a clj file. But if i want to write js, I believe I'll need to tell some compiler that the context is changing from clj to js. I just haven't seen anything in the clerk examples that looks like that. I believe emacs org mode with certain packages can achieve this kind of thing. In the end, i don't have to produce a runnable program, just a document though. So i can just manually stitch together that doc from several others that i used to check, build and run the individual parts.

Sam Ritchie 2024-11-10T16:36:56.879229Z

okay, so you want to write actual JS, not, like, cljs that has access to js

Drew Verlee 2024-11-10T18:22:02.887099Z

Yes, I'm asking if that's something a clerk notebook supports.

mkvlr 2024-11-11T07:52:11.124039Z

clerk viewers are currently limited to (sci-evaluated) ClojureScript and cherry. You can use that to eval js e.g. with (clerk/eval-cljs '(js/eval "console.log('hello from javascript')"))