in RST writer insert comment between lists and quotes, closes #4248

This commit is contained in:
danse 2018-01-15 12:24:20 +01:00
parent 01499b766b
commit 2165efef7e
2 changed files with 22 additions and 1 deletions

View file

@ -353,9 +353,20 @@ blockListToRST' :: PandocMonad m
-> [Block] -- ^ List of block elements
-> RST m Doc
blockListToRST' topLevel blocks = do
-- insert comment between list and quoted blocks, see #4248
let fixBlocks (b1:b2@(BlockQuote _):bs)
| isList b1 = b1 : commentSep : b2 : fixBlocks bs
where
isList (BulletList _) = True
isList (OrderedList _ _) = True
isList (DefinitionList _) = True
isList _ = False
commentSep = RawBlock "rst" ""
fixBlocks (b:bs) = b : fixBlocks bs
fixBlocks [] = []
tl <- gets stTopLevel
modify (\s->s{stTopLevel=topLevel, stLastNested=False})
res <- vcat `fmap` mapM blockToRST' blocks
res <- vcat `fmap` mapM blockToRST' (fixBlocks blocks)
modify (\s->s{stTopLevel=tl})
return res

View file

@ -40,6 +40,16 @@ tests = [ testGroup "rubrics"
, " :name: foo"
, " :class: baz"]
]
, testGroup "ligatures" -- handling specific sequences of blocks
[ "a list is closed by a comment before a quote" =: -- issue 4248
bulletList [plain "bulleted"] <> blockQuote (plain "quoted") =?>
unlines
[ "- bulleted"
, ""
, ".."
, ""
, " quoted"]
]
, testGroup "headings"
[ "normal heading" =:
header 1 (text "foo") =?>