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

View File

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

View File

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