Org writer: fix list items starting with a code block...

or other non-paragraph content.

Closes #7810.
This commit is contained in:
John MacFarlane 2022-01-08 23:21:15 -08:00
parent 61968047e4
commit 66636c89b0
2 changed files with 57 additions and 2 deletions

View file

@ -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

43
test/command/7810.md Normal file
View file

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