diff options
Diffstat (limited to 'src/Text/Pandoc/Writers/Powerpoint.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Powerpoint.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs index bf80b8afb..50b48fd87 100644 --- a/src/Text/Pandoc/Writers/Powerpoint.hs +++ b/src/Text/Pandoc/Writers/Powerpoint.hs @@ -820,16 +820,24 @@ getContentShape ns spTreeElem filterChild (\e -> (isElem ns "p" "sp" e) && (shapeHasName ns "Content Placeholder 2" e)) spTreeElem | otherwise = Nothing -contentIsElem :: NameSpaces -> String -> String -> Content -> Bool -contentIsElem ns prefix name (Elem element) = isElem ns prefix name element -contentIsElem _ _ _ _ = False - -replaceNamedChildren :: NameSpaces -> String -> String -> [Element] -> Element -> Element +replaceChildren :: (Element -> [Element]) -> Element -> Element +replaceChildren fun element = + element{elContent = concatMap fun' $ elContent element} + where fun' :: Content -> [Content] + fun' (Elem e) = map Elem $ fun e + fun' content = [content] + +replaceNamedChildren :: NameSpaces + -> String + -> String + -> [Element] + -> Element + -> Element replaceNamedChildren ns prefix name newKids element = - let content = elContent element - content' = filter (\c -> not (contentIsElem ns prefix name c)) content - in - element{elContent = content' ++ map Elem newKids} + let fun :: Element -> [Element] + fun e | isElem ns prefix name e = newKids + | otherwise = [e] + in replaceChildren fun element ---------------------------------------------------------------- |