Fork me on GitHub
#clerk
<
2023-03-06
>
Ben Sless09:03:13

Damn I love Clerk

šŸ–¤ 8
Ben Sless13:03:06

How do I get clerk to not trim the edges of an image wider than its margins?

mkvlr13:03:20

would you like to set it to full with? That would be {:nextjournal.clerk/width :full} as a first arg to clerk/plotly

Ben Sless14:03:16

I'm using clerk/vl Same thing?

Ben Sless17:03:13

full behaves kind of weird

Ben Sless17:03:40

shouldn't it center?

mkvlr17:03:27

think you need some extra options for vega for this

Ben Sless13:03:05

How can I debug a build error with clerk?

Execution error (NullPointerException) at clojure.tools.analyzer.jvm/macroexpand-1 (jvm.clj:192).
Cannot read field "ns" because "sym" is null
(running nextjournal.clerk/build!)

mkvlr14:03:44

thereā€™s nothing more useful on *e in that case, is there?

Ben Sless14:03:35

It errored from CLI not from REPL, I'll check later if it reproduces, but the temp edn file produced just showed the stack trace, not the offending form

mkvlr14:03:08

ok, if you can use a :local/root dep Iā€™d be curious to know if changing the catch to Throwable gives you the form https://github.com/nextjournal/clerk/blob/f57d9efe6c70f922ecd715a1f45f799be939c750/src/nextjournal/clerk/analyzer.clj#L138

Ben Sless17:03:51

hang on, there's an issue with defrecords, right?

Ben Sless18:03:24

I managed to narrow it down to: I define a protocol and record in the same file emit-defrecord fails because it can't resolve the protocol

Ben Sless18:03:43

And now it works for some esoteric reason

mkvlr09:03:04

issue welcome, the class-based things are tricky to analyze with tools.analyzer

BorisKourt14:03:48

Is there an example config for ClerkShow for neovim lua? (With Conjure)

BorisKourt11:03:40

I saw that one, but it was vimscript I was hoping for a lua version.

jackrusher00:03:40

Ah, sorry, I didn't pay close enough attention! I don't know of one, but if you ask @U38J3881W nicely, they might help you get it working and contribute that recipe to the Book of Clerk šŸ™‚

Olical09:06:02

(module clay-integration.lnvim
  {autoload {a aniseed.core
             str aniseed.string
             nvim aniseed.nvim
             eval conjure.eval
             extract conjure.extract}})

(defn eval-clojure-for-viz []
  (eval.eval-str
    {:origin "custom-clay-wrapper"
     :code (str.join
             ""
             ["(scicloj.clay.v2.api/handle-form! `" (a.get (extract.form {:root? true}) :content) ")"])}))

(defn on-filetype []
  (nvim.buf_set_keymap
    0 :n "<localleader>ev" ""
    {:callback eval-clojure-for-viz}))

(def augroup (nvim.create_augroup :gower-st-intro.lnvim {}))
(nvim.create_autocmd
  :Filetype
  {:group augroup
   :pattern ["clojure"]
   :callback on-filetype})
Here's how I integrated Conjure with Clay, probably similar?

Olical09:06:38

And I know this is an old thread, I just never check clojurians so I thought I'd drop something in here now šŸ˜… I'm only really in github issues and the Conjure discord. https://conjure.fun/discord

genmeblog15:03:16

Just noticed that there is a difference in size between string and markdown text when rendered in a table. Is it possible to make the same style for both cases?

Andrea16:03:07

Hi @U1EP3BZ3Q, this should allow you to customise the string viewer inside tables:

(defn add-child-viewers [viewer viewers]
  (update viewer :transform-fn (fn [tx-fn] (comp #(update % :nextjournal/viewers clerk/add-viewers viewers) tx-fn))))

(def custom-table-viewer
  (add-child-viewers v/table-viewer
                     [(assoc v/string-viewer :render-fn '(fn [s] [:pre.text-amber-500 s]))]))

(clerk/with-viewer custom-table-viewer
  [["text"]["text"] [(clerk/md "text")]])
then you could check the markup rendered by clerk/md in the browser and adjust the :render-fn function to output the same.

Andrea16:03:14

this should get you the same styles:

(defn add-child-viewers [viewer viewers]
  (update viewer :transform-fn (fn [tx-fn] (comp #(update % :nextjournal/viewers clerk/add-viewers viewers) tx-fn))))

(def custom-table-viewer
  (add-child-viewers nextjournal.clerk.viewer/table-viewer
                     [(assoc nextjournal.clerk.viewer/string-viewer :render-fn '(fn [s] [:div.markdown-viewer [:p s]]))]))

(clerk/with-viewer custom-table-viewer
  [[1 "text"][ 2"text"] [3 (clerk/md "text")]])

šŸ™ 2