RST writer: preserve empty inline parents in flatten (#4603)
This commit is contained in:
parent
245c8d92ec
commit
8b01f03eaa
2 changed files with 8 additions and 2 deletions
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue