Skip to content

Commit db26c83

Browse files
authored
Bump nextjournal markdown (#752)
1 parent f4c5488 commit db26c83

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ clerk.iml
2727
report.html
2828
/editor.clj
2929
package.json
30+
scratch.clj

deps.edn

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
weavejester/dependency {:mvn/version "0.2.1"}
77
com.nextjournal/beholder {:mvn/version "1.0.2"}
88
org.flatland/ordered {:mvn/version "1.15.12"}
9-
io.github.nextjournal/markdown {:mvn/version "0.6.157"
10-
;; only used in cljs
11-
:exclusions [applied-science/js-interop]}
9+
io.github.nextjournal/markdown {:mvn/version "0.7.184"}
1210
babashka/process {:mvn/version "0.4.16"}
1311
io.github.nextjournal/dejavu {:git/sha "4980e0cc18c9b09fb220874ace94ba6b57a749ca"}
1412
io.github.babashka/sci.nrepl {:mvn/version "0.0.2"}

notebooks/markdown.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ This notebook demoes feeding Clerk with markdown files. We currently make no ass
66
^:nextjournal.clerk/no-cache
77
(ns markdown-example
88
(:require [nextjournal.clerk :as clerk]
9-
[nextjournal.markdown :as md]
10-
[nextjournal.markdown.transform :as md.transform]))
9+
[nextjournal.markdown :as md]))
1110
```
1211

1312
Nextjournal Markdown library is able to ingest a markdown string
@@ -932,12 +931,12 @@ and render back to hiccup with customisable elements.
932931

933932
```clojure
934933
(def renderers
935-
(assoc md.transform/default-hiccup-renderers
936-
:doc (partial md.transform/into-markup [:div.markdown-viewer])
934+
(assoc md/default-hiccup-renderers
935+
:doc (partial md/into-hiccup [:div.markdown-viewer])
937936
:ruler (constantly [:hr.mt-1.mb-10.border-0.w-full.h-5.bg-fuchsia-900.rounded-full])))
938937

939938
(def hiccup
940-
(md.transform/->hiccup renderers sliced))
939+
(md/->hiccup renderers sliced))
941940
```
942941

943942
and finally render via Clerk's `html` helper.

src/nextjournal/clerk/parser.cljc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
[clojure.zip]
1313
[edamame.core :as edamame]
1414
[nextjournal.markdown :as markdown]
15-
[nextjournal.markdown.transform :as markdown.transform]
1615
[rewrite-clj.node :as n]
1716
[rewrite-clj.parser :as p]
1817
[rewrite-clj.zip :as z]))
@@ -162,7 +161,7 @@
162161
(comp (keep :doc)
163162
(mapcat :content)
164163
(filter (comp #{:paragraph} :type))
165-
(map markdown.transform/->text))
164+
(map markdown/node->text))
166165
blocks))]
167166
(cond-> {:type "article:clerk"}
168167
title (assoc :title title)
@@ -505,7 +504,7 @@
505504
(parse-clojure-string ";; # Hello\n;; ## 👋 Section\n(do 123)\n;; ## 🤚🏽 Section"))
506505

507506
(defn parse-markdown-cell [state opts]
508-
(assoc (parse-clojure-string opts state (markdown.transform/->text (first (:nodes state))))
507+
(assoc (parse-clojure-string opts state (markdown/node->text (first (:nodes state))))
509508
:nodes (rest (:nodes state))
510509
::md-slice []))
511510

src/nextjournal/clerk/viewer.cljc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
(ns nextjournal.clerk.viewer
22
(:refer-clojure :exclude [var?])
3-
(:require [clojure.string :as str]
3+
(:require [clojure.datafy :as datafy]
44
[clojure.pprint :as pprint]
5-
[clojure.datafy :as datafy]
65
[clojure.set :as set]
6+
[clojure.string :as str]
77
[flatland.ordered.map :as omap :refer [ordered-map]]
88
#?@(:clj [[babashka.fs :as fs]
99
[clojure.repl :refer [demunge]]
@@ -21,8 +21,7 @@
2121
[nextjournal.clerk.parser :as parser]
2222
[nextjournal.clerk.walk :as w]
2323
[nextjournal.markdown :as md]
24-
[nextjournal.markdown.utils :as md.utils]
25-
[nextjournal.markdown.transform :as md.transform])
24+
[nextjournal.markdown.utils :as md.utils])
2625
#?(:clj (:import (com.pngencoder PngEncoder)
2726
(clojure.lang IDeref IAtom)
2827
(java.lang Throwable)
@@ -788,7 +787,7 @@
788787
[:div.code-viewer.code-listing
789788
(with-viewer `code-viewer
790789
{:nextjournal/render-opts {:language (:language % "clojure")}}
791-
(str/trim-newline (md.transform/->text %)))]))}
790+
(str/trim-newline (md/node->text %)))]))}
792791

793792
;; marks
794793
{:name :nextjournal.markdown/em :transform-fn (into-markup [:em])}
@@ -824,9 +823,9 @@
824823
{:name :nextjournal.markdown/table-body :transform-fn (into-markup [:tbody])}
825824
{:name :nextjournal.markdown/table-row :transform-fn (into-markup [:tr])}
826825
{:name :nextjournal.markdown/table-header
827-
:transform-fn (into-markup #(vector :th {:style (md.transform/table-alignment (:attrs %))}))}
826+
:transform-fn (into-markup #(vector :th {:style (md/table-alignment %)}))}
828827
{:name :nextjournal.markdown/table-data
829-
:transform-fn (into-markup #(vector :td {:style (md.transform/table-alignment (:attrs %))}))}
828+
:transform-fn (into-markup #(vector :td {:style (md/table-alignment %)}))}
830829

831830
;; ToC via [[TOC]] placeholder ignored
832831
{:name :nextjournal.markdown/toc :transform-fn (into-markup [:div.toc])}
@@ -1243,7 +1242,7 @@
12431242

12441243
(defn md-toc->navbar-items [{:keys [children]}]
12451244
(mapv (fn [{:as node :keys [emoji attrs]}]
1246-
{:title (str/replace (md.transform/->text node) (re-pattern (str "^" emoji "[ ]?")) "")
1245+
{:title (str/replace (md/node->text node) (re-pattern (str "^" emoji "[ ]?")) "")
12471246
:emoji emoji
12481247
:path (str "#" (:id attrs))
12491248
:items (md-toc->navbar-items node)}) children))

0 commit comments

Comments
 (0)