wip: fix: latex paragraphs again lol
Some checks failed
build / build (push) Failing after 20s

This commit is contained in:
2026-03-17 21:24:36 -06:00
parent 1629efb378
commit 362d2a5088
4 changed files with 43 additions and 5 deletions

View File

@@ -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))

View File

@@ -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?)))

View File

@@ -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

View File

@@ -0,0 +1,7 @@
#+title: paragraph with separate latex
a paragraph!
\begin{gather*}
\text{and now, an unrelated latex fragment}
\end{gather*}