Skip to content

Commit

Permalink
render :TeX metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuebert committed Aug 4, 2023
1 parent 385b2f4 commit 2fa8539
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions editor2/src/main/maria/editor/code/show_values.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
[yawn.hooks :as h]
[yawn.view :as v]
[cells.core :as cells]
[reagent.core :as reagent]))
[reagent.core :as reagent]
[shadow.lazy :as lazy]))


(def COLL-PADDING 4)

Expand Down Expand Up @@ -130,11 +132,11 @@
(icons/ellipsis:mini "w-4 h-4 cursor-pointer ")])

(defn punctuate ^v/el [s]
(v/x [:div.inline-block.font-bold.opacity-60 s]))
(v/x [:div.inline-block s]))

(defview show-brackets [left right more children !wrapper !parent interpose-comma?]
(let [bracket-classes "flex flex-none"]
[:div.inline-flex.max-w-full.whitespace-nowrap.text-brackets {:ref !wrapper}
(let [bracket-classes "flex flex-none text-brackets"]
[:div.inline-flex.max-w-full.whitespace-nowrap {:ref !wrapper}
[:div.items-start {:class bracket-classes} (punctuate left)]

(-> [:div.inline-flex.flex-wrap.items-end.gap-list.overflow-hidden
Expand Down Expand Up @@ -232,6 +234,13 @@
loader
(show opts v)))))

(let [show-katex-loadable (lazy/loadable maria.editor.extensions.katex/show-katex)]
(defn show-katex [opts x]
(if (lazy/ready? show-katex-loadable)
(@show-katex-loadable :div x)
(show opts (p/do (lazy/load show-katex-loadable)
(@show-katex-loadable :div x))))))

(defview show-var [opts x]
(v/x [:<>
(when (fn? @x) [:div.text-gray-500.mb-1 (str x)])
Expand Down Expand Up @@ -335,6 +344,12 @@
(fn [opts x] (when (:hiccup (meta x))
(v/x x))))

(handles-keys #{:TeX}
;; THIS IS TEMPORARY FOR TESTING
(fn [opts x]
(when-let [s (:TeX (meta x))]
(show-katex opts s))))

(handles-keys #{:number
:symbol
:var
Expand Down

0 comments on commit 2fa8539

Please sign in to comment.