diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-10-18 22:00:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-18 22:00:58 +0200 |
commit | 0cd11b3e5404fa6fca7538098bcf315343d1a237 (patch) | |
tree | 39057cfcb282e2e7b901dc12510ecffc3baad25b /src/Text/Pandoc/Shared.hs | |
parent | 8264ae2abe976184086a5a40c3d082f5e3e99ca5 (diff) | |
parent | 4417e33ea9d49a2001091adb4d2b19ebdefe5795 (diff) |
Merge pull request #3165 from hubertp-lshift/feature/odt-image
[odt] images parser
Diffstat (limited to 'src/Text/Pandoc/Shared.hs')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 407ff97db..4c10a5572 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -68,6 +68,7 @@ module Text.Pandoc.Shared ( Element (..), hierarchicalize, uniqueIdent, + inlineListToIdentifier, isHeaderBlock, headerShift, isTightList, @@ -85,6 +86,7 @@ module Text.Pandoc.Shared ( fetchItem', openURL, collapseFilePath, + filteredFilesFromArchive, -- * Error handling err, warn, @@ -111,6 +113,7 @@ import System.Exit (exitWith, ExitCode(..)) import Data.Char ( toLower, isLower, isUpper, isAlpha, isLetter, isDigit, isSpace ) import Data.List ( find, stripPrefix, intercalate ) +import Data.Maybe (mapMaybe) import Data.Version ( showVersion ) import qualified Data.Map as M import Network.URI ( escapeURIString, nonStrictRelativeTo, @@ -1031,6 +1034,16 @@ collapseFilePath = Posix.joinPath . reverse . foldl go [] . splitDirectories isSingleton _ = Nothing checkPathSeperator = fmap isPathSeparator . isSingleton +-- +-- File selection from the archive +-- +filteredFilesFromArchive :: Archive -> (FilePath -> Bool) -> [(FilePath, BL.ByteString)] +filteredFilesFromArchive zf f = + mapMaybe (fileAndBinary zf) (filter f (filesInArchive zf)) + where + fileAndBinary :: Archive -> FilePath -> Maybe (FilePath, BL.ByteString) + fileAndBinary a fp = findEntryByPath fp a >>= \e -> Just (fp, fromEntry e) + --- --- Squash blocks into inlines --- |