This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-03
Channels
- # announcements (2)
- # babashka (15)
- # beginners (40)
- # calva (11)
- # cherry (2)
- # cider (3)
- # cljsrn (2)
- # clojure (37)
- # clojure-austin (4)
- # clojure-europe (2)
- # clojurescript (16)
- # core-async (1)
- # datomic (25)
- # hyperfiddle (18)
- # jobs-discuss (9)
- # nbb (7)
- # off-topic (19)
- # pathom (6)
- # podcasts-discuss (4)
- # portal (37)
- # practicalli (1)
- # re-frame (11)
- # releases (1)
- # scittle (13)
- # shadow-cljs (6)
@djblue does a LaTeX viewer exist yet, using https://katex.org/ or mathjax?
Yeah I’m going to give it a go and see if I can get something basic working
This is close @djblue
(ns emmy.portal.tex
(:require ["katex" :as k]
[portal.ui.api :as p]))
(defn tex [text]
[:span
{:dangerouslySetInnerHTML
{:__html
(.renderToString katex text
#js {:throwOnError false
:displayMode true})}}])
(p/register-viewer!
{:name :emmy.portal/tex
:component tex
:predicate (constantly true)})
and then load via
(-> (io/resource "emmy/portal/tex.cljs")
(slurp)
(p/eval-str))
I think an issue you might run into is that strings don't support metadata :thinking_face:
yes for sure
that stops me from sending a default, but once this is working I can render Emmy expressions (which carry metadata) this way with the rpc call approach
that works but weirdly keeps the original text in there too
no errors, but the second form is katex-html and has that aria-hidden true flag
it’s amazing
so either we require npm install katex
here or inject the JS into the header
Yeah that’s right
Yeah, I think those two work for now 👍 I think in the future it might be cool if npm deps (only the modules your code needs) could be embedded into your jar :thinking_face: Users wouldn't need npm or be connected to the internet after the jar is downloaded
That plus something like self-hosted cljs or cherryjs and most of Portal itself becomes an extension to some minimal bootstrap code to get everything kicked off
For example here is Portal hosting (via sci) another completely unrelated project I did 😆
@djblue one thing that WOULD be nice would be to be able to specify default viewers for some type like emmy.expression/Literal
without having the instances having to carry around metadata. can I do that somehow?
configure some list of predicate => default?
Currently, the easiest place to do something like this is via a custom submit function. Does that type live on the jvm or js?
on the JVM
will custom submit cause problems for something like Clojure Notebooks?
Yeah, this wouldn't work with clojure notebooks. However, I'm open to adding extension points, just not sure what they are yet.
I guess by “cause problems” I mean, is there a way to specify that clojure notebooks should use my custom submit function
I guess we want something like middleware on the JVM side
https://clojurians.slack.com/archives/C0185BFLLSE/p1680283906008079 was a previous discussion