RST writer: preserve empty inline parents in flatten (#4603)

This commit is contained in:
Francesco Occhipinti 2018-04-27 18:01:20 +02:00 committed by John MacFarlane
parent 245c8d92ec
commit 8b01f03eaa
2 changed files with 8 additions and 2 deletions

View file

@ -457,8 +457,11 @@ transformInlines = insertBS .
-- them either collapsing them in the outer inline container or
-- pulling them out of it
flatten :: Inline -> [Inline]
flatten outer = combineAll $ dropInlineParent outer
where combineAll = foldl combine []
flatten outer
| null contents = [outer]
| otherwise = combineAll contents
where contents = dropInlineParent outer
combineAll = foldl combine []
combine :: [Inline] -> Inline -> [Inline]
combine f i =

View file

@ -64,6 +64,9 @@ tests = [ testGroup "rubrics"
-- the test above is the reason why we call
-- stripLeadingTrailingSpace through transformNested after
-- flatten
, testCase "preserves empty parents" $
flatten (Image ("",[],[]) [] ("loc","title")) @?=
[Image ("",[],[]) [] ("loc","title")]
]
, testGroup "inlines"
[ "are removed when empty" =: -- #4434