aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2011-11-17 22:35:39 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2011-11-17 22:35:39 -0800
commitfcfbbd2caa96e27e241a441629fcf6003f7a48da (patch)
treed2fe06e047d0128a879f9e3a90e54c053791212f /src/Text
parentb7cbd42d071a296220b3a08a1b2ea333150ca198 (diff)
downloadpandoc-fcfbbd2caa96e27e241a441629fcf6003f7a48da.tar.gz
Supported definition lists.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Asciidoc.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/Asciidoc.hs b/src/Text/Pandoc/Writers/Asciidoc.hs
index 53b607cfc..ff73ae7e6 100644
--- a/src/Text/Pandoc/Writers/Asciidoc.hs
+++ b/src/Text/Pandoc/Writers/Asciidoc.hs
@@ -40,12 +40,13 @@ import Data.List ( isPrefixOf, intersperse, intercalate, transpose )
import Text.Pandoc.Pretty
import Control.Monad.State
-data WriterState = WriterState { }
+data WriterState = WriterState { defListMarker :: String }
-- | Convert Pandoc to Asciidoc.
writeAsciidoc :: WriterOptions -> Pandoc -> String
writeAsciidoc opts document =
- evalState (pandocToAsciidoc opts document) WriterState{ }
+ evalState (pandocToAsciidoc opts document) WriterState{
+ defListMarker = "::" }
-- | Return markdown representation of document.
pandocToAsciidoc :: WriterOptions -> Pandoc -> State WriterState String
@@ -221,14 +222,16 @@ definitionListItemToAsciidoc :: WriterOptions
-> State WriterState Doc
definitionListItemToAsciidoc opts (label, defs) = do
labelText <- inlineListToAsciidoc opts label
- let tabStop = writerTabStop opts
- let leader = " ~"
- let sps = case writerTabStop opts - 3 of
- n | n > 0 -> text $ replicate n ' '
- _ -> text " "
- defs' <- mapM (mapM (blockToAsciidoc opts)) defs
- let contents = vcat $ map (\d -> hang tabStop (leader <> sps) $ vcat d <> cr) defs'
- return $ labelText <> cr <> contents <> cr
+ marker <- defListMarker `fmap` get
+ if marker == "::"
+ then modify (\st -> st{ defListMarker = ";;"})
+ else modify (\st -> st{ defListMarker = "::"})
+ let defsToAsciidoc :: [Block] -> State WriterState Doc
+ defsToAsciidoc ds = vcat `fmap` mapM (blockToAsciidoc opts) ds
+ defs' <- mapM defsToAsciidoc defs
+ modify (\st -> st{ defListMarker = marker })
+ let contents = nest 2 $ vsep defs'
+ return $ labelText <> text marker <> cr <> contents <> cr
-- | Convert list of Pandoc block elements to markdown.
blockListToAsciidoc :: WriterOptions -- ^ Options