Compare commits
1 Commits
4b4573ee1d
...
c3b444c36c
| Author | SHA1 | Date | |
|---|---|---|---|
| c3b444c36c |
@@ -156,7 +156,7 @@
|
|||||||
;; 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)
|
(-> (slurp file)
|
||||||
(str/replace-first #"<\?xml version='1.0' encoding='UTF-8'\?>\n?" "")
|
(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
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
"/home/msyds/org/20250512144715-natural_transformation_category_theory.org"
|
"/home/msyds/org/20250512144715-natural_transformation_category_theory.org"
|
||||||
#_
|
#_
|
||||||
"/home/msyds/org/20251021155921-path_action.org"
|
"/home/msyds/org/20251021155921-path_action.org"
|
||||||
"test/net/deertopia/doerg/render_test/fallbacks.org")
|
"test/net/deertopia/doerg/tex-test.org")
|
||||||
|
|
||||||
(defn- force-create-sym-link [path target]
|
(defn- force-create-sym-link [path target]
|
||||||
(fs/delete-if-exists path)
|
(fs/delete-if-exists path)
|
||||||
|
|||||||
@@ -2,59 +2,12 @@
|
|||||||
(:require [net.deertopia.doerg.render :as sut]
|
(:require [net.deertopia.doerg.render :as sut]
|
||||||
[net.deertopia.doerg.element :as element]
|
[net.deertopia.doerg.element :as element]
|
||||||
[net.deertopia.doerg.tex.temml :as temml]
|
[net.deertopia.doerg.tex.temml :as temml]
|
||||||
[net.deertopia.doerg.tex.native :as native]
|
|
||||||
[com.rpl.specter :as sp]
|
[com.rpl.specter :as sp]
|
||||||
[clojure.edn :as edn]
|
[clojure.test :as t]))
|
||||||
[clojure.test :as t]
|
|
||||||
[clojure.java.io :as io]
|
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
;; Stupid and hacky.
|
(t/deftest fallbacks
|
||||||
(defn mathml? [s]
|
(t/testing "expected fallback behaviour"
|
||||||
(str/starts-with? s "<math"))
|
|
||||||
|
|
||||||
;; Also stupid and hacky. }:)
|
|
||||||
(defn svg? [s]
|
|
||||||
(some? (re-matches #"(?s)(<!--.*?-->\n)<svg.*" s)))
|
|
||||||
|
|
||||||
(defn read-resource [s]
|
|
||||||
(let [p (-> (format "net/deertopia/doerg/render_test/%s" s)
|
|
||||||
io/resource slurp)]
|
|
||||||
(cond (str/ends-with? s ".edn") (edn/read-string p)
|
|
||||||
(str/ends-with? s ".org") (element/read-string p))))
|
|
||||||
|
|
||||||
(t/deftest latex-fallbacks
|
|
||||||
(t/testing "LaTeX fallback behaviour"
|
|
||||||
(let [doc (temml/binding-worker
|
(let [doc (temml/binding-worker
|
||||||
(-> "fallbacks.org" read-resource sut/render-tex-snippets))
|
(-> "net/deertopia/doerg/render_test/fallbacks.org"
|
||||||
snippets (->> doc
|
io/resource slurp element/read-string
|
||||||
(sp/select
|
sut/render-tex-snippets))])))
|
||||||
[element/postorder-walker
|
|
||||||
#(element/of-type?
|
|
||||||
% "latex-fragment" "latex-environment")
|
|
||||||
(sp/view #(-> % ::sut/rendered deref str))]))
|
|
||||||
expectations (-> "fallbacks.edn" read-resource)]
|
|
||||||
(doall (map (fn [s e]
|
|
||||||
(let [mathml (mathml? s)
|
|
||||||
svg (svg? s)]
|
|
||||||
(assert
|
|
||||||
(not= mathml svg)
|
|
||||||
"`mathml?` and `svg?` should be mutually-exclusive.")
|
|
||||||
(case e
|
|
||||||
:mathml (t/is mathml)
|
|
||||||
:svg (t/is svg))))
|
|
||||||
snippets expectations)))))
|
|
||||||
|
|
||||||
(t/deftest latex-laziness
|
|
||||||
(t/testing "LaTeX laziness"
|
|
||||||
(let [ex (Exception. "you're supposed to be lazy!")
|
|
||||||
bad (fn [& _] (throw ex))
|
|
||||||
doc (read-resource "latexless.org")
|
|
||||||
r (try (with-redefs-fn {#'native/render bad
|
|
||||||
#'temml/render bad}
|
|
||||||
#(sut/render-tex-snippets doc))
|
|
||||||
(catch Exception e
|
|
||||||
(if (= e ex)
|
|
||||||
false
|
|
||||||
(throw e))))]
|
|
||||||
(t/is r))))
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
[:mathml
|
|
||||||
:mathml
|
|
||||||
:mathml
|
|
||||||
:mathml
|
|
||||||
:svg
|
|
||||||
:mathml
|
|
||||||
:svg]
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#+title: 이 파일은 LaTeX 코드가 포함되지 않습니다.
|
|
||||||
|
|
||||||
🦌!
|
|
||||||
Reference in New Issue
Block a user