From fcfbbd2caa96e27e241a441629fcf6003f7a48da Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 17 Nov 2011 22:35:39 -0800 Subject: Supported definition lists. --- src/Text/Pandoc/Writers/Asciidoc.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/Text') 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 -- cgit v1.2.3