git.iko.soy/typeable/pandoc
on master help sign in
Fixed continuations in asciidoc definition lists.
commit457571e0c896d7ffbd7f53c9df4a9067d9ba0f68 authorJohn MacFarlane <fiddlosopher@gmail.com> dateFri 18 Nov 2011, 19:38 (15 years ago) parentf5af490
1 file changed+13−5
src/Text/Pandoc/Writers/Asciidoc.hs+13−5
src/Text/Pandoc/Writers/Asciidoc.hs+13−5
@@ -42,7 +42,7 @@ import Text.Pandoc.Templates (renderTemplate)
4242import Text.Pandoc.Shared
4343import Text.Pandoc.Parsing hiding (blankline)
4444import Text.ParserCombinators.Parsec ( runParser, GenParser )
45−import Data.List ( isPrefixOf, intercalate )
45+import Data.List ( isPrefixOf, intersperse, intercalate )
4646import Text.Pandoc.Pretty
4747import Control.Monad.State
4848
@@ -147,9 +147,15 @@ blockToAsciidoc _ (CodeBlock (_,classes,_) str) = return $
147147 else text $ intercalate "," $ "code" : classes
148148blockToAsciidoc opts (BlockQuote blocks) = do
149149 contents <- blockListToAsciidoc opts blocks
150− let cols = offset contents
150+ let isBlock (BlockQuote _) = True
151+ isBlock _ = False
152+ -- if there are nested block quotes, put in an open block
153+ let contents' = if any isBlock blocks
154+ then "--" $$ contents $$ "--"
155+ else contents
156+ let cols = offset contents'
151157 let bar = text $ replicate cols '_'
152− return $ bar $$ contents $$ bar <> blankline
158+ return $ bar $$ chomp contents' $$ bar <> blankline
153159blockToAsciidoc opts (Table caption aligns widths headers rows) = do
154160 caption' <- inlineListToAsciidoc opts caption
155161 let caption'' = if null caption
@@ -269,11 +275,13 @@ definitionListItemToAsciidoc opts (label, defs) = do
269275 if marker == "::"
270276 then modify (\st -> st{ defListMarker = ";;"})
271277 else modify (\st -> st{ defListMarker = "::"})
278+ let divider = cr <> text "+" <> cr
272279 let defsToAsciidoc :: [Block] -> State WriterState Doc
273− defsToAsciidoc ds = vcat `fmap` mapM (blockToAsciidoc opts) ds
280+ defsToAsciidoc ds = (vcat . intersperse divider . map chomp)
281+ `fmap` mapM (blockToAsciidoc opts) ds
274282 defs' <- mapM defsToAsciidoc defs
275283 modify (\st -> st{ defListMarker = marker })
276− let contents = nest 2 $ vsep defs'
284+ let contents = nest 2 $ vcat $ intersperse divider $ map chomp defs'
277285 return $ labelText <> text marker <> cr <> contents <> cr
278286
279287-- | Convert list of Pandoc block elements to markdown.