From 5ad8fdf4b2ca437f8fd2fec2efdce46f9c4af553 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 18 Jul 2023 21:08:13 -0400 Subject: [PATCH] Add test cases. --- .../latex_fragment/fragment_vs_environment.org | 7 +++++++ org_mode_samples/latex_fragment/math_mode.org | 1 + org_mode_samples/latex_fragment/simple.org | 4 ++++ src/parser/latex_fragment.rs | 2 ++ 4 files changed, 14 insertions(+) create mode 100644 org_mode_samples/latex_fragment/fragment_vs_environment.org create mode 100644 org_mode_samples/latex_fragment/math_mode.org create mode 100644 org_mode_samples/latex_fragment/simple.org diff --git a/org_mode_samples/latex_fragment/fragment_vs_environment.org b/org_mode_samples/latex_fragment/fragment_vs_environment.org new file mode 100644 index 0000000..005027f --- /dev/null +++ b/org_mode_samples/latex_fragment/fragment_vs_environment.org @@ -0,0 +1,7 @@ +\begin{itemize} +\item foo \sqrt{x} +\end{itemize} + +\begin{itemize} +\item bar \sqrt{y} +\end{itemize} % Need text on this line to prevent it from becoming a LaTeX environment org-mode element diff --git a/org_mode_samples/latex_fragment/math_mode.org b/org_mode_samples/latex_fragment/math_mode.org new file mode 100644 index 0000000..e1519f6 --- /dev/null +++ b/org_mode_samples/latex_fragment/math_mode.org @@ -0,0 +1 @@ +tex can have math between dollar signs like $x^2=y$ and $$ x=+\sqrt{y} $$ but also braces and brackets like \( x=2 \) and \[ x=-\sqrt{2} \] diff --git a/org_mode_samples/latex_fragment/simple.org b/org_mode_samples/latex_fragment/simple.org new file mode 100644 index 0000000..6acb8ff --- /dev/null +++ b/org_mode_samples/latex_fragment/simple.org @@ -0,0 +1,4 @@ +\begin{itemize} +% this would be a LaTeX comment if this was a LaTeX document +\item Heres some math \sqrt{y} +\end{itemize} % Need text on this line to prevent it from becoming a LaTeX environment org-mode element diff --git a/src/parser/latex_fragment.rs b/src/parser/latex_fragment.rs index 46ac117..8b3113f 100644 --- a/src/parser/latex_fragment.rs +++ b/src/parser/latex_fragment.rs @@ -12,6 +12,7 @@ use crate::error::Res; use crate::parser::object::Entity; use crate::parser::parser_with_context::parser_with_context; use crate::parser::util::get_consumed; +use crate::parser::util::not_yet_implemented; use crate::parser::LatexFragment; #[tracing::instrument(ret, level = "debug")] @@ -19,6 +20,7 @@ pub fn latex_fragment<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, LatexFragment<'s>> { + not_yet_implemented()?; let (remaining, _) = tag("\\")(input)?; todo!() // let (remaining, entity_name) = name(context, remaining)?;