aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2018-01-03 17:51:29 -0500
committerJesse Rosenthal <jrosenthal@jhu.edu>2018-01-03 17:54:43 -0500
commit101aece6cc03eb8dc434f2ff23bd4d66198fb592 (patch)
treea8ef507e45c3a3dbf36d9c0b82fb4f00b835d349 /src
parent02d85469abcb06f10b22ef461e2152c84f12394b (diff)
downloadpandoc-101aece6cc03eb8dc434f2ff23bd4d66198fb592.tar.gz
Powerpoint writer: combine adjacent runs.
This will make the xml easier to read for debugging purposes. It should also make links behave more consistently across numerous words.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/Powerpoint.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Powerpoint.hs b/src/Text/Pandoc/Writers/Powerpoint.hs
index 13542e78f..cac3a0af9 100644
--- a/src/Text/Pandoc/Writers/Powerpoint.hs
+++ b/src/Text/Pandoc/Writers/Powerpoint.hs
@@ -56,7 +56,7 @@ import Text.Pandoc.Walk
import Text.Pandoc.Writers.Shared (fixDisplayMath)
import Text.Pandoc.Writers.OOXML
import qualified Data.Map as M
-import Data.Maybe (mapMaybe, listToMaybe)
+import Data.Maybe (mapMaybe, listToMaybe, maybeToList)
import Text.Pandoc.ImageSize
import Control.Applicative ((<|>))
@@ -1200,7 +1200,7 @@ paragraphToElement par = do
[mknode "a:buAutoNum" [("type", autoNumberingToType attrs')] ()]
Nothing -> [mknode "a:buNone" [] ()]
)
- paras <- mapM paraElemToElement (paraElems par)
+ paras <- mapM paraElemToElement (combineParaElems $ paraElems par)
return $ mknode "a:p" [] $ [mknode "a:pPr" attrs props] ++ paras
shapeToElement :: PandocMonad m => Element -> Shape -> P m Element
@@ -1758,3 +1758,20 @@ getContentType fp
| "ppt" : "slideLayouts" : _ : [] <- splitDirectories fp=
Just $ presML ++ ".slideLayout+xml"
| otherwise = Nothing
+
+-------------------------------------------------------
+
+combineParaElems' :: Maybe ParaElem -> [ParaElem] -> [ParaElem]
+combineParaElems' mbPElem [] = maybeToList mbPElem
+combineParaElems' Nothing (pElem : pElems) =
+ combineParaElems' (Just pElem) pElems
+combineParaElems' (Just pElem') (pElem : pElems)
+ | Run rPr' s' <- pElem'
+ , Run rPr s <- pElem
+ , rPr == rPr' =
+ combineParaElems' (Just $ Run rPr' $ s' ++ s) pElems
+ | otherwise =
+ pElem' : combineParaElems' (Just pElem) pElems
+
+combineParaElems :: [ParaElem] -> [ParaElem]
+combineParaElems = combineParaElems' Nothing