@@ -342,15 +342,15 @@ writeEPUB opts doc@(Pandoc meta _) = do
342342 let tpEntry = mkEntry "title_page.xhtml" tpContent
343343
344344 -- handle pictures
345− picsRef <- newIORef []
346− Pandoc _ blocks <- walkM (transformInline opts' picsRef) doc >>=
347− walkM (transformBlock opts' picsRef)
348− pics <- readIORef picsRef
345+ mediaRef <- newIORef []
346+ Pandoc _ blocks <- walkM (transformInline opts' mediaRef) doc >>=
347+ walkM (transformBlock opts' mediaRef)
348+ pics <- readIORef mediaRef
349349 let readPicEntry entries (oldsrc, newsrc) = do
350350 res <- fetchItem (writerSourceURL opts') oldsrc
351351 case res of
352352 Left _ -> do
353− warn $ "Could not find image `" ++ oldsrc ++ "', skipping..."
353+ warn $ "Could not find media `" ++ oldsrc ++ "', skipping..."
354354 return entries
355355 Right (img,_) -> return $
356356 (toEntry newsrc epochtime $ B.fromChunks . (:[]) $ img) : entries
@@ -440,7 +440,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
440440 [("id", takeBaseName $ eRelativePath ent),
441441 ("href", eRelativePath ent),
442442 ("media-type", fromMaybe "application/octet-stream"
443− $ imageTypeOf $ eRelativePath ent)] $ ()
443+ $ mediaTypeOf $ eRelativePath ent)] $ ()
444444 let fontNode ent = unode "item" !
445445 [("id", takeBaseName $ eRelativePath ent),
446446 ("href", eRelativePath ent),
@@ -717,54 +717,54 @@ showDateTimeISO8601 :: UTCTime -> String
717717showDateTimeISO8601 = formatTime defaultTimeLocale "%FT%TZ"
718718
719719transformTag :: WriterOptions
720− -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images
720+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
721721 -> Tag String
722722 -> IO (Tag String)
723−transformTag opts picsRef tag@(TagOpen "video" attr) = do
723+transformTag opts mediaRef tag@(TagOpen name attr)
724+ | name == "video" || name == "source" = do
724725 let src = fromAttrib "src" tag
725726 let poster = fromAttrib "poster" tag
726727 let oldsrc = maybe src (</> src) $ writerSourceURL opts
727728 let oldposter = maybe poster (</> poster) $ writerSourceURL opts
728− newsrc <- modifyPicsRef picsRef oldsrc
729− newposter <- modifyPicsRef picsRef oldposter
729+ newsrc <- modifyMediaRef mediaRef oldsrc
730+ newposter <- modifyMediaRef mediaRef oldposter
730731 let attr' = filter (\(x,_) -> x /= "src" && x /= "poster") attr ++
731732 [("src", newsrc) | not (null newsrc)] ++
732733 [("poster", newposter) | not (null newposter)]
733− return $ TagOpen "video" attr'
734+ return $ TagOpen name attr'
734735transformTag _ _ tag = return tag
735736
736−modifyPicsRef :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath
737−modifyPicsRef _ "" = return ""
738−modifyPicsRef picsRef oldsrc = do
739− pics <- readIORef picsRef
740− case lookup oldsrc pics of
737+modifyMediaRef :: IORef [(FilePath, FilePath)] -> FilePath -> IO FilePath
738+modifyMediaRef _ "" = return ""
739+modifyMediaRef mediaRef oldsrc = do
740+ media <- readIORef mediaRef
741+ case lookup oldsrc media of
741742 Just n -> return n
742743 Nothing -> do
743− let new = "images/img" ++ show (length pics) ++
744+ let new = "media/file" ++ show (length media) ++
744745 takeExtension oldsrc
745− modifyIORef picsRef ( (oldsrc, new): )
746+ modifyIORef mediaRef ( (oldsrc, new): )
746747 return new
747748
748749transformBlock :: WriterOptions
749− -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images
750+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
750751 -> Block
751752 -> IO Block
752−transformBlock opts picsRef (RawBlock fmt raw)
753+transformBlock opts mediaRef (RawBlock fmt raw)
753754 | fmt == Format "html" = do
754755 let tags = parseTags raw
755− -- look for video tags and add poster and src to images
756− tags' <- mapM (transformTag opts picsRef) tags
756+ tags' <- mapM (transformTag opts mediaRef) tags
757757 return $ RawBlock fmt (renderTags tags')
758758transformBlock _ _ b = return b
759759
760760transformInline :: WriterOptions
761− -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) images
761+ -> IORef [(FilePath, FilePath)] -- ^ (oldpath, newpath) media
762762 -> Inline
763763 -> IO Inline
764−transformInline opts picsRef (Image lab (src,tit)) = do
764+transformInline opts mediaRef (Image lab (src,tit)) = do
765765 let src' = unEscapeString src
766766 let oldsrc = maybe src' (</> src) $ writerSourceURL opts
767− newsrc <- modifyPicsRef picsRef oldsrc
767+ newsrc <- modifyMediaRef mediaRef oldsrc
768768 return $ Image lab (newsrc, tit)
769769transformInline opts _ (x@(Math _ _))
770770 | WebTeX _ <- writerHTMLMathMethod opts = do
@@ -794,10 +794,11 @@ ppTopElement = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ++) . unEntity .
794794 Nothing -> '&':'#':unEntity xs
795795 unEntity (x:xs) = x : unEntity xs
796796
797−imageTypeOf :: FilePath -> Maybe String
798−imageTypeOf x = case getMimeType x of
797+mediaTypeOf :: FilePath -> Maybe String
798+mediaTypeOf x = case getMimeType x of
799799 Just y@('i':'m':'a':'g':'e':_) -> Just y
800800 Just y@('v':'i':'d':'e':'o':_) -> Just y
801+ Just y@('a':'u':'d':'i':'o':_) -> Just y
801802 _ -> Nothing
802803
803804data IdentState = IdentState{