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 +```