Fork me on GitHub
#clerk
<
2023-05-17
>
rickmoynihan11:05:22

I appear to be getting https://clojurians.slack.com/archives/C035GRLJEP8/p1680645356357219 with images not rendering in clerk. I can reproduce it with the minimal example from there too. But also this appears to occur whether I have enabled slideshow viewers or not. :thinking_face: Any ideas?

Andrea13:05:18

> But also this appears to occur whether I have enabled slideshow viewers or not. Which version of Clerk is that happening to? As of the latest git SHA images seem to be working as per https://snapshots.nextjournal.com/clerk/build/5e875e256a28a6deabf27bd6fc20f44cee5dad20/index.html#/notebooks/viewers/image.clj. Also tried the mentioned minimal repro locally and cannot reproduce.

rickmoynihan13:05:12

I appear to see the issue with both: io.github.nextjournal/clerk {:git/sha "5e875e256a28a6deabf27bd6fc20f44cee5dad20"} io.github.nextjournal/clerk {:mvn/version "0.13.842"}

rickmoynihan13:05:31

when running with io.github.nextjournal/clerk-slideshow {:git/sha "977003e581d78f4f554bb8ae73f877f4070925c3"}

Andrea13:05:40

hmm, not really able to reproduce at those deps coordinates with

(ns example-talk
  #:nextjournal.clerk{:visibility {:code :hide}}
  (:require
   [ :as io]
   [nextjournal.clerk :as clerk]
   [nextjournal.clerk-slideshow :as slideshow])
  (:import
   (javax.imageio ImageIO)))

;; ---
;; # Testing

^{::clerk/visibility {:result :hide}}
(comment
  (clerk/add-viewers! [slideshow/viewer])
  (clerk/reset-viewers! clerk/default-viewers))

(ImageIO/read (io/file "test-image.png"))
works just fine for me locally. If you inspect the notebook in the browser and follow the img src, are you getting a 404 at the URL and what kind of URL are you getting? Assuming you’re trying in interactive mode (localhost:<port>)

rickmoynihan17:05:02

The URL to the img looks like this: /_blob/5dsCzXQxZ5s8WwXqUeEKTRsdY21uxe?path=[]

rickmoynihan17:05:36

and yes it’s in interactive mode localhost:7777

oly14:05:08

is there a nice way to have dependant blocks, so pull data in a block then generate a table and graph, If i put the data into a def it does not trigger an update, is there something built in for this ?

jackrusher15:05:48

If you change a def, it will trigger re-computation on dependent forms. I think maybe you mean that you want Clerk to watch an external file for changes to the content in that file?

oly16:05:23

apologies you are quite right must have been something else causing my behaviour, thanks for clarifying 🙂

👍 2
Craig Brozefsky19:05:44

Clark analyzer seems a bit more sensitive than the clojure compiler. Code which tags values with unknown classes in a body of a form will compile file, and run fine. However, the clerk analyzer will error out:

(require '[nextjournal.clerk :as clerk])

;; this is a brute way to make the clerk analyzer resilient in the case of
;; an unknown class tag
;;
;; (alter-var-root #'nextjournal.clerk.analyzer/analyzer-passes-opts
;;                 (fn [v]
;;                   (assoc v
;;                          :validate/wrong-tag-handler (fn [tag node]
;;                                                        nil))))

;; This will compile and run just fine, but clerk errors when evaluating this as
;; a notebook.
(defmulti foo :tag)
(defmethod foo :baz [v] (pr ^Something v))
(foo {:tag :baz})

Craig Brozefsky19:05:15

See the commented out form that sets the :validate/wrong-tag-handler to make it just returna. nil alue instead of throwing an exception. I discovered this when trying to use clerk in a namespace that uses malli. the print-method's defined in malli use shorthand tags for the IntoSchema and Schema protocols, that break clerk.

mkvlr08:05:18

thanks for the issue! I’m on holidays for a few days, will take a closer look next week.