From 362d2a508846c26c8cfa5ce95785c143214badce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Tue, 17 Mar 2026 21:24:36 -0600 Subject: [PATCH] wip: fix: latex paragraphs again lol --- doerg/src/net/deertopia/doerg/element.clj | 8 +++---- .../test/net/deertopia/doerg/element_test.clj | 24 ++++++++++++++++++- .../paragraph-surrounding-separate-latex.org | 9 +++++++ .../paragraph-with-separate-latex.org | 7 ++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 doerg/test/net/deertopia/doerg/element_test/paragraph-surrounding-separate-latex.org create mode 100644 doerg/test/net/deertopia/doerg/element_test/paragraph-with-separate-latex.org diff --git a/doerg/src/net/deertopia/doerg/element.clj b/doerg/src/net/deertopia/doerg/element.clj index 7a03077..3c34373 100644 --- a/doerg/src/net/deertopia/doerg/element.clj +++ b/doerg/src/net/deertopia/doerg/element.clj @@ -239,13 +239,13 @@ rest)] (assoc node :children new-children))) -(defn separated-by-explicit-paragraph-break? - "Returh truthy if each successive pair of elements is separated by - at least one explicit paragraph break; i.e. a blank line." +(defn consequtive-elements? + "Returh truthy if each successive pair of elements is NOT separated + by at least one explicit paragraph break; i.e. a blank line." [& elements] (match elements [e₁ e₂ & es] - (and (< (-> e₁ :position :end :line) + (and (= (-> e₁ :position :end :line) (-> e₂ :position :start :line)) (recur es)) :else true)) diff --git a/doerg/test/net/deertopia/doerg/element_test.clj b/doerg/test/net/deertopia/doerg/element_test.clj index a275b9a..7abaedc 100644 --- a/doerg/test/net/deertopia/doerg/element_test.clj +++ b/doerg/test/net/deertopia/doerg/element_test.clj @@ -79,6 +79,22 @@ (t/is (= ts (sp/select [(sp/must :children) sp/ALL (sp/view sut/type)] p))))))) +(defn- paragraph-has-separate-latex? [doc] + (let [cs (sp/select [(walk-types "section") + (sp/must :children) + sp/ALL + (sp/view sut/type)] + doc)] + (t/is (= cs ["paragraph" "latex-environment"])))) + +(defn- paragraph-surrounding-separate-latex? [doc] + (let [cs (sp/select [(walk-types "section") + (sp/must :children) + sp/ALL + (sp/view sut/type)] + doc)] + (t/is (= cs ["paragraph" "latex-environment" "paragraph"])))) + (t/deftest paragraph-separation (t/testing "paragraph ending with latex" (-> (parse-resource "paragraph-ending-with-latex.org") @@ -88,4 +104,10 @@ paragraph-has-latex?)) (t/testing "paragraph with interleaved latex" (-> (parse-resource "paragraph-with-multiple-latex.org") - paragraph-has-multiple-latex?))) + paragraph-has-multiple-latex?)) + (t/testing "paragraph with separate latex" + (-> (parse-resource "paragraph-with-separate-latex.org") + paragraph-has-separate-latex?)) + (t/testing "paragraphs surrounding separate latex" + (-> (parse-resource "paragraph-surrounding-separate-latex.org") + paragraph-surrounding-separate-latex?))) diff --git a/doerg/test/net/deertopia/doerg/element_test/paragraph-surrounding-separate-latex.org b/doerg/test/net/deertopia/doerg/element_test/paragraph-surrounding-separate-latex.org new file mode 100644 index 0000000..024e968 --- /dev/null +++ b/doerg/test/net/deertopia/doerg/element_test/paragraph-surrounding-separate-latex.org @@ -0,0 +1,9 @@ +#+title: paragraphs surrounding separate latex + +a paragraph! + +\begin{gather*} +\text{and now, an unrelated latex fragment} +\end{gather*} + +more unrelated text diff --git a/doerg/test/net/deertopia/doerg/element_test/paragraph-with-separate-latex.org b/doerg/test/net/deertopia/doerg/element_test/paragraph-with-separate-latex.org new file mode 100644 index 0000000..08c3fda --- /dev/null +++ b/doerg/test/net/deertopia/doerg/element_test/paragraph-with-separate-latex.org @@ -0,0 +1,7 @@ +#+title: paragraph with separate latex + +a paragraph! + +\begin{gather*} +\text{and now, an unrelated latex fragment} +\end{gather*}