From 9e6e9a72218e8c408e151bf8b169f44a8c55eb40 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Thu, 25 Jun 2020 20:04:09 +0200 Subject: Org reader: honor tex export option The `tex` export option can be set with `#+OPTION: tex:nil` and allows three settings: - `t` causes LaTeX fragments to be parsed as TeX or added as raw TeX, - `nil` removes all LaTeX fragments from the document, and - `verbatim` treats LaTeX as text. The default is `t`. Closes: #4070 --- test/Tests/Readers/Org/Directive.hs | 73 +++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'test/Tests/Readers/Org/Directive.hs') diff --git a/test/Tests/Readers/Org/Directive.hs b/test/Tests/Readers/Org/Directive.hs index 79e09ea1c..9e571473b 100644 --- a/test/Tests/Readers/Org/Directive.hs +++ b/test/Tests/Readers/Org/Directive.hs @@ -162,6 +162,79 @@ tests = ] =?> headerWith ("headline", [], mempty) 1 "Headline" + , testGroup "LaTeX" + [ testGroup "Include LaTeX fragments" + [ "Inline command" =: + T.unlines [ "#+OPTIONS: tex:t" + , "Hello \\emph{Name}" + ] =?> + para ("Hello" <> space <> emph "Name") + + , "Alpha" =: + T.unlines [ "#+OPTIONS: tex:t" + , "\\alpha" + ] =?> + para "α" + + , "equation environment" =: + T.unlines [ "#+OPTIONS: tex:t" + , "\\begin{equation}" + , "f(x) = x^2" + , "\\end{equation}" + ] =?> + rawBlock "latex" (T.unlines [ "\\begin{equation}" + , "f(x) = x^2" + , "\\end{equation}" + ]) + ] + + , testGroup "Ignore LaTeX fragments" + [ "Inline command" =: + T.unlines [ "#+OPTIONS: tex:nil" + , "Hello \\emph{Emphasised}" + ] =?> + para "Hello" + + , "MathML symbol (alpha)" =: + T.unlines [ "#+OPTIONS: tex:nil" + , "\\alpha" + ] =?> + para "α" + + , "equation environment" =: + T.unlines [ "#+OPTIONS: tex:nil" + , "\\begin{equation}" + , "f(x) = x^2" + , "\\end{equation}" + ] =?> + (mempty :: Blocks) + ] + + , testGroup "Verbatim LaTeX" + [ "Inline command" =: + T.unlines [ "#+OPTIONS: tex:verbatim" + , "Hello \\emph{Emphasised}" + ] =?> + para "Hello \\emph{Emphasised}" + + , "MathML symbol (alpha)" =: + T.unlines [ "#+OPTIONS: tex:verbatim" + , "\\alpha" + ] =?> + para "α" + + , "equation environment" =: + T.unlines [ "#+OPTIONS: tex:verbatim" + , "\\begin{equation}" + , "f(x) = x^2" + , "\\end{equation}" + ] =?> + para (str "\\begin{equation}" <> softbreak <> + str "f(x) = x^2" <> softbreak <> + str "\\end{equation}") + ] + ] + , testGroup "planning information" [ "include planning info after headlines" =: T.unlines [ "#+OPTIONS: p:t" -- cgit v1.2.3