From 777968cac547fa624f24ca7d2ca2a09e80f7d134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Tue, 10 Mar 2026 14:37:34 -0600 Subject: [PATCH] --- .../test/net/deertopia/doerg/element_test.clj | 22 ++++++++++++------- .../paragraph-with-multiple-latex.org | 10 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 doerg/test/net/deertopia/doerg/element_test/paragraph-with-multiple-latex.org diff --git a/doerg/test/net/deertopia/doerg/element_test.clj b/doerg/test/net/deertopia/doerg/element_test.clj index a4f732b..2c1a97b 100644 --- a/doerg/test/net/deertopia/doerg/element_test.clj +++ b/doerg/test/net/deertopia/doerg/element_test.clj @@ -50,25 +50,31 @@ (t/is (not (-> (parse-resource "first-paragraph-under-heading.org") first-paragraph-belongs-to-first-section?))))) -(defn- first-paragraph-ends-with-latex? [doc] - (-> (sp/select-first [sut/postorder-walker - #(sut/of-type? % "paragraph") +(defn walk-types [type & types] + [sut/postorder-walker #(apply sut/of-type? % type types)]) + +(defn- paragraph-ends-with-latex? [doc] + (-> (sp/select-first [(walk-types "paragraph") (sp/must :children) sp/LAST] doc) (sut/of-type? "latex-environment"))) -(defn- first-paragraph-has-latex? [doc] - (sp/select-first [sut/postorder-walker - #(sut/of-type? % "paragraph") +(defn- paragraph-has-latex? [doc] + (sp/select-first [(walk-types "paragraph") (sp/must :children) + sp/ALL #(sut/of-type? % "latex-environment")] doc)) +(defn- paragraph-has-multiple-latex? [doc] + (sp/select-first [(walk-types "paragraph") (sp/must :children)] + doc)) + (t/deftest paragraph-separation (t/testing "paragraph ending with latex" (t/is (->> (parse-resource "paragraph-ending-with-latex.org") - first-paragraph-ends-with-latex?))) + paragraph-ends-with-latex?))) (t/testing "paragraph surrounding latex" (t/is (->> (parse-resource "paragraph-surrounding-latex.org") - first-paragraph-has-latex?)))) + paragraph-has-latex?)))) diff --git a/doerg/test/net/deertopia/doerg/element_test/paragraph-with-multiple-latex.org b/doerg/test/net/deertopia/doerg/element_test/paragraph-with-multiple-latex.org new file mode 100644 index 0000000..025cdda --- /dev/null +++ b/doerg/test/net/deertopia/doerg/element_test/paragraph-with-multiple-latex.org @@ -0,0 +1,10 @@ +#+title: paragraph with multiple latex environments + +first part of paragraph +\begin{equation*} +\text{first \LaTeX\ environment} +\end{equation*} +second part of paragraph +\begin{equation*} +\text{second \LaTeX\ environment} +\end{equation*}