Skip to content

Commit

Permalink
Use latest commit available on jitpack (temporarily disable footnotes)
Browse files Browse the repository at this point in the history
  • Loading branch information
zampino committed Aug 13, 2024
1 parent 204c9eb commit cdec3d4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
32 changes: 21 additions & 11 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{:paths ["src" "resources" "classes"]
:mvn/repos {"jitpack.io" {:url "https://jitpack.io"}}
:deps {applied-science/js-interop {:mvn/version "0.3.3"}
org.clojure/data.json {:mvn/version "2.4.0"}
org.graalvm.js/js {:mvn/version "21.3.2.1"}

;; commonmark
;; org.commonmark/commonmark {:mvn/version "0.22.0"}
;; use temporary jitpack commit until release
;; com.github.commonmark/commonmark-java {:mvn/version "3733963"}
com.github.commonmark/commonmark-java {:local/root "./jars/commonmark-0.22.1-SNAPSHOT.jar"}
org.commonmark/commonmark-ext-task-list-items {:local/root "./jars/commonmark-ext-task-list-items-0.22.1-SNAPSHOT.jar"}
org.commonmark/commonmark-ext-footnotes {:local/root "./jars/commonmark-ext-footnotes-0.22.1-SNAPSHOT.jar"}
}
;;org.commonmark/commonmark {:mvn/version "0.22.0"}
;;org.commonmark/commonmark-ext-task-list-items {:mvn/version "0.22.0"}

:mvn/repos {"jitpack.io" {:url "https://jitpack.io"}}
;; use jitpack until release
com.github.commonmark/commonmark-java {:mvn/version "faea2a2a61cfa1b1f26a4e914532b651b3602e34"}
com.github.commonmark.commonmark-java/commonmark-ext-task-list-items {:mvn/version "faea2a2a61cfa1b1f26a4e914532b651b3602e34"}

;; jitpack bisect

;; origin/main bad
;; 7b48401897a0c0bf46e757445a20deab78796101 bad (first)

;; faea2a2a61cfa1b1f26a4e914532b651b3602e34 good
;; dd0a4be86643ba95da7304336e2ab123a74d0e35 good
;; 3733963538bd52d619da40508d837186316dadbb good

;; jitpack stopped working as of commit, use local jars
;; com.github.commonmark/commonmark-java {:local/root "./jars/commonmark-0.22.1-SNAPSHOT.jar"}
;; org.commonmark/commonmark-ext-task-list-items {:local/root "./jars/commonmark-ext-task-list-items-0.22.1-SNAPSHOT.jar"}
;; org.commonmark/commonmark-ext-footnotes {:local/root "./jars/commonmark-ext-footnotes-0.22.1-SNAPSHOT.jar"}
}

:aliases
{:nextjournal/clerk
Expand Down Expand Up @@ -55,9 +68,6 @@
:git/sha "e8f275b5cf077ec9441e404c1885ff0b6ee0aef9"
:deps/root "render"}}}

:commonmark-java-local
{:extra-paths ["../commonmark-java/commonmark/target/classes"]}

:build
{:ns-default build
:deps {io.github.clojure/tools.build {:git/tag "v0.6.1" :git/sha "515b334"}
Expand Down
Binary file removed jars/commonmark-0.22.1-SNAPSHOT.jar
Binary file not shown.
Binary file removed jars/commonmark-ext-footnotes-0.22.1-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion src/nextjournal/markdown.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[nextjournal.markdown.parser.impl.utils :as u]
[nextjournal.markdown.transform :as markdown.transform]))


;; TODO: remove fixme (shadow compile warnings)
(defn tokenize [_] [])

Expand Down
11 changes: 7 additions & 4 deletions src/nextjournal/markdown/parser/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[nextjournal.markdown.parser.impl.utils :as u])
(:import (org.commonmark.parser Parser)
(org.commonmark.ext.task.list.items TaskListItemsExtension TaskListItemMarker)
(org.commonmark.ext.footnotes FootnotesExtension FootnoteReference FootnoteDefinition InlineFootnote)
#_ (org.commonmark.ext.footnotes FootnotesExtension FootnoteReference FootnoteDefinition InlineFootnote)
(org.commonmark.node Node AbstractVisitor
Document
BlockQuote
Expand Down Expand Up @@ -56,6 +56,7 @@
builder
(extensions [(formulas/extension)
(TaskListItemsExtension/create)
#_
(.. (FootnotesExtension/builder)
(inlineFootnotes true)
(build))])
Expand Down Expand Up @@ -137,6 +138,7 @@
:attrs {:src (.getDestination node) :title (.getTitle node)}
:content []}) z/down z/rightmost))))

#_
(defmethod open-node FootnoteDefinition [ctx ^FootnoteDefinition node]
(-> ctx
(assoc :root :footnotes)
Expand All @@ -145,10 +147,10 @@
(z/append-child {:type :footnote
:label (.getLabel node)
:content []}) z/down z/rightmost)))))

#_
(defmethod close-node FootnoteDefinition [ctx ^FootnoteDefinition _node]
(-> ctx (update-current z/up) (assoc :root :doc)))

#_
(defmethod open-node InlineFootnote [{:as ctx :keys [label->footnote-ref]} ^InlineFootnote _node]
(let [label (str "note-" (count label->footnote-ref))
footnote-ref {:type :footnote-ref
Expand All @@ -165,7 +167,7 @@
:inline? true
:label label
:content []}) z/down z/rightmost))))))

#_
(defmethod close-node InlineFootnote [ctx ^FootnoteDefinition _node]
(-> ctx (update-current z/up) (assoc :root :doc)))

Expand Down Expand Up @@ -197,6 +199,7 @@
TaskListItemMarker (swap! !ctx update-current handle-todo-list node)
InlineFormula (swap! !ctx update-current z/append-child {:type :formula :text (.getLiteral ^InlineFormula node)})
BlockFormula (swap! !ctx update-current z/append-child {:type :block-formula :text (.getLiteral ^BlockFormula node)})
#_#_
FootnoteReference (swap! !ctx (fn [{:as ctx :keys [label->footnote-ref]}]
(let [label (.getLabel ^FootnoteReference node)
footnote-ref (or (get label->footnote-ref label)
Expand Down

0 comments on commit cdec3d4

Please sign in to comment.