git.iko.soy/typeable/pandoc
on master help sign in
in RST writer insert comment between lists and quotes, closes #4248
2165efedanse
src/Text/Pandoc/Writers/RST.hs+12−1
@@ -353,9 +353,20 @@ blockListToRST' :: PandocMonad m
353 -> [Block] -- ^ List of block elements
353 -> [Block] -- ^ List of block elements
354 -> RST m Doc
354 -> RST m Doc
355blockListToRST' topLevel blocks = do
355blockListToRST' topLevel blocks = do
356+ -- insert comment between list and quoted blocks, see #4248
357+ let fixBlocks (b1:b2@(BlockQuote _):bs)
358+ | isList b1 = b1 : commentSep : b2 : fixBlocks bs
359+ where
360+ isList (BulletList _) = True
361+ isList (OrderedList _ _) = True
362+ isList (DefinitionList _) = True
363+ isList _ = False
364+ commentSep = RawBlock "rst" ""
365+ fixBlocks (b:bs) = b : fixBlocks bs
366+ fixBlocks [] = []
356 tl <- gets stTopLevel
367 tl <- gets stTopLevel
357 modify (\s->s{stTopLevel=topLevel, stLastNested=False})
368 modify (\s->s{stTopLevel=topLevel, stLastNested=False})
358− res <- vcat `fmap` mapM blockToRST' blocks
369+ res <- vcat `fmap` mapM blockToRST' (fixBlocks blocks)
359 modify (\s->s{stTopLevel=tl})
370 modify (\s->s{stTopLevel=tl})
360 return res
371 return res
361
372
test/Tests/Writers/RST.hs+10
@@ -40,6 +40,16 @@ tests = [ testGroup "rubrics"
40 , " :name: foo"
40 , " :name: foo"
41 , " :class: baz"]
41 , " :class: baz"]
42 ]
42 ]
43+ , testGroup "ligatures" -- handling specific sequences of blocks
44+ [ "a list is closed by a comment before a quote" =: -- issue 4248
45+ bulletList [plain "bulleted"] <> blockQuote (plain "quoted") =?>
46+ unlines
47+ [ "- bulleted"
48+ , ""
49+ , ".."
50+ , ""
51+ , " quoted"]
52+ ]
43 , testGroup "headings"
53 , testGroup "headings"
44 [ "normal heading" =:
54 [ "normal heading" =:
45 header 1 (text "foo") =?>
55 header 1 (text "foo") =?>