Fork me on GitHub
#beginners
<
2016-07-12
>
val_waeselynck07:07:18

that should get you going 🙂

davin11:07:42

Sorry if this is very basic, I’m new to Clojurescript and I’m trying to configure cljsjs/marked and cljsjs/highlight. I’m attempting to use marked.setOptions to send in an options object. This is a fairly common js pattern so there must be something I’m missing.

davin11:07:55

So, this is the code I’m trying to convert:

davin11:07:09

marked.setOptions({
  highlight: function (code) {
    return require('highlight.js').highlightAuto(code).value;
  }
});

davin11:07:18

This is what I’ve got:

davin11:07:35

(.setOptions js/marked (js-obj "highlight" (fn [code] (.highlightAuto js/highlight code))))

davin11:07:03

Is this off topic here?

martinklepsch11:07:09

No, perfectly fine

davin11:07:10

or is it ok to ask

davin11:07:34

I don’t think that js-obj can define functions, is that correct?

davin11:07:44

Is it just key/value

martinklepsch11:07:24

You can try #js {} instead of js-obj which is easier to read imho but I think both should work

davin11:07:54

I get error highlight is not defined

davin11:07:16

not a lot of help, I know

davin11:07:11

Actually the error is Uncaught ReferenceError: highlight is not defined called from inside marked

davin11:07:17

somewhere

martinklepsch11:07:34

CLJSJS packages don't expose any globals like js/highlight on their own, instead they just load a library's file which usually defines the global. In the case of highlight.js the global seems to be called hljs so try js/hljs maybe

davin11:07:54

thx, I’ll give it a try

davin11:07:38

nice one! no more error

davin11:07:20

not quite rendering correctly, it renders out [object Object]. Must be a way to convert that to a str.

davin11:07:59

But this is internal to my configuration. Thanks for the help @martinklepsch!

martinklepsch11:07:33

@davin I think you might be missing the .value thing from the JS snippet

davin11:07:58

I think you are right 🙂

davin11:07:01

working now, thanks again @martinklepsch

yusup20:07:20

`(System/setProperty "archaius.configurationSource.defaultFileName" "archaius.properties")` , where should I put this sort of init code while generating uberjar?

volrath22:07:30

quick question: I have a record A which is a relatively big data structure that has other records in it, for example:

#A{:some "fields" :another-record #B{:a b :c d} ...}
I want to transform it all into a simple map, what would be a nice way to do that? I thought of recursively applying (into {} ...) to all the records (internals and external), but I guess there should be a better way