summaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorLucas Viana <l240191@dac.unicamp.br>2022-01-06 16:30:20 -0300
committerJohn MacFarlane <jgm@berkeley.edu>2022-01-09 09:39:27 -0800
commitfb91a916154b70696fc7e533a7db83e847218715 (patch)
treef49172ba2eef9e7a3fbec5eccf7c6f8e3698153e /test/Tests
parent66636c89b03e75c76ed17904b9adc0a1772f419b (diff)
Org reader: support alphabetical (fancy) lists
This adds support for alphabetical lists in org by enabling the extension Ext_fancy_lists, mimicking the behaviour of Org Mode when org-list-allow-alphabetical is enabled. Enabling Ext_fancy_lists will also make Pandoc differentiate between the delimiters of ordered lists (periods or closing parentheses). Org does this differentiation by default when exporting to some formats (e.g. plain text) but does not in others (e.g. html and latex), so I decided to copy Pandoc's markdown reader behaviour.
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Readers/Org/Block/List.hs59
1 files changed, 58 insertions, 1 deletions
diff --git a/test/Tests/Readers/Org/Block/List.hs b/test/Tests/Readers/Org/Block/List.hs
index c5dba52f4..5708b25f5 100644
--- a/test/Tests/Readers/Org/Block/List.hs
+++ b/test/Tests/Readers/Org/Block/List.hs
@@ -12,12 +12,21 @@ Test parsing of org lists.
-}
module Tests.Readers.Org.Block.List (tests) where
+import Data.Text (Text)
import Test.Tasty (TestTree)
-import Tests.Helpers ((=?>))
+import Tests.Helpers ((=?>), purely, test)
import Tests.Readers.Org.Shared ((=:), spcSep)
+import Text.Pandoc (ReaderOptions (readerExtensions),
+ Extension (Ext_fancy_lists), def, enableExtension,
+ getDefaultExtensions, readOrg)
import Text.Pandoc.Builder
import qualified Data.Text as T
+orgFancyLists :: Text -> Pandoc
+orgFancyLists = purely $
+ let extensionsFancy = enableExtension Ext_fancy_lists (getDefaultExtensions "org")
+ in readOrg def{ readerExtensions = extensionsFancy }
+
tests :: [TestTree]
tests =
[ "Simple Bullet Lists" =:
@@ -153,6 +162,21 @@ tests =
]
]
+ , test orgFancyLists "Task with alphabetical markers and counter cookie" $
+ T.unlines [ "- [ ] nope"
+ , "- [@9] [X] yup"
+ , "- [@a][-] started"
+ , " a) [@D][X] sure"
+ , " b) [@8] [ ] nuh-uh"
+ ] =?>
+ bulletList [ plain "☐ nope", plain "☒ yup"
+ , mconcat [ plain "☐ started"
+ , orderedListWith
+ (4, LowerAlpha, OneParen)
+ [plain "☒ sure", plain "☐ nuh-uh"]
+ ]
+ ]
+
, "Simple Ordered List" =:
("1. Item1\n" <>
"2. Item2\n") =?>
@@ -162,6 +186,33 @@ tests =
]
in orderedListWith listStyle listStructure
+ , test orgFancyLists "Simple Ordered List with fancy lists extension" $
+ ("1. Item1\n" <>
+ "2. Item2\n") =?>
+ let listStyle = (1, Decimal, Period)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , test orgFancyLists "Simple Ordered List with lower alpha marker" $
+ ("a) Item1\n" <>
+ "b) Item2\n") =?>
+ let listStyle = (1, LowerAlpha, OneParen)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , test orgFancyLists "Simple Ordered List with upper and lower alpha markers" $
+ ("A. Item1\n" <>
+ "b) Item2\n") =?>
+ let listStyle = (1, UpperAlpha, Period)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
, "Simple Ordered List with Counter Cookie" =:
("1. [@1234] Item1\n" <>
"2. Item2\n") =?>
@@ -213,6 +264,12 @@ tests =
] =?>
orderedList [ plain "", plain "" ]
+ , test orgFancyLists "Empty ordered list item with fancy lists extension" $
+ T.unlines [ "a."
+ , "2. "
+ ] =?>
+ orderedListWith (1, LowerAlpha, Period) [ plain "", plain "" ]
+
, "Empty ordered list item with counter cookie" =:
T.unlines [ "1. [@5]"
, "3. [@e] "