@@ -57,7 +57,6 @@ data WriterState =
5757 , stHasRawTeX :: Bool
5858 , stOptions :: WriterOptions
5959 , stTopLevel :: Bool
60− , stLastNested :: Bool
6160 }
6261
6362type RST = StateT WriterState
@@ -68,7 +67,7 @@ writeRST opts document = do
6867 let st = WriterState { stNotes = [], stLinks = [],
6968 stImages = [], stHasMath = False,
7069 stHasRawTeX = False, stOptions = opts,
71− stTopLevel = True, stLastNested = False}
70+ stTopLevel = True }
7271 evalStateT (pandocToRST document) st
7372
7473-- | Return RST representation of document.
@@ -353,33 +352,26 @@ blockListToRST' :: PandocMonad m
353352 -> [Block] -- ^ List of block elements
354353 -> RST m Doc
355354blockListToRST' topLevel blocks = do
355+ -- insert comment between list and quoted blocks, see #4248 and #3675
356+ let fixBlocks (b1:b2@(BlockQuote _):bs)
357+ | toClose b1 = b1 : commentSep : b2 : fixBlocks bs
358+ where
359+ toClose (Plain{}) = False
360+ toClose (Header{}) = False
361+ toClose (LineBlock{}) = False
362+ toClose (HorizontalRule) = False
363+ toClose (Para [Image _ _ (_,'f':'i':'g':':':_)]) = True
364+ toClose (Para{}) = False
365+ toClose _ = True
366+ commentSep = RawBlock "rst" "..\n\n"
367+ fixBlocks (b:bs) = b : fixBlocks bs
368+ fixBlocks [] = []
356369 tl <- gets stTopLevel
357− modify (\s->s{stTopLevel=topLevel, stLastNested=False})
358− res <- vcat `fmap` mapM blockToRST' blocks
370+ modify (\s->s{stTopLevel=topLevel})
371+ res <- vcat `fmap` mapM blockToRST (fixBlocks blocks)
359372 modify (\s->s{stTopLevel=tl})
360373 return res
361374
362−blockToRST' :: PandocMonad m => Block -> RST m Doc
363−blockToRST' (x@BlockQuote{}) = do
364− lastNested <- gets stLastNested
365− res <- blockToRST x
366− modify (\s -> s{stLastNested = True})
367− return $ if lastNested
368− then ".." $+$ res
369− else res
370−blockToRST' x = do
371− modify (\s -> s{stLastNested =
372− case x of
373− Para [Image _ _ (_,'f':'i':'g':':':_)] -> True
374− Para{} -> False
375− Plain{} -> False
376− Header{} -> False
377− LineBlock{} -> False
378− HorizontalRule -> False
379− _ -> True
380− })
381− blockToRST x
382−
383375blockListToRST :: PandocMonad m
384376 => [Block] -- ^ List of block elements
385377 -> RST m Doc