@@ -57,7 +57,6 @@ data WriterState =
57 , stHasRawTeX :: Bool
57 , stHasRawTeX :: Bool
58 , stOptions :: WriterOptions
58 , stOptions :: WriterOptions
59 , stTopLevel :: Bool
59 , stTopLevel :: Bool
60− , stLastNested :: Bool
63type RST = StateT WriterState
62type RST = StateT WriterState
@@ -68,7 +67,7 @@ writeRST opts document = do
68 let st = WriterState { stNotes = [], stLinks = [],
67 let st = WriterState { stNotes = [], stLinks = [],
69 stImages = [], stHasMath = False,
68 stImages = [], stHasMath = False,
70 stHasRawTeX = False, stOptions = opts,
69 stHasRawTeX = False, stOptions = opts,
71− stTopLevel = True, stLastNested = False}
70+ stTopLevel = True }
72 evalStateT (pandocToRST document) st
71 evalStateT (pandocToRST document) st
74-- | Return RST representation of document.
73-- | Return RST representation of document.
@@ -353,33 +352,26 @@ blockListToRST' :: PandocMonad m
353 -> [Block] -- ^ List of block elements
352 -> [Block] -- ^ List of block elements
354 -> RST m Doc
353 -> RST m Doc
355blockListToRST' topLevel blocks = do
354blockListToRST' 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
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
366+ commentSep = RawBlock "rst" "..\n\n"
367+ fixBlocks (b:bs) = b : fixBlocks bs
356 tl <- gets stTopLevel
369 tl <- gets stTopLevel
357− modify (\s->s{stTopLevel=topLevel, stLastNested=False})
370+ modify (\s->s{stTopLevel=topLevel})
358− res <- vcat `fmap` mapM blockToRST' blocks
371+ res <- vcat `fmap` mapM blockToRST (fixBlocks blocks)
359 modify (\s->s{stTopLevel=tl})
372 modify (\s->s{stTopLevel=tl})
360 return res
373 return res
362−blockToRST' :: PandocMonad m => Block -> RST m Doc
363−blockToRST' (x@BlockQuote{}) = do
364− lastNested <- gets stLastNested
366− modify (\s -> s{stLastNested = True})
367− return $ if lastNested
371− modify (\s -> s{stLastNested =
373− Para [Image _ _ (_,'f':'i':'g':':':_)] -> True
377− LineBlock{} -> False
378− HorizontalRule -> False
383blockListToRST :: PandocMonad m
375blockListToRST :: PandocMonad m
384 => [Block] -- ^ List of block elements
376 => [Block] -- ^ List of block elements
385 -> RST m Doc
377 -> RST m Doc