diff options
Diffstat (limited to 'test/Tests/Readers/Org/Block')
-rw-r--r-- | test/Tests/Readers/Org/Block/CodeBlock.hs.orig | 194 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Block/Figure.hs.orig | 57 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Block/Header.hs.orig | 182 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Block/List.hs.orig | 244 | ||||
-rw-r--r-- | test/Tests/Readers/Org/Block/Table.hs.orig | 150 |
5 files changed, 0 insertions, 827 deletions
diff --git a/test/Tests/Readers/Org/Block/CodeBlock.hs.orig b/test/Tests/Readers/Org/Block/CodeBlock.hs.orig deleted file mode 100644 index 8fa822089..000000000 --- a/test/Tests/Readers/Org/Block/CodeBlock.hs.orig +++ /dev/null @@ -1,194 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Tests.Readers.Org.Block.CodeBlock (tests) where - -import Test.Tasty (TestTree) -import Tests.Helpers ((=?>)) -import Tests.Readers.Org.Shared ((=:), spcSep) -import Text.Pandoc.Builder -import qualified Data.Text as T - -tests :: [TestTree] -tests = - [ "Source block" =: - T.unlines [ " #+BEGIN_SRC haskell" - , " main = putStrLn greeting" - , " where greeting = \"moin\"" - , " #+END_SRC" ] =?> - let attr' = ("", ["haskell"], []) - code' = "main = putStrLn greeting\n" <> - " where greeting = \"moin\"\n" - in codeBlockWith attr' code' - - , "Source block with indented code" =: - T.unlines [ " #+BEGIN_SRC haskell" - , " main = putStrLn greeting" - , " where greeting = \"moin\"" - , " #+END_SRC" ] =?> - let attr' = ("", ["haskell"], []) - code' = "main = putStrLn greeting\n" <> - " where greeting = \"moin\"\n" - in codeBlockWith attr' code' - - , "Source block with tab-indented code" =: - T.unlines [ "\t#+BEGIN_SRC haskell" - , "\tmain = putStrLn greeting" - , "\t where greeting = \"moin\"" - , "\t#+END_SRC" ] =?> - let attr' = ("", ["haskell"], []) - code' = "main = putStrLn greeting\n" <> - " where greeting = \"moin\"\n" - in codeBlockWith attr' code' - - , "Empty source block" =: - T.unlines [ " #+BEGIN_SRC haskell" - , " #+END_SRC" ] =?> - let attr' = ("", ["haskell"], []) - code' = "" - in codeBlockWith attr' code' - - , "Source block between paragraphs" =: - T.unlines [ "Low German greeting" - , " #+BEGIN_SRC haskell" - , " main = putStrLn greeting" - , " where greeting = \"Moin!\"" - , " #+END_SRC" ] =?> - let attr' = ("", ["haskell"], []) - code' = "main = putStrLn greeting\n" <> - " where greeting = \"Moin!\"\n" - in mconcat [ para $ spcSep [ "Low", "German", "greeting" ] - , codeBlockWith attr' code' - ] - , "Source block with babel arguments" =: - T.unlines [ "#+BEGIN_SRC emacs-lisp :exports both" - , "(progn (message \"Hello, World!\")" - , " (+ 23 42))" - , "#+END_SRC" ] =?> - let classes = [ "commonlisp" ] -- as kate doesn't know emacs-lisp syntax - params = [ ("org-language", "emacs-lisp") - , ("exports", "both") - ] - code' = unlines [ "(progn (message \"Hello, World!\")" - , " (+ 23 42))" ] - in codeBlockWith ("", classes, params) code' - - , "Source block with results and :exports both" =: - T.unlines [ "#+BEGIN_SRC emacs-lisp :exports both" - , "(progn (message \"Hello, World!\")" - , " (+ 23 42))" - , "#+END_SRC" - , "" - , "#+RESULTS:" - , ": 65"] =?> - let classes = [ "commonlisp" ] - params = [ ("org-language", "emacs-lisp") - , ("exports", "both") - ] - code' = unlines [ "(progn (message \"Hello, World!\")" - , " (+ 23 42))" ] - results' = "65\n" - in codeBlockWith ("", classes, params) code' - <> - codeBlockWith ("", ["example"], []) results' - - , "Source block with results and :exports code" =: - T.unlines [ "#+BEGIN_SRC emacs-lisp :exports code" - , "(progn (message \"Hello, World!\")" - , " (+ 23 42))" - , "#+END_SRC" - , "" - , "#+RESULTS:" - , ": 65" ] =?> - let classes = [ "commonlisp" ] - params = [ ("org-language", "emacs-lisp") - , ("exports", "code") - ] - code' = unlines [ "(progn (message \"Hello, World!\")" - , " (+ 23 42))" ] - in codeBlockWith ("", classes, params) code' - - , "Source block with results and :exports results" =: - T.unlines [ "#+BEGIN_SRC emacs-lisp :exports results" - , "(progn (message \"Hello, World!\")" - , " (+ 23 42))" - , "#+END_SRC" - , "" - , "#+RESULTS:" - , ": 65" ] =?> - let results' = "65\n" - in codeBlockWith ("", ["example"], []) results' - - , "Source block with results and :exports none" =: - T.unlines [ "#+BEGIN_SRC emacs-lisp :exports none" - , "(progn (message \"Hello, World!\")" - , " (+ 23 42))" - , "#+END_SRC" - , "" - , "#+RESULTS:" - , ": 65" ] =?> - (mempty :: Blocks) - - , "Source block with toggling header arguments" =: - T.unlines [ "#+BEGIN_SRC sh :noeval" - , "echo $HOME" - , "#+END_SRC" - ] =?> - let classes = [ "bash" ] - params = [ ("org-language", "sh"), ("noeval", "yes") ] - in codeBlockWith ("", classes, params) "echo $HOME\n" - - , "Source block with line number switch" =: - T.unlines [ "#+BEGIN_SRC sh -n 10" - , ":() { :|:& };:" - , "#+END_SRC" - ] =?> - let classes = [ "bash", "numberLines" ] - params = [ ("org-language", "sh"), ("startFrom", "10") ] - in codeBlockWith ("", classes, params) ":() { :|:& };:\n" - - , "Source block with multi-word parameter values" =: - T.unlines [ "#+BEGIN_SRC dot :cmdline -Kdot -Tpng " - , "digraph { id [label=\"ID\"] }" - , "#+END_SRC" - ] =?> - let classes = [ "dot" ] - params = [ ("cmdline", "-Kdot -Tpng") ] - in codeBlockWith ("", classes, params) "digraph { id [label=\"ID\"] }\n" - - , "Example block" =: - T.unlines [ "#+begin_example" - , "A chosen representation of" - , "a rule." - , "#+eND_exAMPle" - ] =?> - codeBlockWith ("", ["example"], []) - "A chosen representation of\na rule.\n" - - , "Code block with caption" =: - T.unlines [ "#+CAPTION: Functor laws in Haskell" - , "#+NAME: functor-laws" - , "#+BEGIN_SRC haskell" - , "fmap id = id" - , "fmap (p . q) = (fmap p) . (fmap q)" - , "#+END_SRC" - ] =?> - divWith - nullAttr - (mappend - (plain $ spanWith ("", ["label"], []) - (spcSep [ "Functor", "laws", "in", "Haskell" ])) - (codeBlockWith ("functor-laws", ["haskell"], []) - (unlines [ "fmap id = id" - , "fmap (p . q) = (fmap p) . (fmap q)" - ]))) - - , "Non-letter chars in source block parameters" =: - T.unlines [ "#+BEGIN_SRC C :tangle xxxx.c :city Zürich" - , "code body" - , "#+END_SRC" - ] =?> - let params = [ ("org-language", "C") - , ("tangle", "xxxx.c") - , ("city", "Zürich") - ] - in codeBlockWith ( "", ["c"], params) "code body\n" - ] diff --git a/test/Tests/Readers/Org/Block/Figure.hs.orig b/test/Tests/Readers/Org/Block/Figure.hs.orig deleted file mode 100644 index cae6ef179..000000000 --- a/test/Tests/Readers/Org/Block/Figure.hs.orig +++ /dev/null @@ -1,57 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Tests.Readers.Org.Block.Figure (tests) where - -import Test.Tasty (TestTree) -import Tests.Helpers ((=?>)) -import Tests.Readers.Org.Shared ((=:)) -import Text.Pandoc.Builder (image, imageWith, para) -import qualified Data.Text as T - -tests :: [TestTree] -tests = - [ "Figure" =: - T.unlines [ "#+caption: A very courageous man." - , "#+name: goodguy" - , "[[file:edward.jpg]]" - ] =?> - para (image "edward.jpg" "fig:goodguy" "A very courageous man.") - - , "Figure with no name" =: - T.unlines [ "#+caption: I've been through the desert on this" - , "[[file:horse.png]]" - ] =?> - para (image "horse.png" "fig:" "I've been through the desert on this") - - , "Figure with `fig:` prefix in name" =: - T.unlines [ "#+caption: Used as a metapher in evolutionary biology." - , "#+name: fig:redqueen" - , "[[./the-red-queen.jpg]]" - ] =?> - para (image "./the-red-queen.jpg" "fig:redqueen" - "Used as a metapher in evolutionary biology.") - - , "Figure with HTML attributes" =: - T.unlines [ "#+CAPTION: mah brain just explodid" - , "#+NAME: lambdacat" - , "#+ATTR_HTML: :style color: blue :role button" - , "[[file:lambdacat.jpg]]" - ] =?> - let kv = [("style", "color: blue"), ("role", "button")] - name = "fig:lambdacat" - caption = "mah brain just explodid" - in para (imageWith (mempty, mempty, kv) "lambdacat.jpg" name caption) - - , "Labelled figure" =: - T.unlines [ "#+CAPTION: My figure" - , "#+LABEL: fig:myfig" - , "[[file:blub.png]]" - ] =?> - let attr = ("fig:myfig", mempty, mempty) - in para (imageWith attr "blub.png" "fig:" "My figure") - - , "Figure with empty caption" =: - T.unlines [ "#+CAPTION:" - , "[[file:guess.jpg]]" - ] =?> - para (image "guess.jpg" "fig:" "") - ] diff --git a/test/Tests/Readers/Org/Block/Header.hs.orig b/test/Tests/Readers/Org/Block/Header.hs.orig deleted file mode 100644 index e8ad88558..000000000 --- a/test/Tests/Readers/Org/Block/Header.hs.orig +++ /dev/null @@ -1,182 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Tests.Readers.Org.Block.Header (tests) where - -import Test.Tasty (TestTree, testGroup) -import Tests.Helpers ((=?>)) -import Tests.Readers.Org.Shared ((=:), spcSep, tagSpan) -import Text.Pandoc.Builder -import qualified Data.Text as T - -tests :: [TestTree] -tests = - [ "First Level Header" =: - "* Headline\n" =?> - headerWith ("headline", [], []) 1 "Headline" - - , "Third Level Header" =: - "*** Third Level Headline\n" =?> - headerWith ("third-level-headline", [], []) - 3 - ("Third" <> space <> "Level" <> space <> "Headline") - - , "Compact Headers with Paragraph" =: - T.unlines [ "* First Level" - , "** Second Level" - , " Text" - ] =?> - mconcat [ headerWith ("first-level", [], []) - 1 - ("First" <> space <> "Level") - , headerWith ("second-level", [], []) - 2 - ("Second" <> space <> "Level") - , para "Text" - ] - - , "Separated Headers with Paragraph" =: - T.unlines [ "* First Level" - , "" - , "** Second Level" - , "" - , " Text" - ] =?> - mconcat [ headerWith ("first-level", [], []) - 1 - ("First" <> space <> "Level") - , headerWith ("second-level", [], []) - 2 - ("Second" <> space <> "Level") - , para "Text" - ] - - , "Headers not preceded by a blank line" =: - T.unlines [ "** eat dinner" - , "Spaghetti and meatballs tonight." - , "** walk dog" - ] =?> - mconcat [ headerWith ("eat-dinner", [], []) - 2 - ("eat" <> space <> "dinner") - , para $ spcSep [ "Spaghetti", "and", "meatballs", "tonight." ] - , headerWith ("walk-dog", [], []) - 2 - ("walk" <> space <> "dog") - ] - - , testGroup "Todo keywords" - [ "Header with known todo keyword" =: - "* TODO header" =?> - let todoSpan = spanWith ("", ["todo", "TODO"], []) "TODO" - in headerWith ("header", [], []) 1 (todoSpan <> space <> "header") - - , "Header marked as done" =: - "* DONE header" =?> - let todoSpan = spanWith ("", ["done", "DONE"], []) "DONE" - in headerWith ("header", [], []) 1 (todoSpan <> space <> "header") - - , "Header with unknown todo keyword" =: - "* WAITING header" =?> - headerWith ("waiting-header", [], []) 1 "WAITING header" - - , "Custom todo keywords" =: - T.unlines [ "#+TODO: WAITING CANCELLED" - , "* WAITING compile" - , "* CANCELLED lunch" - ] =?> - let todoSpan = spanWith ("", ["todo", "WAITING"], []) "WAITING" - doneSpan = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED" - in headerWith ("compile", [], []) 1 (todoSpan <> space <> "compile") - <> headerWith ("lunch", [], []) 1 (doneSpan <> space <> "lunch") - - , "Custom todo keywords with multiple done-states" =: - T.unlines [ "#+TODO: WAITING | DONE CANCELLED " - , "* WAITING compile" - , "* CANCELLED lunch" - , "* DONE todo-feature" - ] =?> - let waiting = spanWith ("", ["todo", "WAITING"], []) "WAITING" - cancelled = spanWith ("", ["done", "CANCELLED"], []) "CANCELLED" - done = spanWith ("", ["done", "DONE"], []) "DONE" - in headerWith ("compile", [], []) 1 (waiting <> space <> "compile") - <> headerWith ("lunch", [], []) 1 (cancelled <> space <> "lunch") - <> headerWith ("todo-feature", [], []) 1 (done <> space <> "todo-feature") - ] - - , "Tagged headers" =: - T.unlines [ "* Personal :PERSONAL:" - , "** Call Mom :@PHONE:" - , "** Call John :@PHONE:JOHN: " - ] =?> - mconcat [ headerWith ("personal", [], []) - 1 - ("Personal " <> tagSpan "PERSONAL") - , headerWith ("call-mom", [], []) - 2 - ("Call Mom " <> tagSpan "@PHONE") - , headerWith ("call-john", [], []) - 2 - ("Call John " <> tagSpan "@PHONE" <> "\160" <> tagSpan "JOHN") - ] - - , "Untagged header containing colons" =: - "* This: is not: tagged" =?> - headerWith ("this-is-not-tagged", [], []) 1 "This: is not: tagged" - - , "Header starting with strokeout text" =: - T.unlines [ "foo" - , "" - , "* +thing+ other thing" - ] =?> - mconcat [ para "foo" - , headerWith ("thing-other-thing", [], []) - 1 - (strikeout "thing" <> " other thing") - ] - - , "Comment Trees" =: - T.unlines [ "* COMMENT A comment tree" - , " Not much going on here" - , "** This will be dropped" - , "* Comment tree above" - ] =?> - headerWith ("comment-tree-above", [], []) 1 "Comment tree above" - - , "Nothing but a COMMENT header" =: - "* COMMENT Test" =?> - (mempty::Blocks) - - , "Tree with :noexport:" =: - T.unlines [ "* Should be ignored :archive:noexport:old:" - , "** Old stuff" - , " This is not going to be exported" - ] =?> - (mempty::Blocks) - - , "Subtree with :noexport:" =: - T.unlines [ "* Exported" - , "** This isn't exported :noexport:" - , "*** This neither" - , "** But this is" - ] =?> - mconcat [ headerWith ("exported", [], []) 1 "Exported" - , headerWith ("but-this-is", [], []) 2 "But this is" - ] - - , "Preferences are treated as header attributes" =: - T.unlines [ "* foo" - , " :PROPERTIES:" - , " :custom_id: fubar" - , " :bar: baz" - , " :END:" - ] =?> - headerWith ("fubar", [], [("bar", "baz")]) 1 "foo" - - - , "Headers marked with a unnumbered property get a class of the same name" =: - T.unlines [ "* Not numbered" - , " :PROPERTIES:" - , " :UNNUMBERED: t" - , " :END:" - ] =?> - headerWith ("not-numbered", ["unnumbered"], []) 1 "Not numbered" - ] diff --git a/test/Tests/Readers/Org/Block/List.hs.orig b/test/Tests/Readers/Org/Block/List.hs.orig deleted file mode 100644 index 343682a80..000000000 --- a/test/Tests/Readers/Org/Block/List.hs.orig +++ /dev/null @@ -1,244 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Tests.Readers.Org.Block.List (tests) where - -import Test.Tasty (TestTree) -import Tests.Helpers ((=?>)) -import Tests.Readers.Org.Shared ((=:), spcSep) -import Text.Pandoc.Builder -import qualified Data.Text as T - -tests :: [TestTree] -tests = - [ "Simple Bullet Lists" =: - ("- Item1\n" <> - "- Item2\n") =?> - bulletList [ plain "Item1" - , plain "Item2" - ] - - , "Indented Bullet Lists" =: - (" - Item1\n" <> - " - Item2\n") =?> - bulletList [ plain "Item1" - , plain "Item2" - ] - - , "Unindented *" =: - ("- Item1\n" <> - "* Item2\n") =?> - bulletList [ plain "Item1" - ] <> - headerWith ("item2", [], []) 1 "Item2" - - , "Multi-line Bullet Lists" =: - ("- *Fat\n" <> - " Tony*\n" <> - "- /Sideshow\n" <> - " Bob/") =?> - bulletList [ plain $ strong ("Fat" <> softbreak <> "Tony") - , plain $ emph ("Sideshow" <> softbreak <> "Bob") - ] - - , "Nested Bullet Lists" =: - ("- Discovery\n" <> - " + One More Time\n" <> - " + Harder, Better, Faster, Stronger\n" <> - "- Homework\n" <> - " + Around the World\n"<> - "- Human After All\n" <> - " + Technologic\n" <> - " + Robot Rock\n") =?> - bulletList [ mconcat - [ plain "Discovery" - , bulletList [ plain ("One" <> space <> - "More" <> space <> - "Time") - , plain ("Harder," <> space <> - "Better," <> space <> - "Faster," <> space <> - "Stronger") - ] - ] - , mconcat - [ plain "Homework" - , bulletList [ plain ("Around" <> space <> - "the" <> space <> - "World") - ] - ] - , mconcat - [ plain ("Human" <> space <> "After" <> space <> "All") - , bulletList [ plain "Technologic" - , plain ("Robot" <> space <> "Rock") - ] - ] - ] - - , "Bullet List with Decreasing Indent" =: - " - Discovery\n\ - \ - Human After All\n" =?> - mconcat [ bulletList [ plain "Discovery" ] - , bulletList [ plain ("Human" <> space <> "After" <> space <> "All")] - ] - - , "Header follows Bullet List" =: - " - Discovery\n\ - \ - Human After All\n\ - \* Homework" =?> - mconcat [ bulletList [ plain "Discovery" - , plain ("Human" <> space <> "After" <> space <> "All") - ] - , headerWith ("homework", [], []) 1 "Homework" - ] - - , "Bullet List Unindented with trailing Header" =: - "- Discovery\n\ - \- Homework\n\ - \* NotValidListItem" =?> - mconcat [ bulletList [ plain "Discovery" - , plain "Homework" - ] - , headerWith ("notvalidlistitem", [], []) 1 "NotValidListItem" - ] - - , "Empty bullet points" =: - T.unlines [ "-" - , "- " - ] =?> - bulletList [ plain "", plain "" ] - - , "Simple Ordered List" =: - ("1. Item1\n" <> - "2. Item2\n") =?> - let listStyle = (1, DefaultStyle, DefaultDelim) - listStructure = [ plain "Item1" - , plain "Item2" - ] - in orderedListWith listStyle listStructure - - , "Simple Ordered List with Parens" =: - ("1) Item1\n" <> - "2) Item2\n") =?> - let listStyle = (1, DefaultStyle, DefaultDelim) - listStructure = [ plain "Item1" - , plain "Item2" - ] - in orderedListWith listStyle listStructure - - , "Indented Ordered List" =: - (" 1. Item1\n" <> - " 2. Item2\n") =?> - let listStyle = (1, DefaultStyle, DefaultDelim) - listStructure = [ plain "Item1" - , plain "Item2" - ] - in orderedListWith listStyle listStructure - - , "Empty ordered list item" =: - T.unlines [ "1." - , "3. " - ] =?> - orderedList [ plain "", plain "" ] - - , "Nested Ordered Lists" =: - ("1. One\n" <> - " 1. One-One\n" <> - " 2. One-Two\n" <> - "2. Two\n" <> - " 1. Two-One\n"<> - " 2. Two-Two\n") =?> - let listStyle = (1, DefaultStyle, DefaultDelim) - listStructure = [ mconcat - [ plain "One" - , orderedList [ plain "One-One" - , plain "One-Two" - ] - ] - , mconcat - [ plain "Two" - , orderedList [ plain "Two-One" - , plain "Two-Two" - ] - ] - ] - in orderedListWith listStyle listStructure - - , "Ordered List in Bullet List" =: - ("- Emacs\n" <> - " 1. Org\n") =?> - bulletList [ plain "Emacs" <> - orderedList [ plain "Org"] - ] - - , "Bullet List in Ordered List" =: - ("1. GNU\n" <> - " - Freedom\n") =?> - orderedList [ plain "GNU" <> bulletList [ plain "Freedom" ] ] - - , "Definition List" =: - T.unlines [ "- PLL :: phase-locked loop" - , "- TTL ::" - , " transistor-transistor logic" - , "- PSK :: phase-shift keying" - , "" - , " a digital modulation scheme" - ] =?> - definitionList [ ("PLL", [ plain $ "phase-locked" <> space <> "loop" ]) - , ("TTL", [ plain $ "transistor-transistor" <> space <> - "logic" ]) - , ("PSK", [ mconcat - [ para $ "phase-shift" <> space <> "keying" - , para $ spcSep [ "a", "digital" - , "modulation", "scheme" ] - ] - ]) - ] - , "Definition list with multi-word term" =: - " - Elijah Wood :: He plays Frodo" =?> - definitionList [ ("Elijah" <> space <> "Wood", [plain $ "He" <> space <> "plays" <> space <> "Frodo"])] - , "Compact definition list" =: - T.unlines [ "- ATP :: adenosine 5' triphosphate" - , "- DNA :: deoxyribonucleic acid" - , "- PCR :: polymerase chain reaction" - , "" - ] =?> - definitionList - [ ("ATP", [ plain $ spcSep [ "adenosine", "5'", "triphosphate" ] ]) - , ("DNA", [ plain $ spcSep [ "deoxyribonucleic", "acid" ] ]) - , ("PCR", [ plain $ spcSep [ "polymerase", "chain", "reaction" ] ]) - ] - - , "Definition List With Trailing Header" =: - "- definition :: list\n\ - \- cool :: defs\n\ - \* header" =?> - mconcat [ definitionList [ ("definition", [plain "list"]) - , ("cool", [plain "defs"]) - ] - , headerWith ("header", [], []) 1 "header" - ] - - , "Definition lists double-colon markers must be surrounded by whitespace" =: - "- std::cout" =?> - bulletList [ plain "std::cout" ] - - , "Loose bullet list" =: - T.unlines [ "- apple" - , "" - , "- orange" - , "" - , "- peach" - ] =?> - bulletList [ para "apple" - , para "orange" - , para "peach" - ] - - , "Recognize preceding paragraphs in non-list contexts" =: - T.unlines [ "CLOSED: [2015-10-19 Mon 15:03]" - , "- Note taken on [2015-10-19 Mon 13:24]" - ] =?> - mconcat [ para "CLOSED: [2015-10-19 Mon 15:03]" - , bulletList [ plain "Note taken on [2015-10-19 Mon 13:24]" ] - ] - ] diff --git a/test/Tests/Readers/Org/Block/Table.hs.orig b/test/Tests/Readers/Org/Block/Table.hs.orig deleted file mode 100644 index db6e756f8..000000000 --- a/test/Tests/Readers/Org/Block/Table.hs.orig +++ /dev/null @@ -1,150 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Tests.Readers.Org.Block.Table (tests) where - -import Test.Tasty (TestTree) -import Tests.Helpers ((=?>)) -import Tests.Readers.Org.Shared ((=:), spcSep) -import Text.Pandoc.Builder -import qualified Data.Text as T - -simpleTable' :: Int - -> [Blocks] - -> [[Blocks]] - -> Blocks -simpleTable' n = table "" (replicate n (AlignDefault, 0.0)) - -tests :: [TestTree] -tests = - [ "Single cell table" =: - "|Test|" =?> - simpleTable' 1 mempty [[plain "Test"]] - - , "Multi cell table" =: - "| One | Two |" =?> - simpleTable' 2 mempty [ [ plain "One", plain "Two" ] ] - - , "Multi line table" =: - T.unlines [ "| One |" - , "| Two |" - , "| Three |" - ] =?> - simpleTable' 1 mempty - [ [ plain "One" ] - , [ plain "Two" ] - , [ plain "Three" ] - ] - - , "Empty table" =: - "||" =?> - simpleTable' 1 mempty [[mempty]] - - , "Glider Table" =: - T.unlines [ "| 1 | 0 | 0 |" - , "| 0 | 1 | 1 |" - , "| 1 | 1 | 0 |" - ] =?> - simpleTable' 3 mempty - [ [ plain "1", plain "0", plain "0" ] - , [ plain "0", plain "1", plain "1" ] - , [ plain "1", plain "1", plain "0" ] - ] - - , "Table between Paragraphs" =: - T.unlines [ "Before" - , "| One | Two |" - , "After" - ] =?> - mconcat [ para "Before" - , simpleTable' 2 mempty [ [ plain "One", plain "Two" ] ] - , para "After" - ] - - , "Table with Header" =: - T.unlines [ "| Species | Status |" - , "|--------------+--------------|" - , "| cervisiae | domesticated |" - , "| paradoxus | wild |" - ] =?> - simpleTable [ plain "Species", plain "Status" ] - [ [ plain "cervisiae", plain "domesticated" ] - , [ plain "paradoxus", plain "wild" ] - ] - - , "Table with final hline" =: - T.unlines [ "| cervisiae | domesticated |" - , "| paradoxus | wild |" - , "|--------------+--------------|" - ] =?> - simpleTable' 2 mempty - [ [ plain "cervisiae", plain "domesticated" ] - , [ plain "paradoxus", plain "wild" ] - ] - - , "Table in a box" =: - T.unlines [ "|---------|---------|" - , "| static | Haskell |" - , "| dynamic | Lisp |" - , "|---------+---------|" - ] =?> - simpleTable' 2 mempty - [ [ plain "static", plain "Haskell" ] - , [ plain "dynamic", plain "Lisp" ] - ] - - , "Table with empty cells" =: - "|||c|" =?> - simpleTable' 3 mempty [[mempty, mempty, plain "c"]] - - , "Table with empty rows" =: - T.unlines [ "| first |" - , "| |" - , "| third |" - ] =?> - simpleTable' 1 mempty [[plain "first"], [mempty], [plain "third"]] - - , "Table with alignment row" =: - T.unlines [ "| Numbers | Text | More |" - , "| <c> | <r> | |" - , "| 1 | One | foo |" - , "| 2 | Two | bar |" - ] =?> - table "" (zip [AlignCenter, AlignRight, AlignDefault] [0, 0, 0]) - [] - [ [ plain "Numbers", plain "Text", plain "More" ] - , [ plain "1" , plain "One" , plain "foo" ] - , [ plain "2" , plain "Two" , plain "bar" ] - ] - - , "Pipe within text doesn't start a table" =: - "Ceci n'est pas une | pipe " =?> - para (spcSep [ "Ceci", "n'est", "pas", "une", "|", "pipe" ]) - - , "Missing pipe at end of row" =: - "|incomplete-but-valid" =?> - simpleTable' 1 mempty [ [ plain "incomplete-but-valid" ] ] - - , "Table with differing row lengths" =: - T.unlines [ "| Numbers | Text " - , "|-" - , "| <c> | <r> |" - , "| 1 | One | foo |" - , "| 2" - ] =?> - table "" (zip [AlignCenter, AlignRight] [0, 0]) - [ plain "Numbers", plain "Text" ] - [ [ plain "1" , plain "One" , plain "foo" ] - , [ plain "2" ] - ] - - , "Table with caption" =: - T.unlines [ "#+CAPTION: Hitchhiker's Multiplication Table" - , "| x | 6 |" - , "| 9 | 42 |" - ] =?> - table "Hitchhiker's Multiplication Table" - [(AlignDefault, 0), (AlignDefault, 0)] - [] - [ [ plain "x", plain "6" ] - , [ plain "9", plain "42" ] - ] - ] |