aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-10-04 11:45:01 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-10-04 11:45:01 -0700
commit62f83aa48633af477913bde6f615fe9f8793901a (patch)
tree66ecb0856d4d2b642590b59bcb916ffe80f67d34 /src/Text/Pandoc/Writers
parent0088e79cf57fb9586e1596e2b97bdebb12667f6d (diff)
downloadpandoc-62f83aa48633af477913bde6f615fe9f8793901a.tar.gz
Powerpoint writer: consolidate text run nodes.
This should reduce the size of the generated files.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint/Presentation.hs10
1 files changed, 9 insertions, 1 deletions
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