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).
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"))The viewer code can run javascript / is javascript
How do you ask it to eval javascript inside a .clj file? Can you bring in Js libraries like react?
should i be read the clerk docs on writing viewers?
probably, cc @mkvlr for pointers
the viewers are already reagent forms
@drewverlee sorry, a better question from me might have been — what are you trying to do, and what have you tried?
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.
okay, so you want to write actual JS, not, like, cljs that has access to js
Yes, I'm asking if that's something a clerk notebook supports.
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')"))