This commit is contained in:
2026-03-12 11:00:42 -06:00
parent 2c755422a7
commit f326fad9f4
2 changed files with 115 additions and 38 deletions
+23 -20
View File
@@ -57,28 +57,31 @@
())
(defn- paragraph-ends-with-latex? [doc]
(-> (sp/select-first [(walk-types "paragraph")
(sp/must :children)
sp/LAST]
doc)
(sut/of-type? "latex-environment")))
(let [type (-> (sp/select-first [(walk-types "paragraph")
(sp/must :children)
sp/LAST]
doc)
sut/type)]
(t/is type "latex-environment")))
(defn- paragraph-has-latex? [doc]
(sp/select-first [(walk-types "paragraph")
(sp/must :children)
sp/ALL
#(sut/of-type? % "latex-environment")]
doc))
(t/is (sp/select-first [(walk-types "paragraph")
(sp/must :children)
sp/ALL
#(sut/of-type? % "latex-environment")]
doc)))
(defn- paragraph-has-multiple-latex? [doc]
(let [[interleaved fenceposted]
(sp/select [(walk-types "section")
(sp/must :children)
#(some-> % first (sut/of-type? "headline"))
(sp/subselect (sp/view #(drop 1 %))
sp/ALL (sp/must :children) sp/ALL
(sp/must :type))]
doc)]))
(let [paragraphs (sp/select (walk-types "paragraph") doc)]
(t/is (= 2 (count paragraphs)))
(let [[p p] paragraphs]
(t/are [p ts] (= ts
(sp/select [(sp/must :children)
sp/ALL (sp/view sut/type)] p))
p ["text" "latex-environment"
"text" "latex-environment"]
p ["text" "latex-environment"
"text" "latex-environment" "text"]))))
(t/deftest paragraph-separation
(t/testing "paragraph ending with latex"
@@ -88,5 +91,5 @@
(-> (parse-resource "paragraph-surrounding-latex.org")
paragraph-has-latex?))
(t/testing "paragraph with interleaved latex"
(let [(parse-resource "paragraph-with-multiple-latex.org")])
(t/is (-))))
(-> (parse-resource "paragraph-with-multiple-latex.org")
paragraph-has-multiple-latex?)))