From c4785a21dc5cfecdecf68042c394360208b2c4cf Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 24 Sep 2024 12:18:01 +0200 Subject: [PATCH] middle ground --- src/nextjournal/markdown/impl/types.clj | 15 +++++---------- .../markdown/impl/types/CustomNode.java | 12 ++++++++++++ 2 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 src/nextjournal/markdown/impl/types/CustomNode.java diff --git a/src/nextjournal/markdown/impl/types.clj b/src/nextjournal/markdown/impl/types.clj index 30fb846..df3ab70 100644 --- a/src/nextjournal/markdown/impl/types.clj +++ b/src/nextjournal/markdown/impl/types.clj @@ -1,19 +1,14 @@ -(ns nextjournal.markdown.impl.types) +(ns nextjournal.markdown.impl.types + (:import [nextjournal.markdown.impl.types CustomNode])) ;; See also ;; https://github.com/noties/Markwon/blob/master/markwon-ext-latex/src/main/java/io/noties/markwon/ext/latex/JLatexMathBlockParser.java (set! *warn-on-reflection* true) -(defonce _ - (definterface CustomNode - (getLiteral []) - (setLiteral [v]) - (nodeType []))) - (defn ->InlineFormula [lit] (let [state (atom lit)] - (proxy [org.commonmark.node.CustomNode nextjournal.markdown.impl.types.CustomNode] [] + (proxy [org.commonmark.node.CustomNode CustomNode] [] (getLiteral [] @state) (nodeType [] :inline-formula)))) @@ -21,14 +16,14 @@ ([] (->BlockFormula nil)) ([lit] (let [state (atom lit)] - (proxy [org.commonmark.node.CustomBlock nextjournal.markdown.impl.types.CustomNode] [] + (proxy [org.commonmark.node.CustomBlock CustomNode] [] (getLiteral [] @state) (setLiteral [v] (do (reset! state v) this)) (nodeType [] :block-formula))))) (defn ->ToC [] - (proxy [org.commonmark.node.CustomBlock nextjournal.markdown.impl.types.CustomNode] [] + (proxy [org.commonmark.node.CustomBlock CustomNode] [] (nodeType [] :toc))) (defn setLiteral [^CustomNode n lit] diff --git a/src/nextjournal/markdown/impl/types/CustomNode.java b/src/nextjournal/markdown/impl/types/CustomNode.java new file mode 100644 index 0000000..b9f9a38 --- /dev/null +++ b/src/nextjournal/markdown/impl/types/CustomNode.java @@ -0,0 +1,12 @@ +package nextjournal.markdown.impl.types; + +// rebuild with: +// javac src/nextjournal/markdown/impl/types/CustomNode.java + +public interface CustomNode { + + public Object setLiteral(Object v); + public Object getLiteral(); + public Object nodeType(); + +}