Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PandocMonad: allow nested data files #8822

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/Text/Pandoc/Class/PandocMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,19 @@ findFileWithDataFallback subdir fp = do
existsInWorkingDir <- fileExists fp
if existsInWorkingDir
then return $ Just fp
else do
mbDataDir <- checkUserDataDir fp
case mbDataDir of
Nothing -> return Nothing
Just datadir -> do
let datafp = datadir </> subdir </> fp
existsInDataDir <- fileExists datafp
return $ if existsInDataDir
then Just datafp
else Nothing
else checkUserDataDir fp >>= findInDataDir
where
findInDataDir Nothing = pure Nothing
findInDataDir (Just datadir) = do
let datafp = datadir </> subdir </> fp
let nested = datadir </> subdir </> dropExtension fp </> fp
existsInDataDir <- fileExists datafp
nestedInDataDir <- fileExists nested
return $
case () of
_ | existsInDataDir -> Just datafp
_ | nestedInDataDir -> Just nested
_ -> Nothing

-- | Traverse tree, filling media bag for any images that
-- aren't already in the media bag.
Expand Down