Fixes #9
This commit is contained in:
@@ -39,5 +39,6 @@ texlive.combine {
|
|||||||
collection-fontsrecommended # Essential fonts.
|
collection-fontsrecommended # Essential fonts.
|
||||||
etoolbox # For Org-mode exports.
|
etoolbox # For Org-mode exports.
|
||||||
caption
|
caption
|
||||||
|
standalone
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,56 @@
|
|||||||
\documentclass{article}
|
\documentclass[tikz,dvisvgm]{standalone}
|
||||||
\usepackage{amsmath}
|
|
||||||
\usepackage[active,tightpage,auctex,dvips]{preview}
|
\usepackage[active,tightpage,auctex,dvips]{preview}
|
||||||
\usepackage{fontspec}
|
\usepackage{amsmath}
|
||||||
|
\usepackage{amssymb}
|
||||||
\usepackage{ifxetex}
|
\usepackage{ifxetex}
|
||||||
\usepackage{syd-plex}
|
\usepackage{syd-plex}
|
||||||
\usepackage{quiver}
|
\usepackage{quiver}
|
||||||
\usepackage{tikz-cd}
|
\usepackage{tikz}
|
||||||
|
\usepackage{amscd}
|
||||||
|
|
||||||
|
\newcommand{\catname}[1]{\textbf{#1}}
|
||||||
|
\newcommand{\C}[1]{\catname{#1}}
|
||||||
|
|
||||||
|
% Specific categories
|
||||||
|
\newcommand{\Set}{\catname{Set}}
|
||||||
|
\newcommand{\Cat}{\catname{Cat}}
|
||||||
|
\newcommand{\CAT}{\catname{CAT}}
|
||||||
|
\newcommand{\Grp}{\catname{Grp}}
|
||||||
|
|
||||||
|
% Common objects and functions
|
||||||
|
\newcommand{\Ob}{\operatorname{Ob}}
|
||||||
|
\newcommand{\op}{\text{op}}
|
||||||
|
\newcommand{\opof}[1]{{#1}^{\text{op}}}
|
||||||
|
% \id{x} is the identity morphism on x.
|
||||||
|
\newcommand{\id}[1]{1_{#1}}
|
||||||
|
% \Id{C} is the identity functor on C.
|
||||||
|
\newcommand{\Id}[1]{1_{#1}}
|
||||||
|
\newcommand{\Mor}{\operatorname{Mor}}
|
||||||
|
\newcommand{\homset}[3]{{{#1} \left[ {#2} \to {#3} \right]}}
|
||||||
|
|
||||||
|
% Constructions of categories.
|
||||||
|
\newcommand{\FunctorCategory}[2]{\left[#1, #2\right]}
|
||||||
|
\newcommand{\Funct}[2]{\FunctorCategory{#1}{#2}} % Deprecated.
|
||||||
|
\newcommand{\ArrowCategory}[1]{{#1}^\to}
|
||||||
|
|
||||||
|
% Semantic aliases
|
||||||
|
\newcommand{\monicto}{\rightarrowtail}
|
||||||
|
\newcommand{\epicto}{\twoheadrightarrow}
|
||||||
|
\newcommand{\naturalto}{\Rightarrow}
|
||||||
|
\newcommand{\isoto}{\cong}
|
||||||
|
\newcommand{\equivto}{\simeq}
|
||||||
|
|
||||||
|
\newcommand{\naturaltrans}[2]{#1 \naturalto #2} % Deprecated.
|
||||||
|
\newcommand{\horizontalcompose}{\ast}
|
||||||
|
|
||||||
|
% Optics
|
||||||
|
\newcommand{\opticname}[1]{\textbf{#1}}
|
||||||
|
\newcommand{\optic}[3]{\opticname{#1}^\prime\;#2\;#3}
|
||||||
|
\newcommand{\Optic}[5]{\opticname{#1}\;#2\;#3\;#4\;#5}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\setlength\abovedisplayskip{0pt}
|
\setlength\abovedisplayskip{0pt} % Remove padding before equation environments.
|
||||||
|
%% \color[rgb]{0.000,0.000,0.004}\special{dvisvgm:currentcolor on}\setcounter{equation}{0}%
|
||||||
|
|
||||||
% {{contents}}
|
% {{contents}}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
fut-res (deref fut ms ::timed-out)]
|
fut-res (deref fut ms ::timed-out)]
|
||||||
(if (= fut-res ::timed-out)
|
(if (= fut-res ::timed-out)
|
||||||
(do (l/warnf "Giving up on rendering TeX snippets after %.3f seconds."
|
(do (l/warnf "Giving up on rendering TeX snippets after %.3f seconds."
|
||||||
(* ms 1000))
|
(/ ms 1000))
|
||||||
(future-cancel fut)
|
(future-cancel fut)
|
||||||
(doseq [[_snippet p] snippet-promises]
|
(doseq [[_snippet p] snippet-promises]
|
||||||
(deliver p ::timed-out)))
|
(deliver p ::timed-out)))
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
[babashka.fs :as fs]
|
[babashka.fs :as fs]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[hiccup2.core :as hiccup]
|
[hiccup2.core :as hiccup]
|
||||||
[clojure.tools.logging :as l]))
|
[clojure.tools.logging :as l]
|
||||||
|
[clojure.tools.logging.readable :as lr]))
|
||||||
|
|
||||||
(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
|
||||||
@@ -28,26 +29,38 @@
|
|||||||
(format "%s style=\"%s\""
|
(format "%s style=\"%s\""
|
||||||
s
|
s
|
||||||
(format "height:%.4fem;vertical-align:%.4fem;display:inline-block"
|
(format "height:%.4fem;vertical-align:%.4fem;display:inline-block"
|
||||||
height (- depth)))))))
|
height (- depth)))))
|
||||||
|
;; Stupid hack. --currentcolor on dvisvgm should be enough, but
|
||||||
|
;; it doesn't get e.g. TikZ arrows.
|
||||||
|
(str/replace #"stroke=['\"]#000['\"]" "stroke=\"currentColor\"")))
|
||||||
|
|
||||||
|
(def ^:dynamic *save-snippets?* false)
|
||||||
|
|
||||||
(defn render-snippets [snippet-promises]
|
(defn render-snippets [snippet-promises]
|
||||||
(fs/with-temp-dir [svg-dir {:prefix "doerg-svg-"}]
|
(with-redefs [fs/delete-tree
|
||||||
(let [rendered-snippets
|
(fn
|
||||||
(delay (->> snippet-promises
|
([path]
|
||||||
(map first)
|
(l/warnf "refusing to delete %s" path))
|
||||||
(apply native/render svg-dir)))]
|
([path opts]
|
||||||
(doseq [[snippet p] snippet-promises]
|
(lr/warnf "refusing to delete %s with opts %s"
|
||||||
(try (let [temml (temml/render snippet)]
|
path opts)))]
|
||||||
(->> (if (temml/erroneous-output? temml)
|
(fs/with-temp-dir [svg-dir {:prefix "doerg-svg-"}]
|
||||||
(let [tex (get @rendered-snippets snippet)]
|
(let [rendered-snippets
|
||||||
(if (:errors tex)
|
(delay (->> snippet-promises
|
||||||
temml
|
(map first)
|
||||||
(read-and-patch-generated-svg tex)))
|
(apply native/render svg-dir)))]
|
||||||
temml)
|
(doseq [[snippet p] snippet-promises]
|
||||||
hiccup/raw (deliver p)))
|
(try (let [temml (temml/render snippet)]
|
||||||
(catch Exception e
|
(->> (if (temml/erroneous-output? temml)
|
||||||
(l/error e "Error in TeX thread")
|
(let [tex (get @rendered-snippets snippet)]
|
||||||
(throw e)))))))
|
(if (:errors tex)
|
||||||
|
temml
|
||||||
|
(read-and-patch-generated-svg tex)))
|
||||||
|
temml)
|
||||||
|
hiccup/raw (deliver p)))
|
||||||
|
(catch Exception e
|
||||||
|
(l/error e "Error in TeX thread")
|
||||||
|
(throw e))))))))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(let [snippets (for [x ["\\(\\ifxetex blah \\fi\\)"
|
(let [snippets (for [x ["\\(\\ifxetex blah \\fi\\)"
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
(invoke
|
(invoke
|
||||||
{:dir output-dir}
|
{:dir output-dir}
|
||||||
dvisvgm "--page=1-" "--optimize" "--clipjoin"
|
dvisvgm "--page=1-" "--optimize" "--clipjoin"
|
||||||
"--relative" "--no-fonts" "-v3"
|
"--relative" "--no-fonts" "-v3" "--currentcolor"
|
||||||
"--message=processing page {?pageno}: output written to {?svgpath}"
|
"--message=processing page {?pageno}: output written to {?svgpath}"
|
||||||
"--bbox=preview" "-o" "%9p.svg" file)))
|
"--bbox=preview" "-o" "%9p.svg" file)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user