aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2022-01-08 23:21:15 -0800
committerJohn MacFarlane <[email protected]>2022-01-08 23:21:15 -0800
commit66636c89b03e75c76ed17904b9adc0a1772f419b (patch)
tree3340838c6faa71732dcd4d235d013bbba4cd3187
parent61968047e49f2710499028d71b12c783a53c7658 (diff)
Org writer: fix list items starting with a code block...
or other non-paragraph content. Closes #7810.
-rw-r--r--src/Text/Pandoc/Writers/Org.hs16
-rw-r--r--test/command/7810.md43
2 files changed, 57 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index 22c229de9..6d4dfa1b5 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -219,7 +219,13 @@ bulletListItemToOrg :: PandocMonad m => [Block] -> Org m (Doc Text)
bulletListItemToOrg items = do
exts <- gets $ writerExtensions . stOptions
contents <- blockListToOrg (taskListItemToOrg exts items)
- return $ hang 2 "- " (chomp contents) $$
+ -- if list item starts with non-paragraph, it must go on
+ -- the next line:
+ let contents' = (case items of
+ Plain{}:_ -> mempty
+ Para{}:_ -> mempty
+ _ -> cr) <> chomp contents
+ return $ hang 2 "- " contents' $$
if null items || endsWithPlain items
then cr
else blankline
@@ -233,11 +239,17 @@ orderedListItemToOrg :: PandocMonad m
orderedListItemToOrg marker counter items = do
exts <- gets $ writerExtensions . stOptions
contents <- blockListToOrg (taskListItemToOrg exts items)
+ -- if list item starts with non-paragraph, it must go on
+ -- the next line:
+ let contents' = (case items of
+ Plain{}:_ -> mempty
+ Para{}:_ -> mempty
+ _ -> cr) <> chomp contents
let cookie = maybe empty
(\n -> space <> literal "[@" <> literal (tshow n) <> literal "]")
counter
return $ hang (T.length marker + 1)
- (literal marker <> cookie <> space) (chomp contents) $$
+ (literal marker <> cookie <> space) contents' $$
if null items || endsWithPlain items
then cr
else blankline
diff --git a/test/command/7810.md b/test/command/7810.md
new file mode 100644
index 000000000..389aa733b
--- /dev/null
+++ b/test/command/7810.md
@@ -0,0 +1,43 @@
+```
+% pandoc -f org -t org
+-
+ #+begin_example
+ aa
+ #+end_example
+- test
+^D
+-
+ #+begin_example
+ aa
+ #+end_example
+
+- test
+```
+
+```
+% pandoc -f org -t org
+- a
+-
+- a
+- a
+^D
+- a
+-
+- a
+- a
+```
+
+```
+% pandoc -f org -t org
+- a
+ - b
+ - b
+- a
+- a
+^D
+- a
+ - b
+ - b
+- a
+- a
+```