wip: xelatex

This commit is contained in:
2026-02-22 19:01:12 -07:00
parent 651ed4f26c
commit b5a5721eed
4 changed files with 48 additions and 2 deletions

View File

@@ -34,7 +34,7 @@ function do_command (cmd) {
return null
}
} catch (e) {
return e
return {type: "error", error: e}
}
}

View File

@@ -141,6 +141,7 @@
\newcommand{\definedto}{}
\newcommand{\equivto}{\simeq}
\newcommand{\homotopicto}{\sim}
\newcommand{\homotopyto}{\sim}
\newcommand{\naturalto}{\Rightarrow}
\newcommand{\isoto}{\cong}
\newcommand{\monicto}{\rightarrowtail}

View File

@@ -1,6 +1,7 @@
(ns net.deertopia.doerg.common
(:require [babashka.process :as p]
[clojure.string :as str]))
[clojure.string :as str]
[clojure.tools.logging :as l]))
(defn deref-with-timeout [process ms]
(let [p (promise)
@@ -16,3 +17,16 @@
{:process process
:timed-out-after-milliseconds ms}))
@p)))
(defn invoke [opts & cmd]
(l/info (str/join " " (cons "$" cmd)))
(let [r (apply p/shell
(merge {:continue true
:in nil :out :string :err :string}
opts)
cmd)
bin (first cmd)]
(l/infof "%s (stdout): %s" bin (:out r))
(l/infof "%s (stderr): %s" bin (:err r))
(l/infof "%s exited with status %s" bin (str (:exit r)))
r))

View File

@@ -3,6 +3,37 @@
[net.deertopia.doerg.common :as common]
[clj-cbor.core :as cbor]
[clojure.java.io :as io]))
;;; XeLaTeX
(def scale-divisor 66873.46948423679)
(def font-size 10)
(defn- invoke-xelatex [& {:keys [file output-dir]}]
(let [{:keys [out]} (common/invoke
{:dir output-dir}
"xelatex" "-no-pdf" "-interaction" "nonstopmode"
"-output-directory" output-dir file)
[tp1 tp2 tp3 tp4] (->> (re-find tightpage-regexp out)
(drop 1)
(map parse-long))]
(->> (re-find-all preview-end-regexp out)
(map #(let [[d1 d2 d3] (map parse-long (drop 1 %))
depth (/ (- d2 tp2)
scale-divisor
font-size)]
{:depth depth
:height (+ depth
(/ (+ d1 tp4)
tex-scale-divisor
tex-fontsize))
:width (/ (+ d3 tp3 (- tp2))
tex-scale-divisor
tex-fontsize)})))))
;;; Temml
(def ^:dynamic *tex-worker-timeout-duration*
"Number of milliseconds to wait before killing the external Uniorg