Moved makeCanoncial definition out of ifdef!

Also added slide2 to the default pptx, and reordered
the data files in pandoc.cabal.
This commit is contained in:
John MacFarlane 2017-12-28 11:03:34 -08:00
parent 60ace79b03
commit d5770b7496
2 changed files with 25 additions and 23 deletions

View file

@ -105,28 +105,28 @@ data-files:
data/pptx/docProps/thumbnail.jpeg
data/pptx/docProps/app.xml
data/pptx/docProps/core.xml
data/pptx/ppt/slideLayouts/slideLayout4.xml
data/pptx/ppt/slideLayouts/_rels/slideLayout9.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout2.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout10.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout1.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout2.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout3.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout4.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout5.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout6.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout7.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout8.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout9.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout10.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout11.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout4.xml.rels
data/pptx/ppt/slideLayouts/_rels/slideLayout6.xml.rels
data/pptx/ppt/slideLayouts/slideLayout2.xml
data/pptx/ppt/slideLayouts/slideLayout8.xml
data/pptx/ppt/slideLayouts/slideLayout11.xml
data/pptx/ppt/slideLayouts/slideLayout3.xml
data/pptx/ppt/slideLayouts/slideLayout6.xml
data/pptx/ppt/slideLayouts/slideLayout9.xml
data/pptx/ppt/slideLayouts/slideLayout5.xml
data/pptx/ppt/slideLayouts/slideLayout7.xml
data/pptx/ppt/slideLayouts/slideLayout1.xml
data/pptx/ppt/slideLayouts/slideLayout2.xml
data/pptx/ppt/slideLayouts/slideLayout3.xml
data/pptx/ppt/slideLayouts/slideLayout4.xml
data/pptx/ppt/slideLayouts/slideLayout5.xml
data/pptx/ppt/slideLayouts/slideLayout6.xml
data/pptx/ppt/slideLayouts/slideLayout7.xml
data/pptx/ppt/slideLayouts/slideLayout8.xml
data/pptx/ppt/slideLayouts/slideLayout9.xml
data/pptx/ppt/slideLayouts/slideLayout10.xml
data/pptx/ppt/slideLayouts/slideLayout11.xml
data/pptx/ppt/_rels/presentation.xml.rels
data/pptx/ppt/theme/theme1.xml
data/pptx/ppt/presProps.xml

View file

@ -688,8 +688,6 @@ getDefaultReferencePptx = do
, "ppt/presProps.xml"
, "ppt/presentation.xml"
, "ppt/slideLayouts/_rels/slideLayout1.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout10.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout11.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout2.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout3.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout4.xml.rels"
@ -698,6 +696,8 @@ getDefaultReferencePptx = do
, "ppt/slideLayouts/_rels/slideLayout7.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout8.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout9.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout10.xml.rels"
, "ppt/slideLayouts/_rels/slideLayout11.xml.rels"
, "ppt/slideLayouts/slideLayout1.xml"
, "ppt/slideLayouts/slideLayout10.xml"
, "ppt/slideLayouts/slideLayout11.xml"
@ -713,6 +713,8 @@ getDefaultReferencePptx = do
, "ppt/slideMasters/slideMaster1.xml"
, "ppt/slides/_rels/slide1.xml.rels"
, "ppt/slides/slide1.xml"
, "ppt/slides/_rels/slide2.xml.rels"
, "ppt/slides/slide2.xml"
, "ppt/tableStyles.xml"
, "ppt/theme/theme1.xml"
, "ppt/viewProps.xml"
@ -766,13 +768,6 @@ readDefaultDataFile fname =
getDataFileName fname' >>= checkExistence >>= readFileStrict
where fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
makeCanonical :: FilePath -> FilePath
makeCanonical = Posix.joinPath . transformPathParts . splitDirectories
where transformPathParts = reverse . foldl go []
go as "." = as
go (_:as) ".." = as
go as x = x : as
checkExistence :: PandocMonad m => FilePath -> m FilePath
checkExistence fn = do
exists <- fileExists fn
@ -781,6 +776,13 @@ checkExistence fn = do
else throwError $ PandocCouldNotFindDataFileError fn
#endif
makeCanonical :: FilePath -> FilePath
makeCanonical = Posix.joinPath . transformPathParts . splitDirectories
where transformPathParts = reverse . foldl go []
go as "." = as
go (_:as) ".." = as
go as x = x : as
withPaths :: PandocMonad m => [FilePath] -> (FilePath -> m a) -> FilePath -> m a
withPaths [] _ fp = throwError $ PandocResourceNotFound fp
withPaths (p:ps) action fp =