git.iko.soy/typeable/pandoc
on master help sign in
in RST writer insert comment between lists and quotes, closes #4248
commit2165efef7e3608b5c8e7f144b4f3884635410bc5 authordanse <f.occhipinti@gmail.com> dateMon 15 Jan 2018, 12:24 (9 years ago) parent01499b7
2 files changed+22−1
src/Text/Pandoc/Writers/RST.hs+12−1 test/Tests/Writers/RST.hs+10
src/Text/Pandoc/Writers/RST.hs+12−1
@@ -353,9 +353,20 @@ blockListToRST' :: PandocMonad m
353353 -> [Block] -- ^ List of block elements
354354 -> RST m Doc
355355blockListToRST' 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 [] = []
356367 tl <- gets stTopLevel
357368 modify (\s->s{stTopLevel=topLevel, stLastNested=False})
358− res <- vcat `fmap` mapM blockToRST' blocks
369+ res <- vcat `fmap` mapM blockToRST' (fixBlocks blocks)
359370 modify (\s->s{stTopLevel=tl})
360371 return res
361372
test/Tests/Writers/RST.hs+10
@@ -40,6 +40,16 @@ tests = [ testGroup "rubrics"
4040 , " :name: foo"
4141 , " :class: baz"]
4242 ]
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+ ]
4353 , testGroup "headings"
4454 [ "normal heading" =:
4555 header 1 (text "foo") =?>