has anyone out there figured out how to automatically klipse-ify code blocks in posts generated by cryogen? I'm thinking that probably the easiest thing to do would be to just stick in some javascript at the end to automatically add klipse classes to all code blocks, but if there's a more straightforward way I'd love to hear it...
oooh, actually, it looks like highlight.js automatically adds classes like "hljs clojure" to code blocks, so it might be as easy as just configuring klipse to look for that.
(although with multiple languages, I'm not sure that would work. does klipse_settings.selector
take an array of css selectors?
interesting. using class selectors doesn't seem to work, but selecting code elements does...
ok, the solution is apparently to just put straight html in the markdown and give it a code tag with a klipse class, rather than using the markdown triple-backquote syntax
@mynomoto regarding github cache if raw files - usually it works, sometimes I’m appending url params for cache busters you know ?fsafdsfsf
etc...
Also, opening dev tools and selecting cache=false
I tried disabling cache on dev tools but that wasn't working. I will try adding the query parameter next time, thanks!
@gowder why the markdown triple-backquote syntax didn’t work?
can you share an html page with the issue
?
Can u try to use ~~~klipse
?
I'll give it a shot in a bit. My guess is that the cryogen markdown parser was doing something funny with the classes when it wraps code blocks in <pre> and <code>. The workaround that I just went with is to just use, e.g.,
<code class="clojure">
((comp (partial apply +) (partial map (partial * 3))) [1 2 3])
</code>
in the markdown file, and then pass that class to window.klipse_settings
the only weird behavior I see with that is that the linebreak after the code tag adds extraneous whitespace in python code blocks, so I'm doing things like
<code class="python">print [x.upper() for x in ["foo", "bar"]]
</code>
in order to avoid having an error in klipseok.
what’s your use casse?
a blog?
slides?
docs?
@viebel a blog. But actually, it looks like I can get it working by applying appropriate classes in the markdown code block, as per your suggestion. https://paultopia.github.io/ --- source https://raw.githubusercontent.com/paultopia/experimental-cryogen/master/resources/templates/md/posts/second.md
behaves appropriately, where "clojure" is given as a class in the markdown block and is specified in window.klipse_settings
Interestingly, python works fine that way too, and doesn't include extraneous whitespace with markdown, even though it does include extraneous whitespace with a html code tag.
I think my original issue, which led me to think that class identification wasn't working, was to try to piggyback the klipse selectors off the classes that highlight.js code identification was doing. And that just flat out was not working... possibly because of some weird javascript async thing involving the order the classes were added or something.
Yeah! You should let klipse do its job before highlight.js enters in action!
oh, actually, while we're here: it might be worth noting that pages served over https don't work with loading klipse from app.klipse.tech -- it looks like you're only serving http there, and modern browsers reject the mixed requests on security grounds. I ended up just hosting local copies of all the javascript and css. (also, the readme doesn't have information for python evaluation, just the other languages) Also, for anyone else interested, interesting strategy I'm trying out is to only load klipse plus all the plugins on posts that have executable code, just by adding a variable to posts. See lines 99-103 of https://github.com/paultopia/experimental-cryogen/blob/master/resources/templates/themes/nucleus/html/base.html Having so much fun with klipse. this is a freaking amazing innovation. thank you so much for writing it.
I’m aware of the issue with https, the solution is to use <https://storage.googleapis.com/app.klipse.tech>
instead of <http://app.klipse.tech>
as specified in https://github.com/viebel/klipse#https
oops. missed that altogether. thanks! 🙂
I would recommend not to host klipse locally - as you won’t enjoy the automatic upgrade of new klipse versions
I’m trying to maintain a pretty high pace of features
🙂
I'm not one to object to a pretty high pace of features 🙂
I mean - if you download a local version, your blog wont’ get the new features automatically
understood!
How did you discover about python?
somewhere floating around in the repo or the blog I think you've got a demo page with plugins for each language. I just grabbed the code from there
aah, here it is: http://blog.klipse.tech/klipse/2016/09/09/klipse-languages.html
The reason I didn’t make python official yet is...
…that I didn’t find a way to make variables shared between code snippets @gowder
I think it make the whole stuff much less useful
Ooooooh. Makes sense. I still think it's pretty useful though, at least for my purposes (occasionally comparing small chunks of code in different languages)
OK
I might include it in the README
a PR would be much welcome!
@mynomoto I took a look at https://mynomoto.github.io/hoplon-klipse/
It’s a nice start!
@viebel yeah, it is, but only really simple stuff works and I think the work to make other things work will be huge.
You mean to make hoplon
self-host compatible?
Yeah, actually the problem should be javelin
that is a lib that hoplon
depends on. I'm uncertain about how to fix macros that depends on jvm namespaces even when those are available in cljs.
Do you need to access those macros directly inside klipse?
Yeah for the reactive part.
Main on missing is cell=
but there is more good macro stuff there that used by users directly.
So, you need to port the macros to clojurescript
There is the same problem with core.match
The fun part is that javelin
was supposed to work on clojure also but atm it only works on cljs. Maybe I can make it work on both when trying to port the macros.