This commit is contained in:
@@ -143,6 +143,16 @@
|
|||||||
#(element/of-keyword-type? % "LATEX_HEADER")
|
#(element/of-keyword-type? % "LATEX_HEADER")
|
||||||
(sp/view :value)])))
|
(sp/view :value)])))
|
||||||
|
|
||||||
|
(defn timeout-snippet-promises [snippet-promises fut]
|
||||||
|
;; Time out after eight seconds. With all the LaTeX and IPC, there
|
||||||
|
;; are so many opportunities for things to go wrong </3.
|
||||||
|
(let [fut-res (deref fut (* 10 1000) ::timed-out)]
|
||||||
|
(if (= fut-res ::timed-out)
|
||||||
|
(do (future-cancel fut)
|
||||||
|
(doseq [[_snippet p] snippet-promises]
|
||||||
|
(deliver p ::timed-out)))
|
||||||
|
fut-res)))
|
||||||
|
|
||||||
(defn render-tex-snippets
|
(defn render-tex-snippets
|
||||||
"Traverse doc, adorning each LaTeX node with a promise resolving to,
|
"Traverse doc, adorning each LaTeX node with a promise resolving to,
|
||||||
optimistically, Hiccup-rendered SVG or MathML code."
|
optimistically, Hiccup-rendered SVG or MathML code."
|
||||||
@@ -156,16 +166,10 @@
|
|||||||
(let [p (promise)]
|
(let [p (promise)]
|
||||||
(swap! snippet-promises #(conj % [(:value node) p]))
|
(swap! snippet-promises #(conj % [(:value node) p]))
|
||||||
(assoc node ::rendered p)))))
|
(assoc node ::rendered p)))))
|
||||||
fut (-> #(tex/render-snippets @snippet-promises)
|
sp @snippet-promises
|
||||||
|
fut (-> #(tex/render-snippets sp)
|
||||||
bound-fn* future-call)]
|
bound-fn* future-call)]
|
||||||
;; Time out after eight seconds. With all the LaTeX and IPC, there
|
(timeout-snippet-promises sp fut)
|
||||||
;; are so many opportunities for things to go wrong </3.
|
|
||||||
(let [fut-res (deref fut (* 10 1000) ::timed-out)]
|
|
||||||
(if (= fut-res ::timed-out)
|
|
||||||
(do (future-cancel fut)
|
|
||||||
(doseq [[_snippet p] @snippet-promises]
|
|
||||||
(deliver p ::timed-out)))
|
|
||||||
fut-res))
|
|
||||||
r))
|
r))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|||||||
Reference in New Issue
Block a user