@@ -33,8 +33,7 @@ import Data.Version (showVersion)
3333
3434import Paths_pandoc_plot (version )
3535
36- import System.FilePath (makeValid )
37- import System.Directory (canonicalizePath )
36+ import System.FilePath (makeValid , normalise )
3837
3938import Text.Pandoc.Definition (Block (.. ), Inline ,
4039 Pandoc (.. ), Format (.. ))
@@ -90,8 +89,8 @@ parseFigureSpec block@(CodeBlock (id', classes, attrs) _) =
9089 extraAttrs = Map. toList extraAttrs'
9190 blockAttrs = (id', filter (/= cls toolkit) classes, filteredAttrs)
9291
93- blockDependencies <- parseFileDependencies $ fromMaybe mempty $ Map. lookup (tshow DependenciesK ) attrs'
94- let dependencies = (defaultDependencies conf) <> blockDependencies
92+ let blockDependencies = parseFileDependencies $ fromMaybe mempty $ Map. lookup (tshow DependenciesK ) attrs'
93+ dependencies = (defaultDependencies conf) <> blockDependencies
9594
9695 -- This is the first opportunity to check save format compatibility
9796 let saveFormatSupported = saveFormat `elem` (supportedSaveFormats toolkit)
@@ -110,7 +109,7 @@ parseFigureSpec _ = return Nothing
110109parseContent :: Block -> PlotM Script
111110parseContent (CodeBlock (_, _, attrs) content) = do
112111 let attrs' = Map. fromList attrs
113- mfile <- liftIO $ sequence $ fmap canonicalizePath $ unpack <$> Map. lookup (tshow FileK ) attrs'
112+ mfile = unpack <$> Map. lookup (tshow FileK ) attrs'
114113 when (content /= mempty && isJust mfile) $ do
115114 err $ mconcat [
116115 " Figure refers to a file (" , pack $ fromJust mfile
@@ -157,10 +156,11 @@ readBool s | s `elem` ["True", "true", "'True'", "'true'", "1"] = True
157156
158157
159158-- | Parse a list of file dependencies such as /[foo.bar, hello.txt]/.
160- parseFileDependencies :: Text -> PlotM [FilePath ]
159+ parseFileDependencies :: Text -> [FilePath ]
161160parseFileDependencies t
162- | t == mempty = return mempty
163- | otherwise = sequence $
164- fmap (liftIO . canonicalizePath . unpack . T. dropAround isSpace)
165- . T. splitOn " ,"
166- . T. dropAround (\ c -> c `elem` [' [' , ' ]' ]) $ t
161+ | t == mempty = mempty
162+ | otherwise = fmap normalise
163+ . fmap unpack
164+ . fmap (T. dropAround isSpace) -- Remove leading/trailing whitespace on filenames
165+ . T. splitOn " ,"
166+ . T. dropAround (\ c -> c `elem` [' [' , ' ]' ]) $ t
0 commit comments