This commit is contained in:
2026-02-26 12:39:13 -07:00
parent d5ccadb326
commit 7d12f7d90e
6 changed files with 36 additions and 39 deletions

View File

@@ -1 +0,0 @@
classes

View File

@@ -1,2 +0,0 @@
(compile 'serialise)
(compile 'deserialise)

View File

@@ -1,7 +1,5 @@
(ns deserialise (ns deserialise
(:require [clj-cbor.core :as cbor] (:require [clj-cbor.core :as cbor]
[clojure.string :as str]) [clojure.string :as str]))
(:gen-class))
(defn -main [] (prn (cbor/decode cbor/default-codec System/in :eof))
(prn (cbor/decode cbor/default-codec System/in :eof)))

View File

@@ -1,7 +1,6 @@
(ns serialise (ns serialise
(:require [clj-cbor.core :as cbor] (:require [clj-cbor.core :as cbor]
[clojure.string :as str]) [clojure.string :as str]))
(:gen-class))
(defn w [x] (defn w [x]
(cbor/encode cbor/default-codec System/out x)) (cbor/encode cbor/default-codec System/out x))
@@ -12,13 +11,9 @@
#_ #_
(w "\\naturalto") (w "\\naturalto")
(defn -main [] (w "\\ifxetex blah \\fi")
(w "\\begin{align*}
x &= y
\\\\ &= zzz
\\end{align*}")
#_#_#_ #_#_#_
(w "c = \\sqrt{a^2 + y^2}") (w "c = \\sqrt{a^2 + y^2}")
(w "c = \\sqrt{a^ + y^2") (w "c = \\sqrt{a^ + y^2")
(w "\\alpha^\\beta")) (w "\\alpha^\\beta")

View File

@@ -2,6 +2,7 @@
\usepackage{amsmath} \usepackage{amsmath}
\usepackage[active,tightpage,auctex,dvips]{preview} \usepackage[active,tightpage,auctex,dvips]{preview}
\usepackage{fontspec} \usepackage{fontspec}
\usepackage{ifxetex}
%% \usepackage{syd-plex} %% \usepackage{syd-plex}
\begin{document} \begin{document}

View File

@@ -127,6 +127,13 @@
element/footnotes-section?] element/footnotes-section?]
sp/NONE)))) sp/NONE))))
(defn- collect-latex-headers [doc]
(->> doc
(sp/select
[element/postorder-walker
#(element/of-keyword-type? % "LATEX_HEADER")
(sp/view :value)])))
(defn- read-and-patch-generated-svg [{:keys [file height depth]}] (defn- read-and-patch-generated-svg [{:keys [file height depth]}]
;; dvisvgm writes standalone SVG files, to which we need to make a ;; dvisvgm writes standalone SVG files, to which we need to make a
;; few changes to use them inline within our HTML. ;; few changes to use them inline within our HTML.
@@ -139,15 +146,19 @@
;; the SVG tag, and set the new values for height and ;; the SVG tag, and set the new values for height and
;; vertical-align in the style attribute ;; vertical-align in the style attribute
;; • Viewbox: Must be removed entirely for correct positioning. ;; • Viewbox: Must be removed entirely for correct positioning.
(-> (slurp file) (let [r (-> (slurp file)
(str/replace-first "<?xml version='1.0' encoding='UTF-8'?>" "") (str/replace-first "<?xml version='1.0' encoding='UTF-8'?>" "")
(str/replace-first #" height=['\"][^\"']+[\"']" "") (str/replace-first #" height=['\"][^\"']+[\"']" "")
(str/replace-first #" width=['\"][^\"']+[\"']" "") (str/replace-first #" width=['\"][^\"']+[\"']" "")
(str/replace-first (str/replace-first
#"viewBox=['\"][^\"']+[\"']" #"viewBox=['\"][^\"']+[\"']"
(format "style=\"%s\"" (fn [s]
(format "height:%.4fem;vertical-align:%.4f;display:inline-block" (format "%s style=\"%s\""
height (- depth)))))) s
(format "height:%.4fem;vertical-align:%.4fem;display:inline-block"
height (- depth))))))]
(spit (fs/file "/tmp" (fs/file-name file)) r)
r))
(defn- render-tex-snippets [doc] (defn- render-tex-snippets [doc]
(let [promises (atom []) (let [promises (atom [])
@@ -181,7 +192,10 @@
(catch Exception e (catch Exception e
(prn e) (prn e)
(flush) (flush)
(throw e)))))))] (throw e))))
(when (fs/exists? "/tmp/doerg-svgs")
(fs/delete-tree "/tmp/doerg-svgs"))
(fs/copy-tree svg-dir "/tmp/doerg-svgs"))))]
(future-call (bound-fn* f)) (future-call (bound-fn* f))
r)) r))
@@ -331,19 +345,12 @@
(str "@" key)) (str "@" key))
(defmethod org-element "latex-fragment" [{:keys [contents value] :as e}] (defmethod org-element "latex-fragment" [{:keys [contents value] :as e}]
(let [display? (str/starts-with? value "\\[")]
[:span.latex-fragment [:span.latex-fragment
(-> e ::rendered (deref 2000 "«timed out»"))] (-> e ::rendered (deref 2000 "«timed out»"))])
#_
[:span.latex-fragment
(hiccup/raw (tex/render-temml contents :display? display?))]))
(defmethod org-element "latex-environment" [{:keys [value] :as e}] (defmethod org-element "latex-environment" [{:keys [value] :as e}]
[:span.latex-fragment [:span.latex-fragment
(-> e ::rendered (deref 2000 "«timed out»"))] (-> e ::rendered (deref 2000 "«timed out»"))])
#_
[:span.latex-fragment
(hiccup/raw (tex/render-temml value :display? true))])
(defmethod org-element "example-block" [{:keys [value]}] (defmethod org-element "example-block" [{:keys [value]}]
[:pre value]) [:pre value])
@@ -362,7 +369,6 @@
;; Completely ignore the LATEX_COMPILER keyword. ;; Completely ignore the LATEX_COMPILER keyword.
(defmethod org-keyword "LATEX_COMPILER" [_] nil) (defmethod org-keyword "LATEX_COMPILER" [_] nil)
;; TODO: Real LatEx support.
(defmethod org-keyword "LATEX_HEADER" [_] nil) (defmethod org-keyword "LATEX_HEADER" [_] nil)
;; Not sure how to deal with this one yet. ;; Not sure how to deal with this one yet.