I changed something about babashka tasks which I think is an improvement but could potentially break existing code, although it seems unlikely to me.
The changes:
• :init is now ran after global task :requires but before specific task :requires (old behavior: after both requires). This lets you e.g. set a System property before specific task namespaces are loaded that reads it
• :init is now only ran once. The behavior before was that it ran potentially multiple times if you used run in your code, e.g. (run 'task-b) .
I'd appreciate it if you could test out the dev build with: bash <(curl to see if your tasks aren't affected by this.
This seems sensible and fine to me but will give it a whirl and report back
@lee https://clojurians.slack.com/archives/C8NUSGWG6/p1748607808841879?thread_ts=1748578704.342109&cid=C8NUSGWG6
Oopsies! The king of typos and mal-pasters strikes again! Tx
I tried bb babashka v1.12.201-SNAPSHOT out on various projects with bb.edn that use :init and some that don't.
I did not notice any problems at all.
good, thanks!
I read back some threads from this channel from 2020 and found this comment by @dominicm and the comment by @nate: the idea that bb could talk to several other bb instances with other features (jdbc etc) via a pipe. A month later the pods library was born (which was also heavily inspired by how nREPL works). https://clojurians.slack.com/archives/CLX41ASCS/p1587824080017300?thread_ts=1587810643.473500&cid=CLX41ASCS
Cool! Today in bb history!
Fun to see conversations from more than 5 years ago. I think pods have really done well, and the pod-registry makes them super easy to install. Just used the sqlite one for the first time in the last week and it just works.
I feel like I'm missing some function somewhere, but is there a way to list all files in a dir recursive using babashka/fs?
like babashka.fs/list-dir but entering the dirs if any
you could just use file-seq for this
ah yeah, I forgot about that facepalm
but if you're looking for specific files, you can use fs/glob
which is recursive
got it, I want all files indeed
you can also use https://github.com/babashka/fs/blob/master/API.md#walk-file-tree which is a visitor for all files in a directory
actually, on a second thought, only clojure related ones
yeah I saw that one but I thought there was a easier one
I have source-paths and wanna convert them to clojurable uris
$ bb -e '(map str (fs/glob "." "**.{edn}"))'
("tests.edn" "shadow-cljs.edn" "deps.edn" "resources/clj-kondo.exports/nextjournal/clerk/config.edn" "resources/META-INF/nextjournal/clerk/meta.edn" "render/deps.edn" "ui_tests/nbb.edn" "public/build/index.edn" "public/build/book.edn" "public/build/CHANGELOG.edn" "bb-runtime.edn" "bb.edn" "garden.edn")awesome, will try this one, thank you!
(map (comp str fs/canonicalize)
(fs/glob "." "**.{edn,clj,cljs,cljc,bb,cljd,clj_kondo}"))
yes
I'm contemplating adding a markdown library to babashka. The reasons for this are as follows: • Babashka already has built-in (= performant) support for common formats: EDN, JSON, CSV, YAML. Markdown is a common format. Adding this will make bb a good engine to build static blogging frameworks on. • markdown-clj is pretty good and bb-compatible, but it doesn't implement the CommonMark spec to the letter (it parses stuff line by line, which gets you 90% there but it has some quirks). Quickblog is already a bb-compatible blogging framework which uses markdown-clj. A built-in library would provide even better performance and CommonMark compliance (depending on the chosen lib). • Clerk support. As we speak I'm writing notebooks in babashka with clerk (with a locally compiled bb, see comment in #clerk). Clerk needs a markdown library which spits out an intermediate AST before going all the way to HTML. I've tested https://github.com/nextjournal/markdown for this (which is used in clerk) and it only adds 1MB to the binary (from 69MB to 70MB) which may very well be worth it. Any thoughts on this? Any other use cases you would have for a markdown library in bb? Issues reported with markdown-clj that violate the commonmark spec: - https://github.com/yogthos/markdown-clj/issues/97 - https://github.com/yogthos/markdown-clj/issues/100 - https://github.com/yogthos/markdown-clj/issues/114 - https://github.com/yogthos/markdown-clj/issues/146 - https://github.com/yogthos/markdown-clj/issues/156 - https://github.com/yogthos/markdown-clj/issues/170 - https://github.com/yogthos/markdown-clj/issues/180 - https://github.com/yogthos/markdown-clj/issues/181 - https://github.com/yogthos/markdown-clj/issues/190 (Yes, I know there's asciidoctor fans out here too, but limiting this discussion to markdown, sorry ;-)).
I’ve been using the asciidoc variant of markdown more over time.
I'll say this again: binary size doesn't matter as much as it did in 1997 😉
sure, but adding libs also increases compile time :) nextjournal/markdown + java CommonMark isn't very heavy though
Definitely, but for me, there's still a psychological 2-digit MB limit. 😄
Not that going over that limit would make me give up Babashka...
@borkdude that's fair, sounds like a more important consideration, out of curiosity - have you been tracking compile time increase with every major library addition?
I have. binary size too. Let me check compile time with and without nextjournal.markdown on CI. current master linux: 3m7 current nextjournal-markdown linux: 3m11
shipit
There's also the markdown over in the bootleg pod. Haven't used it and don't know if it does AST. As a pod, it would be slower than native.
the bootleg pod uses markdown-clj which runs with bb from source since a few years
I updated the original message with a list of issues from markdown-clj that violate the commonmark spec
I like the idea of running clerk with bb, and the markdown library from nextjournal looks nice. Biggest things I look for in a markdown parser is the github extensions.
What Github extensions in particular? I think a few of them are enabled, but not sure if all the ones you need are. This is the time to discuss!
TODO list / checkboxes do work
oh, I thought that fenced code blocks were GFM, but it looks like they're part of the base spec
Looks like tables are an extension
@nate looks like nextjournal.markdown supports tables out of the box:
(md/parse "| Name | Age | Occupation |
|------------|-----|----------------|
| Alice | 30 | Engineer |
| Bob | 25 | Designer |
| Charlie | 35 | Product Manager|")
{:toc {:type :toc}, :footnotes [], :content [{:type :table, :content [{:type :table-head, :content [{:type :table-row, :content [{:type :table-header, :content [{:type :text, :text "Name"}]} {:type :table-header, :content [{:type :text, :text "Age"}]} {:type :table-header, :content [{:type :text, :text "Occupation"}]}]}]} {:type :table-body, :content [{:type :table-row, :content [{:type :table-data, :content [{:type :text, :text "Alice"}]} {:type :table-data, :content [{:type :text, :text "30"}]} {:type :table-data, :content [{:type :text, :text "Engineer"}]}]} {:type :table-row, :content [{:type :table-data, :content [{:type :text, :text "Bob"}]} {:type :table-data, :content [{:type :text, :text "25"}]} {:type :table-data, :content [{:type :text, :text "Designer"}]}]} {:type :table-row, :content [{:type :table-data, :content [{:type :text, :text "Charlie"}]} {:type :table-data, :content [{:type :text, :text "35"}]} {:type :table-data, :content [{:type :text, :text "Product Manager"}]}]}]}]}], :type :doc}sweet!
nice that it parses to an AST, very Clojure-y
yeah and it has one transformer that happens to transform to hiccup so it's very easy to modify the generated HTML too as a post-processing step
I have no opinion on this markdown business simple_smile But another github extension that was not part of the official spec, last time I checked, is https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts. Fwiw, cljdoc uses https://github.com/vsch/flexmark-java for markdown support. It's very flexible, but also, I think, no longer actively developed/supported.
ok yeah for alerts, I think it would be easy enough to traverse the hiccup and modify that if you want it.
[!NOTE]
Useful information that users should know, even when skimming content.
or just incercept block_quote before it's turned into hiccup. I think this is doable with nextjournal.markdown in multiple placesflexmark-java is a fork of commonmark-java btw. luckily nextjournal.markdown doesn't expose any of this stuff, it's hidden in an .impl namespace so switching the Java lib would still be possible in the future
Yeah, not too tricky. I did not find specific rules for github markdown alert syntax, so I figured out what I could at the time for cljdoc through experimentation: https://github.com/cljdoc/cljdoc/issues/906
I'll try to do a POC if I think about this again when I have time to see how easy it would be in nextjournal.markdown to do the same (without writing Java)
@lee here's the POC. It's a bit unwieldy but compared to writing Java I'd say it's not too bad.
(require '[clojure.pprint :as pprint]
'[nextjournal.markdown :as md]
'[nextjournal.markdown.transform :as md.transform])
(def blockquote-renderer (:blockquote md.transform/default-hiccup-renderers))
(clojure.pprint/pprint
(md/->hiccup
(assoc md.transform/default-hiccup-renderers
:blockquote
(fn [ctx {:keys [content] :as elt}]
(if (= 1 (count content))
(let [{:keys [content type]} (first content)]
(if (and (= :paragraph type)
(= "[!NOTE]" (-> content first :text)))
[:div {:style {:color "green"}}
(blockquote-renderer ctx
(update elt :content
(fn [[paragraph]]
[(update paragraph :content (fn [text-nodes]
(drop 2 text-nodes)))])))]
(blockquote-renderer ctx elt)))
(blockquote-renderer ctx elt))))
"> [!NOTE]
> Useful information that users should know, even when skimming content.
> Normal blockquote"
))
$ clj -M scratch.clj
[:div
[:div
{:style {:color "green"}}
[:blockquote
[:p
"Useful information that users should know, even when skimming content."]]]
[:blockquote [:p "Normal blockquote"]]]