aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-11-18 18:19:47 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-11-18 18:19:47 -0800
commit11f6177670a7e0b15a42c7576a988c083d9c77e2 (patch)
tree7c3c7252cc04261b9d597094ab03b6846c129479 /src/Text/Pandoc/Writers
parent40c7d096ccbc2f4bb0c0b4b79ba332c2542e997a (diff)
downloadpandoc-11f6177670a7e0b15a42c7576a988c083d9c77e2.tar.gz
Implemented ordered lists in asciidoc.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Asciidoc.hs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/Asciidoc.hs b/src/Text/Pandoc/Writers/Asciidoc.hs
index 2ef5b45bb..a3df93a3c 100644
--- a/src/Text/Pandoc/Writers/Asciidoc.hs
+++ b/src/Text/Pandoc/Writers/Asciidoc.hs
@@ -244,13 +244,20 @@ orderedListItemToAsciidoc :: WriterOptions -- ^ options
-> String -- ^ list item marker
-> [Block] -- ^ list item (list of blocks)
-> State WriterState Doc
-orderedListItemToAsciidoc opts marker items = do
- contents <- blockListToAsciidoc opts items
- let sps = case length marker - writerTabStop opts of
- n | n > 0 -> text $ replicate n ' '
- _ -> text " "
- let start = text marker <> sps
- return $ hang (writerTabStop opts) start $ contents <> cr
+orderedListItemToAsciidoc opts marker blocks = do
+ let addBlock :: Doc -> Block -> State WriterState Doc
+ addBlock d b | isEmpty d = chomp `fmap` blockToAsciidoc opts b
+ addBlock d b@(BulletList _) = do x <- blockToAsciidoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b@(OrderedList _ _) = do x <- blockToAsciidoc opts b
+ return $ d <> cr <> chomp x
+ addBlock d b = do x <- blockToAsciidoc opts b
+ return $ d <> cr <> text "+" <> cr <> chomp x
+ lev <- orderedListLevel `fmap` get
+ modify $ \s -> s{ orderedListLevel = lev + 1 }
+ contents <- foldM addBlock empty blocks
+ modify $ \s -> s{ orderedListLevel = lev }
+ return $ text marker <> space <> contents <> cr
-- | Convert definition list item (label, list of blocks) to markdown.
definitionListItemToAsciidoc :: WriterOptions