summaryrefslogtreecommitdiff
path: root/tests/Tests/Readers
diff options
context:
space:
mode:
authorAlbert Krewinkel <tarleb@moltkeplatz.de>2014-04-11 11:05:42 +0200
committerAlbert Krewinkel <tarleb@moltkeplatz.de>2014-04-11 11:05:42 +0200
commit6f19be7d40f583ee4e10fa2b0f20bd4f1fa80c43 (patch)
tree04363183f1d9f3e91d65465c52ea4a9f9532bfff /tests/Tests/Readers
parentca40acea5b022d6309a36000d54844a482c14555 (diff)
Org reader: Fix parsing of sub-/superscript expressions
This fixes the org-reader's handling of sub- and superscript expressions. Simple expressions (like `2^+10`), expressions in parentheses (`a_(n+1)`) and nested sexp (like `a_(nested()parens)`) are now read correctly.
Diffstat (limited to 'tests/Tests/Readers')
-rw-r--r--tests/Tests/Readers/Org.hs39
1 files changed, 30 insertions, 9 deletions
diff --git a/tests/Tests/Readers/Org.hs b/tests/Tests/Readers/Org.hs
index 9e9482e45..49130f0ab 100644
--- a/tests/Tests/Readers/Org.hs
+++ b/tests/Tests/Readers/Org.hs
@@ -78,15 +78,15 @@ tests =
"A * symbol" =?>
para (str "A" <> space <> str "*" <> space <> "symbol")
- , "Superscript single char" =:
- "2^n" =?>
- para (str "2" <> superscript "n")
+ , "Superscript simple expression" =:
+ "2^-λ" =?>
+ para (str "2" <> superscript "-λ")
, "Superscript multi char" =:
"2^{n-1}" =?>
para (str "2" <> superscript "n-1")
- , "Subscript single char" =:
+ , "Subscript simple expression" =:
"a_n" =?>
para (str "a" <> subscript "n")
@@ -105,11 +105,8 @@ tests =
])
, "No empty markup" =:
- -- FIXME: __ is erroneously parsed as subscript "_"
- -- "// ** __ ++ == ~~ $$" =?>
- -- para (spcSep [ "//", "**", "__", "++", "==", "~~", "$$" ])
- "// ** ++ == ~~ $$" =?>
- para (spcSep [ "//", "**", "++", "==", "~~", "$$" ])
+ "// ** __ ++ == ~~ $$" =?>
+ para (spcSep [ "//", "**", "__", "++", "==", "~~", "$$" ])
, "Adherence to Org's rules for markup borders" =:
"/t/& a/ / ./r/ (*l*) /e/! /b/." =?>
@@ -143,6 +140,30 @@ tests =
]))
, "emph/" ])
+ , "Sub- and superscript expressions" =:
+ unlines [ "a_(a(b)(c)d)"
+ , "e^(f(g)h)"
+ , "i_(jk)l)"
+ , "m^()n"
+ , "o_{p{q{}r}}"
+ , "s^{t{u}v}"
+ , "w_{xy}z}"
+ , "1^{}2"
+ , "3_{{}}"
+ , "4^(a(*b(c*)d))"
+ ] =?>
+ para (spcSep [ "a" <> subscript "(a(b)(c)d)"
+ , "e" <> superscript "(f(g)h)"
+ , "i" <> (subscript "(jk)") <> "l)"
+ , "m" <> (superscript "()") <> "n"
+ , "o" <> subscript "p{q{}r}"
+ , "s" <> superscript "t{u}v"
+ , "w" <> (subscript "xy") <> "z}"
+ , "1" <> (superscript "") <> "2"
+ , "3" <> subscript "{}"
+ , "4" <> superscript ("(a(" <> strong "b(c" <> ")d))")
+ ])
+
, "Image" =:
"[[./sunset.jpg]]" =?>
(para $ image "./sunset.jpg" "" "")