-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clerk in Babashka #232
Draft
zampino
wants to merge
17
commits into
main
Choose a base branch
from
bb-clerk
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Clerk in Babashka #232
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ff2ef75
First sketch of Clerk in Babashka
zampino 36ba59c
Fix bb task
zampino 066161f
Require latest babashka
zampino ed9b560
clean bb deps
zampino baa9660
Rely on latest bb for namespace instance check
zampino 4fc3526
Move stubs to bb files
zampino 1493d7b
Pass cli args to bb task
zampino 8406591
Fix add-viewers! and auto-resolve of ::alias keywords
zampino e5ce7ab
Extract var from def
zampino a4b3738
Fix static builder in bb runtime
zampino a642887
Fix markdown viewer for cljs consumption
zampino b6bd4c4
Add build bb task
zampino 7c95f89
Implement no-cache?
zampino 995e264
Parse markdown via quickjs
zampino 865c088
Check quickjs is available
zampino 38997c8
Lazily copy markdown js module
zampino 10e95c4
More escapes
zampino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{:min-bb-version "1.0.164" | ||
:paths ["bb/stubs" "src" "notebooks" "resources"] | ||
:deps {;; hash replacement? | ||
io.replikativ/hasch {:mvn/version "0.3.7"} | ||
weavejester/dependency {:mvn/version "0.2.1"} | ||
;; shiiiiet! | ||
;; io.github.nextjournal/markdown {:mvn/version "0.4.126"} | ||
hiccup/hiccup {:mvn/version "2.0.0-alpha2"} | ||
} | ||
:tasks | ||
{clerk | ||
{:requires ([babashka.fs :as fs] | ||
[babashka.nrepl.server :as srv] | ||
[nextjournal.clerk :as clerk]) | ||
:task (do (srv/start-server! {:host "localhost" :port 1339}) | ||
(spit ".nrepl-port" "1339") | ||
(clerk/serve! {:port 9999}) | ||
(-> (Runtime/getRuntime) | ||
(.addShutdownHook (Thread. (fn [] | ||
(clerk/halt!) | ||
(fs/delete ".nrepl-port"))))) | ||
(deref (promise)))}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns multihash.core) | ||
|
||
(defn base58 [h] "base58") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns multihash.digest) | ||
|
||
(defn sha2-512 [o] "sha2") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns nextjournal.beholder) | ||
|
||
(defn watch [cb & args] nil) | ||
(defn stop [w] nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
(ns nextjournal.clerk.analyzer | ||
(:require [nextjournal.clerk.config :as config] | ||
[edamame.core :as edamame])) | ||
|
||
(defn valuehash [value] "hash") | ||
(defn hash-codeblock [_ {:keys [hash]}] hash) | ||
(defn ->hash-str [value] "hash-str") | ||
(defn deref? [form] false) | ||
(defn hash [doc] doc) | ||
(defn hash-deref-deps [doc _cell] doc) | ||
|
||
(defn build-graph [doc] | ||
(-> doc | ||
(assoc :->analysis-info (fn [x] {:form x})) | ||
;; TODO: read first form, create sci.lang.Namespace | ||
(assoc :ns *ns*) | ||
(update :blocks | ||
(partial into [] (map (fn [{:as b :keys [type text]}] | ||
(cond-> b | ||
(= :code type) | ||
(assoc :form | ||
(edamame/parse-string text | ||
{:all true | ||
:readers *data-readers* | ||
:read-cond :allow | ||
:regex #(list `re-pattern %) | ||
:features #{:clj} | ||
;; TODO: | ||
#_#_:auto-resolve (auto-resolves (or *ns* (find-ns 'user)))}))))))))) | ||
|
||
(defn exceeds-bounded-count-limit? [x] | ||
(reduce (fn [_ xs] | ||
(try | ||
(let [limit config/*bounded-count-limit*] | ||
(if (and (seqable? xs) (<= limit (bounded-count limit xs))) | ||
(reduced true) | ||
false)) | ||
(catch Exception _e | ||
(reduced true)))) | ||
false | ||
(tree-seq seqable? seq x))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns nextjournal.markdown) | ||
|
||
(defn parse [md] {:type :doc :content md}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(ns nextjournal.markdown.parser) | ||
|
||
(defn add-title+toc [doc] doc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(ns nextjournal.markdown.transform) | ||
|
||
(defn ->text [node] "text") | ||
(defn table-alignment [attrs] {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(ns taoensso.nippy) | ||
|
||
(defn freezable? [x] false) | ||
(defn freeze [x] x) | ||
(defn thaw-from-file [file] "thawed") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
46k5SeDmWgR6seZFSVzwdiCJ7BEi | ||
3E4A2XqsHVVWy5QvM6RCuu7ScjWw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work now in the newest bb