mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-24 15:44:59 +08:00
RST writer: preserve empty inline parents in flatten (#4603)
This commit is contained in:
committed by
John MacFarlane
parent
245c8d92ec
commit
8b01f03eaa
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user