From 62f83aa48633af477913bde6f615fe9f8793901a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Oct 2021 11:45:01 -0700 Subject: Powerpoint writer: consolidate text run nodes. This should reduce the size of the generated files. --- src/Text/Pandoc/Writers/Powerpoint/Presentation.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs index e3d31d099..1680bc7ac 100644 --- a/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs +++ b/src/Text/Pandoc/Writers/Powerpoint/Presentation.hs @@ -348,7 +348,15 @@ instance Default PicProps where -------------------------------------------------- inlinesToParElems :: [Inline] -> Pres [ParaElem] -inlinesToParElems ils = concatMapM inlineToParElems ils +inlinesToParElems = concatMapM inlineToParElems . consolidateStrs + where + -- we combine Str + Space combinations, because this makes + -- the resulting ooxml much more compact, with fewer independent + -- text run elements + consolidateStrs [] = [] + consolidateStrs (Str t : Space : ils) = consolidateStrs (Str (t <> " ") : ils) + consolidateStrs (Space : Str t : ils) = consolidateStrs (Str (" " <> t) : ils) + consolidateStrs (il : ils) = il : consolidateStrs ils inlineToParElems :: Inline -> Pres [ParaElem] inlineToParElems (Str s) = do -- cgit v1.2.3