Fork me on GitHub
#beginners
<
2022-09-30
>
Erlangga09:09:13

Hi everyone, So i want to reload this namespace to REPL

(ns reporting-example.reports
  (:require [reporting-example.db.core :as db]
            [clj-pdf.core :refer [pdf template]]))
but when i want to use the pdf function after i reload that namespace to REPL, why it's says Unable to resolve symbol: pdf in this context ? And if i do load file in REPL the error goes to : Execution error (UnsatisfiedLinkError) at java.lang.ClassLoader/loadLibrary (ClassLoader.java:2633). Can't load library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so I already restart all the applications, but nothing happen. Btw, I use Intellij IDEA Community Edition with Cursive and nREPL run with Leiningen.

afleck15:09:56

lack of libawt might mean you have headless jdk

afleck15:09:44

if you’re using leiningen, does it work if you just run lein repl at the command line and load the namespace in the repl?

Erlangga02:10:41

Hey thanks! Sorry for the late reply. Yeah, you right, i think the problem that I've encountered is I have headless jdk, and it solved by :

$ sudo apt install openjdk-11-jdk
and run
$ ldd /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
I hope this help anyone who encountered the same problem, Thanks again!

Vinicius Vieira Tozzi22:09:49

Hello, is there a library I can use to convert HTML to markdown? I found https://github.com/yogthos/markdown-clj but I think this one only converts markdown to html and not the other way around. My use case is that I want to convert html e-mails into markdown files, I already could parse into plain text using https://github.com/owainlewis/clojure-mail, but when converting to plain text I lose the all the formatting such as line breaks.

craftybones13:10:45

HTMl -> Markdown might not always be possible. Markdown only has sigils for a subset of HTML tags. Having said that, you could use Hickory to parse HTML into Hiccup and then render that into Markdown yourself maybe? https://github.com/clj-commons/hickory

craftybones13:10:04

Another useful tool you should consider is bootleg https://github.com/retrogradeorbit/bootleg

teodorlu14:10:38

I've come to rely heavily on https://pandoc.org/ for all things markdown, HTML and org-mode. You'll find it in homebrew and packaged for most linux distributions.

$ pandoc -f markdown -t html <<< "# My heading"
<h1 id="my-heading">My heading</h1>

$ pandoc -f html -t markdown <<< '<h1>To action!</h1><p>We like actions.</p>'
# To action!

We like actions.
Here's how to shell out to pandoc with https://github.com/babashka/process to convert org-mode to html:
(require '[babashka.process :refer [process]])

(defn pandoc-org->html
  "String -> String, Org-mode to HTML"
  [org-markup]
  (slurp (:out (process
                '[pandoc --from org+smart --to html --standalone]
                {:in org-markup}))))
where you can adapt --from and --to to your liking for markdown.

☝️ 1
teodorlu14:10:13

Downside with pandoc: there's a binary to install; not a JVM package that "just works".

Vinicius Vieira Tozzi15:10:55

yeah I always used pandoc and it worked great, I don’t really mind having a separate binary to install but I was not aware you could actually call a shell command from clojure, that’s really interesting, thanks!

😄 1
Vinicius Vieira Tozzi15:10:57

do you know if I can use any library from clj in babashka? right know I am using babasha/fs in my jvm project, but if I can run clojure-mailon babashka then I can build my solution entirely with babashka and that would be nice

Vinicius Vieira Tozzi15:10:40

I also just learned that clojure.java.shell` is a thing reading babshka process README

teodorlu15:10:57

> do you know if I can use any library from clj in babashka? > No - unfortunately, not all clojure libraries work on babashka. babashka/fs is written specifically to support both JVM Clojure and babashka, though. So in that case, the code should be exactly the same. Or you can use clojure.java.shell as you noted 🙂

Vinicius Vieira Tozzi16:10:08

yeah, but most of my program is parsing/reading emails with clojure-mail , so I my app will have to run on jvm, but no problem, babashka.process seems very promising I will try it out, thanks for the help

👍 1
Jacob O'Bryant17:10:17

I've been using this for html->markdown: https://github.com/furstenheim/copy-down I use it to render a text version of the html emails I send. I honestly never look at the output though ha ha so I'm not sure how good of a rendering it is, but worth looking at at least.

👍 2
Vinicius Vieira Tozzi19:10:42

Thanks! I will check it out