Can I read js/document into a clojure structure ?
no. well I mean if you write a function for it yes, by default no.
I see, thanks
Maybe something like https://github.com/mfikes/cljs-bean
Why would you want to do that?
I’m consuming an api that returns a xml body
I guess I would do one of: • use JS-interop directly (it's not too bad) • capture some small bit of information from the XML-string (works for simple small case) • parse the XML (if I need to do it in CLJS and I need flexibility) (and by parsing I mean convert into hiccup or hickory depending on the need) • parse in CLJ and do the heavy lifting there (if I have CLJ)
yeah I think I’m just gonna try using xml2js and then convert it with clj->js. The data is not very large so it should be sufficient.
tubax seems to be the library that internally uses sax-js too
Depending on what you have already, avoiding more dependencies should be good :)
good point.
This message was deleted.
Seems like a problem with highlight.js that's not related to CLJS at all.
Oh well, if you want a CLJS problem... 😂
I'm trying to fitgure out, why I sometimes cannot change the :require header, because shadow-cljs -reload fails...
Anyways, where could I talk about JS libraries?
Regarding the shadow-cljs issue - usually in #shadow-cljs. Regarding JS libraries - if you have an issue with a specific library, then I'd look at where the authors of the library ask you to report the issues. Most often, just GitHub issues, sometimes other places.
Besides asking there ☝️ , make a clean rebuild, and if that fails then you could try a small repro because that's usually when you find out that it was something in the project instead.
I don't recall any problem with CLJS highlight.js so maybe it's a newer version thing or some misconfiguration?
@macroz well, clean rebuild helped a few times already, but after some time, the problem appears again 😞
Do you use an external packaging tool or just Shadow-CLJS?
I use package.json instead of :npm-deps which should work the same, right?
I meant in Shadow-CLJS
But yes, I use package.json too
Thinking about if you for example use webpack in the mix too, or something.
Oh, yeah, I use shadow-cljs + npm
And sometimes when you reload your app you get that error?
Yes
Actually, it has been some time since I tried adding another language extension
But anyways, I tried adding Nim, because I wanted to test something and I got this message. However, after I reloaded the browser, it actually used Nim's rules to automatically highlight the Nim source. So it might just be a bug when I try to reload the namespace at runtime, idk...
Could it be that it does not load the extension in time?
Sounds like a race condition / timing issue if it happens sometimes.
So e.g. the registerLanguage or so happens "too late"
Yeah, I also feel like that might be it, but it's impossible to debug, because the stacktrace is literally a bunch of garbage
registerLanguage has nothing to do with it
even if I import a language submodule without calling registerLanguage, it still fails
Well if it is this problem, then it is not going to be in the stacktrace because of design. highlight.js seems to have a global registry inside and whether a thing is loaded there or not can cause the problem.
But it's interesting that a while ago, it failed on literally every language that hasn't "already been there" (that I haven't been using for some time), but after reload, I tried different languages and all of them worked fine.
I think this isn't handled by highlight.js , because I just :require the submodule, like everything else, without calling anything else from highlight.js
Yeah true
Hot code reloading is not magic that resolves everything for you, unfortunately.
It might very well that that highlight.js with a custom configuration is not amenable to hot code reload and you have to guard that custom config or some other parts that use it with stuff like defonce.
And if something should be reset/reconfigured after a code reload, there are hooks for that. The same thing you might use for re-rendering the page with Reagent, for example.
So I require
["highlight.js/lib/core" :default hljs] and
["highlight.js/lib/languages/clojure" :as hljs-clojure]
And in my start function (.registerLanguage hljs "clojure" hljs-clojure)
I do not recollect any code reload problems, but this was some year ago
Also in stop function I do (.unregisterLanguage hljs "clojure")
In shadow-cljs.edn
:devtools
{:before-load
:after-load }
Well, I don't necessarily need to load new languages at runtime, but you know, when something goes wrong, you really want to know, why, and whether you should ignore it or not 😄
I think you should not be getting that error 🙂
Hmm, I didn't even know you could use :before-load for this
For this project I don't seem to be using the metadata version of it.
Starting highlight.js is part of the app startup in my case so it makes sense to be in there.
It would be nice if I could wait for this error to appear again and try solving it using this, to see, whether it helped, but if that reloads the entire build, I wouldn't really know, whether it wouldn't get fixed just because of the build reload