summaryrefslogtreecommitdiff
path: root/test/Tests
diff options
context:
space:
mode:
authorLucas Viana <l240191@dac.unicamp.br>2022-01-05 19:02:47 -0300
committerAlbert Krewinkel <albert+github@zeitkraut.de>2022-01-06 19:33:13 +0100
commit4be41e3bb54449597b998788753717a6765b413b (patch)
treebf88f9ae9ab540c9e22b81034a4409770cbb9484 /test/Tests
parentea745822887bd91b34bd808d3037e3da8009a18e (diff)
Org reader: support counter cookies in lists
This adds support for counter cookies in org lists. Such cookies are used to override the item counter in ordered lists. In org it is possible to set the counter at any list item, but since Pandoc AST does not support this, we restrict the usage to setting an offset for the entire ordered list, by using the cookie in the first list item. Note that even though unordered lists do not have counters, Org Mode still parses such cookies in unordered lists and suppresses them in the output, so we do the same. Also, even though org-list-allow-alphabetical is disabled in Emacs by default, for some reason alphabetical cookies are always parsed and used in Org Mode regardlessly of whether this option is enabled or the list style is decimal, so we do the same. E.g. 2. test 3. test Is parsed as an ordered list starting at 1, as before. This also conforms to Org Mode behaviour. 1. [@2] test 2. test Is now parsed as an ordered list starting at 2, so that it conforms to Org Mode behaviour. Note that when parsing 1. [@2] test 2. [@9] test the second cookie is silenced and the entire list starts at 2. This is because the current Pandoc AST does not support expressing a change in the counter at a specific item.
Diffstat (limited to 'test/Tests')
-rw-r--r--test/Tests/Readers/Org/Block/List.hs56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/Tests/Readers/Org/Block/List.hs b/test/Tests/Readers/Org/Block/List.hs
index 24d3590b3..c5dba52f4 100644
--- a/test/Tests/Readers/Org/Block/List.hs
+++ b/test/Tests/Readers/Org/Block/List.hs
@@ -27,6 +27,13 @@ tests =
, plain "Item2"
]
+ , "Simple Bullet List with Ignored Counter Cookie" =:
+ ("- [@4] Item1\n" <>
+ "- Item2\n") =?>
+ bulletList [ plain "Item1"
+ , plain "Item2"
+ ]
+
, "Indented Bullet Lists" =:
(" - Item1\n" <>
" - Item2\n") =?>
@@ -131,6 +138,21 @@ tests =
]
]
+ , "Task List with Counter Cookies" =:
+ T.unlines [ "- [ ] nope"
+ , "- [@9] [X] yup"
+ , "- [@a][-] started"
+ , " 1. [@3][X] sure"
+ , " 2. [@b] [ ] nuh-uh"
+ ] =?>
+ bulletList [ plain "☐ nope", plain "☒ yup"
+ , mconcat [ plain "☐ started"
+ , orderedListWith
+ (3, DefaultStyle, DefaultDelim)
+ [plain "☒ sure", plain "☐ nuh-uh"]
+ ]
+ ]
+
, "Simple Ordered List" =:
("1. Item1\n" <>
"2. Item2\n") =?>
@@ -140,6 +162,33 @@ tests =
]
in orderedListWith listStyle listStructure
+ , "Simple Ordered List with Counter Cookie" =:
+ ("1. [@1234] Item1\n" <>
+ "2. Item2\n") =?>
+ let listStyle = (1234, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Simple Ordered List with Alphabetical Counter Cookie" =:
+ ("1. [@c] Item1\n" <>
+ "2. Item2\n") =?>
+ let listStyle = (3, DefaultStyle, DefaultDelim)
+ listStructure = [ plain "Item1"
+ , plain "Item2"
+ ]
+ in orderedListWith listStyle listStructure
+
+ , "Simple Ordered List with Ignored Counter Cookie" =:
+ ("1. Item1\n" <>
+ "2. [@4] 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") =?>
@@ -164,6 +213,13 @@ tests =
] =?>
orderedList [ plain "", plain "" ]
+ , "Empty ordered list item with counter cookie" =:
+ T.unlines [ "1. [@5]"
+ , "3. [@e] "
+ ] =?>
+ let listStyle = (5, DefaultStyle, DefaultDelim)
+ in orderedListWith listStyle [ plain "", plain "" ]
+
, "Nested Ordered Lists" =:
("1. One\n" <>
" 1. One-One\n" <>