Fork me on GitHub

does anyone know if there's a relevant room for the mfikes esprit cljs boards?


@dpsutton I just made #esprit ... seems like a good idea to have such a thing 🙂


i agree. thanks!


in advanced-optmization browser builds, I always get var process={} this appears after foreign-libs and before my actual code. the variable is not actually referred to in any of the output of the builds. This is on recent versions of cljs - not sure about older versions. Anyone know what it's doing there? I mean I guess it has something to do with node, which has always provides process object. As you might guess it's causing a problem with a non-cljs library that must be using the presence of this to decide what platform it's on


likely the :process-shim compileroption? I'm not sure what the default is, might be true?


exactly that! thanks very much.


suppose I want to bold some text in a div:

[:div "This is some text and THIS should be bold."]
and I want "THIS" to be bold. Do I have to split the div, or can this be done within the string?


You can wrap "THIS" in a span within that div and style that span.


how do I turn the html response of a clj-http.client/get request into hiccup?


one uses hiccup.core/html to convert from hiccup to html


how to do the opposite?


I've used enlive ages ago for something similar - it did give me data structures from html, but I don't think it was hiccup


if there's something that does do html->hiccup reliably I don't know of it


yeah - it ha functions to extract data from html


So long as it is parsable it will suit the need. Doesn't have to be huicup. how did the api work for converting an html string to a parsable data structure?


the html-resource function, if I recall correctly


This example there:

(-> "" URL. html-resource 
  (select [:body :img]) first :attrs :src) 
gives nil


perhaps the structure of the page has changed - if you just stop at html-resource, what does that look like?


Yeah that returns

({:type :dtd, :data ["HTML" "-//IETF//DTD HTML 2.0//EN" ""]}
 {:tag :html,
  :attrs nil,
  ({:tag :head,
    :attrs nil,
    :content ("\n" {:tag :title, :attrs nil, :content ("302 Found")} "\n")}
   {:tag :body,
    :attrs nil,
     {:tag :h1, :attrs nil, :content ("Found")}
     {:tag :p,
      :attrs nil,
      ("The document has moved "
       {:tag :a,
        :attrs {:href ""},
        :content ("here")}
     {:tag :hr, :attrs nil, :content nil}
     {:tag :address,
      :attrs nil,
      ("Apache/2.4.38 (Debian) Server at  Port 80")}
but on another url I tried, this error is thrown:
Execution error (UnknownServiceException) at (
no content-type 1241  740
           enlive_html.clj:  115  net.cgrand.enlive-html/eval44675/fn
      234  clojure.lang.MultiFn/invoke
           enlive_html.clj:   69  net.cgrand.enlive-html/html-resource
           enlive_html.clj:   66  net.cgrand.enlive-html/html-resource
                      REPL:  115  user/eval45429
                      REPL:  115  user/eval45429
    7177  clojure.lang.Compiler/eval
    7132  clojure.lang.Compiler/eval
                  core.clj: 3214  clojure.core/eval
                  core.clj: 3210  clojure.core/eval
    interruptible_eval.clj:   91  nrepl.middleware.interruptible-eval/evaluate/fn
                  main.clj:  437  clojure.main/repl/read-eval-print/fn
                  main.clj:  437  clojure.main/repl/read-eval-print
                  main.clj:  458  clojure.main/repl/fn
                  main.clj:  458  clojure.main/repl
                  main.clj:  368  clojure.main/repl
       137  clojure.lang.RestFn/applyTo
                  core.clj:  665  clojure.core/apply
                  core.clj:  660  clojure.core/apply
                regrow.clj:   18  refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
      1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   84  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   56  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  155  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
           22  clojure.lang.AFn/run
               session.clj:  190  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  189  nrepl.middleware.session/session-exec/main-loop
           22  clojure.lang.AFn/run
       748  java.lang.Thread/run


how to fix the no content-type error?


that's odd - must be the kind of thing browsers work around automatically...


i think i remember looking at this once. its not super fun to parse a string as opposed to a resource based thing. either file uri or net uri


it really wants to get something from somewhere


In this particular case, there seems to be no api, so the html page must be fetched and parsed to extract the data


@dpsutton are there alternatives to enlive for parsing html?


i'm gonna google clj parse html to hiccup.


seems like a jumping off point. but this seems like lots of jvm talk in the clojurescript channel


(and not saying we shouldn't talk about it here, just worried that after a while down this rabbit hole these jvm based solutions won't fit your needs)