summaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorLucas V. R <lvr@s-viva.xyz>2022-02-21 09:54:37 -0300
committerAlbert Krewinkel <albert+github@zeitkraut.de>2022-02-21 16:04:14 +0100
commit3bc3e968372e567cbaf3a7a512e15b93b90d2520 (patch)
treee1be96d9616f2961a514a1b926058ec1fde8f9b9 /test/Tests
parent6fe8014a2cc1d732dd11c0fc386d7c8449048c90 (diff)
Org reader: More flexible LaTeX environments
Looking at the definition of `org-element-latex-environment-parser`, one sees that Org allows arbitrary arguments to LaTeX environments. In fact, it parses every char just after `\begin{xxx}` until `\end{xxx}` as content for the environment, so all the following examples are valid environments: ```org \begin{equation} e = mc^2 \end{equations} ``` ```org \begin{tikzcd}[ampersand replacement=\&] A \& B \\ C \& D \arrow[from=1-1, to=1-2] \arrow["f", from=2-1, to=2-2] \end{tikzcd} ```
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Readers/Org/Block.hs21
-rw-r--r--test/Tests/Readers/Org/Directive.hs2
2 files changed, 22 insertions, 1 deletions
diff --git a/test/Tests/Readers/Org/Block.hs b/test/Tests/Readers/Org/Block.hs
index 4f3038f93..fd11b9ad7 100644
--- a/test/Tests/Readers/Org/Block.hs
+++ b/test/Tests/Readers/Org/Block.hs
@@ -186,6 +186,27 @@ tests =
, "\\end{equation}"
])
+ , "One-line LaTeX fragment" =:
+ "\\begin{equation} 2 + 3 \\end{equation}" =?>
+ rawBlock "latex" "\\begin{equation} 2 + 3 \\end{equation}\n"
+
+ , "LaTeX fragment with more arguments" =:
+ T.unlines [ "\\begin{tikzcd}[ampersand replacement=\\&]"
+ , " A \\& B \\\\"
+ , " C \\& D"
+ , " \\arrow[from=1-1, to=1-2]"
+ , " \\arrow[\"f\", from=2-1, to=2-2]"
+ , "\\end{tikzcd}"
+ ] =?>
+ rawBlock "latex"
+ (T.unlines [ "\\begin{tikzcd}[ampersand replacement=\\&]"
+ , " A \\& B \\\\"
+ , " C \\& D"
+ , " \\arrow[from=1-1, to=1-2]"
+ , " \\arrow[\"f\", from=2-1, to=2-2]"
+ , "\\end{tikzcd}"
+ ])
+
, "Convert blank lines in blocks to single newlines" =:
T.unlines [ "#+begin_html"
, ""
diff --git a/test/Tests/Readers/Org/Directive.hs b/test/Tests/Readers/Org/Directive.hs
index 7839cf193..cceed8108 100644
--- a/test/Tests/Readers/Org/Directive.hs
+++ b/test/Tests/Readers/Org/Directive.hs
@@ -250,7 +250,7 @@ tests =
, "\\end{equation}"
] =?>
para (str "\\begin{equation}" <> softbreak <>
- str "f(x) = x^2" <> softbreak <>
+ text "f(x) = x^2" <> softbreak <>
str "\\end{equation}")
]
]