summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/MIME.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/MIME.hs')
-rw-r--r--src/Text/Pandoc/MIME.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Text/Pandoc/MIME.hs b/src/Text/Pandoc/MIME.hs
index eb54bd48d..d9cb94a33 100644
--- a/src/Text/Pandoc/MIME.hs
+++ b/src/Text/Pandoc/MIME.hs
@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Mime type lookup for ODT writer.
-}
-module Text.Pandoc.MIME ( getMimeType )
+module Text.Pandoc.MIME ( getMimeType, extensionFromMimeType )
where
import System.FilePath
import Data.Char ( toLower )
@@ -37,7 +37,14 @@ import qualified Data.Map as M
getMimeType :: FilePath -> Maybe String
getMimeType "layout-cache" = Just "application/binary" -- in ODT
getMimeType f = M.lookup (map toLower $ drop 1 $ takeExtension f) mimeTypes
- where mimeTypes = M.fromList -- List borrowed from happstack-server.
+ where mimeTypes = M.fromList mimeTypesList
+
+extensionFromMimeType :: String -> Maybe String
+extensionFromMimeType mimetype = M.lookup mimetype reverseMimeTypes
+ where reverseMimeTypes = M.fromList $ map (\(k,v) -> (v,k)) mimeTypesList
+
+mimeTypesList :: [(String, String)]
+mimeTypesList = -- List borrowed from happstack-server.
[("gz","application/x-gzip")
,("cabal","application/x-cabal")
,("%","application/x-trash")