klipse

gowder 2016-10-17T02:07:22.000034Z

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...

gowder 2016-10-17T02:08:39.000035Z

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.

gowder 2016-10-17T02:11:40.000036Z

(although with multiple languages, I'm not sure that would work. does klipse_settings.selector take an array of css selectors?

gowder 2016-10-17T02:24:45.000037Z

interesting. using class selectors doesn't seem to work, but selecting code elements does...

gowder 2016-10-17T03:47:02.000038Z

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

Yehonathan Sharvit 2016-10-17T16:20:35.000039Z

@mynomoto regarding github cache if raw files - usually it works, sometimes I’m appending url params for cache busters you know ?fsafdsfsf etc...

Yehonathan Sharvit 2016-10-17T16:20:54.000040Z

Also, opening dev tools and selecting cache=false

2016-10-17T16:22:19.000041Z

I tried disabling cache on dev tools but that wasn't working. I will try adding the query parameter next time, thanks!

Yehonathan Sharvit 2016-10-17T18:06:32.000042Z

@gowder why the markdown triple-backquote syntax didn’t work?

Yehonathan Sharvit 2016-10-17T18:06:45.000043Z

can you share an html page with the issue

Yehonathan Sharvit 2016-10-17T18:06:46.000044Z

?

Yehonathan Sharvit 2016-10-17T18:07:24.000046Z

Can u try to use ~~~klipse?

gowder 2016-10-17T18:10:52.000048Z

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.,

&lt;code class="clojure"&gt;
((comp (partial apply +) (partial map (partial * 3))) [1 2 3])
&lt;/code&gt;
in the markdown file, and then pass that class to window.klipse_settings

gowder 2016-10-17T18:12:23.000049Z

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

&lt;code class="python"&gt;print [x.upper() for x in ["foo", "bar"]]
&lt;/code&gt;
in order to avoid having an error in klipse

Yehonathan Sharvit 2016-10-17T18:20:49.000050Z

ok.

Yehonathan Sharvit 2016-10-17T18:20:54.000051Z

what’s your use casse?

Yehonathan Sharvit 2016-10-17T18:20:56.000052Z

a blog?

Yehonathan Sharvit 2016-10-17T18:21:00.000053Z

slides?

Yehonathan Sharvit 2016-10-17T18:21:01.000054Z

docs?

gowder 2016-10-17T18:28:56.000055Z

@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.

Yehonathan Sharvit 2016-10-17T18:37:02.000058Z

Yeah! You should let klipse do its job before highlight.js enters in action!

🎉 1
gowder 2016-10-17T18:37:36.000059Z

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.

Yehonathan Sharvit 2016-10-17T18:40:03.000061Z

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

gowder 2016-10-17T18:40:32.000063Z

oops. missed that altogether. thanks! 🙂

Yehonathan Sharvit 2016-10-17T18:40:42.000064Z

I would recommend not to host klipse locally - as you won’t enjoy the automatic upgrade of new klipse versions

Yehonathan Sharvit 2016-10-17T18:41:08.000065Z

I’m trying to maintain a pretty high pace of features

Yehonathan Sharvit 2016-10-17T18:41:09.000066Z

🙂

gowder 2016-10-17T18:41:51.000067Z

I'm not one to object to a pretty high pace of features 🙂

Yehonathan Sharvit 2016-10-17T18:42:29.000068Z

I mean - if you download a local version, your blog wont’ get the new features automatically

gowder 2016-10-17T18:43:07.000069Z

understood!

Yehonathan Sharvit 2016-10-17T18:43:37.000070Z

How did you discover about python?

gowder 2016-10-17T18:45:16.000071Z

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

gowder 2016-10-17T18:46:42.000072Z

aah, here it is: http://blog.klipse.tech/klipse/2016/09/09/klipse-languages.html

Yehonathan Sharvit 2016-10-17T18:51:13.000074Z

The reason I didn’t make python official yet is...

Yehonathan Sharvit 2016-10-17T18:51:41.000075Z

…that I didn’t find a way to make variables shared between code snippets @gowder

Yehonathan Sharvit 2016-10-17T18:52:00.000076Z

I think it make the whole stuff much less useful

gowder 2016-10-17T18:53:29.000077Z

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)

Yehonathan Sharvit 2016-10-17T18:55:48.000078Z

OK

Yehonathan Sharvit 2016-10-17T18:55:56.000079Z

I might include it in the README

Yehonathan Sharvit 2016-10-17T18:56:09.000080Z

a PR would be much welcome!

1
Yehonathan Sharvit 2016-10-17T19:00:43.000082Z

@mynomoto I took a look at https://mynomoto.github.io/hoplon-klipse/

Yehonathan Sharvit 2016-10-17T19:00:49.000083Z

It’s a nice start!

2016-10-17T19:53:10.000087Z

@viebel yeah, it is, but only really simple stuff works and I think the work to make other things work will be huge.

Yehonathan Sharvit 2016-10-17T20:12:10.000088Z

You mean to make hoplon self-host compatible?

2016-10-17T20:22:35.000090Z

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.

Yehonathan Sharvit 2016-10-17T20:24:00.000091Z

Do you need to access those macros directly inside klipse?

2016-10-17T20:27:30.000092Z

Yeah for the reactive part.

2016-10-17T20:28:20.000093Z

Main on missing is cell= but there is more good macro stuff there that used by users directly.

Yehonathan Sharvit 2016-10-17T20:28:43.000094Z

So, you need to port the macros to clojurescript

Yehonathan Sharvit 2016-10-17T20:28:57.000095Z

There is the same problem with core.match

2016-10-17T20:33:12.000096Z

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.