Closed rutchkiwi closed 6 months ago
I haven't manage to test the new actual JS file from my browser - where/how do you actually find that JS file? Is it in the .jar file?
You'd have to compile the js using something like shadow-cljs. Typically, the library would be used as cljs dependency from within a cljs based project. It's worth noting that making a js artifact will pull in a lot of cljs core, so it will be relatively large. This is why cljs libs are typically not used as standalone dependencies in js projects.
You'd have to compile the js using something like shadow-cljs. Typically, the library would be used as cljs dependency from within a cljs based project. It's worth noting that making a js artifact will pull in a lot of cljs core, so it will be relatively large. This is why cljs libs are typically not used as standalone dependencies in js projects.
Hmm okay, do you have any tips for doing the shadown-cljs compiling? Is there a build step for it? I think I got the JS version from the demo page, so it'd have to go in there I guess?
In regards to the .js artefact being big, it is not really a problem for me, as my use case is that I've got a user-facing website that renders the markdown using normal JVM clojure. But then I've got a back office system for editing content, and that is where the .js version does it. (also it's only 50kb compressed!)
Ah I see, I've added a build option in project.clj
for creating the Js artifact. If you rebase your branch to the latest you can run lein with-profile js cljsbuild once
to make a standalone markdown.js
file. If you can confirm your changes work then we can merge the PR. And also if you can revert the change in clj
version. :)
Thanks, I've done that and verified that the JS works now.
Regarding the removal of the stuff from the cli version - doing so breaks the tests. Is there a way to add a a test only for the cljs?
Oh yeah, you just have to wrap the test as follows
#?(:cljs
(is (=
"<h3 id=\"foo_bar_baz\">foo bar BAz</h3><p>some text</p>"
; Also testing that keywords args can be passed as strings, for javascript compatibility
(entry-function "###foo bar BAz##\nsome text" "heading-anchors" true))))
Ah nice, thanks. All sorted now.
Awesome, glad to hear everything's working. :)
In javascript, there are no keywords, so we simply convert string to keywords first. This feature is added to the clojure version as well, mostly because I don't know how to run a make a test only for the JS version.
Fixes https://github.com/yogthos/markdown-clj/issues/197