@@ -46,6 +46,7 @@ import Text.XHtml.Transitional hiding ( stringToHtml, unordList, ordList )
4646import qualified Text.XHtml.Transitional as XHtml
4747import Text.TeXMath
4848import Text.XML.Light.Output
49+import System.FilePath (takeExtension)
4950
5051data WriterState = WriterState
5152 { stNotes :: [Html] -- ^ List of notes
@@ -320,6 +321,17 @@ attrsToHtml opts (id',classes',keyvals) =
320321 [prefixedId opts id' | not (null id')] ++
321322 map (\(x,y) -> strAttr x y) keyvals
322323
324+imageExts :: [String]
325+imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf",
326+ "gif", "ico", "ief", "jng", "jpg", "jpeg", "nef", "orf", "pat", "pbm",
327+ "pcx", "pgm", "png", "pnm", "ppm", "psd", "ras", "rgb", "svg", "tiff",
328+ "wbmp", "xbm", "xpm", "xwd" ]
329+
330+treatAsImage :: FilePath -> Bool
331+treatAsImage fp =
332+ let ext = map toLower $ drop 1 $ takeExtension fp
333+ in null ext || ext `elem` imageExts
334+
323335-- | Convert Pandoc block element to HTML.
324336blockToHtml :: WriterOptions -> Block -> State WriterState Html
325337blockToHtml _ Null = return noHtml
@@ -603,7 +615,7 @@ inlineToHtml opts inline =
603615 return $ anchor ! ([href s] ++
604616 if null tit then [] else [title tit]) $
605617 linkText
606− (Image txt (s,tit)) -> do
618+ (Image txt (s,tit)) | treatAsImage s -> do
607619 let alternate' = stringify txt
608620 let attributes = [src s] ++
609621 (if null tit
@@ -614,6 +626,13 @@ inlineToHtml opts inline =
614626 else [alt alternate']
615627 return $ image ! attributes
616628 -- note: null title included, as in Markdown.pl
629+ (Image _ (s,tit)) -> do
630+ let attributes = [src s] ++
631+ (if null tit
632+ then []
633+ else [title tit])
634+ return $ itag "embed" ! attributes
635+ -- note: null title included, as in Markdown.pl
617636 (Note contents) -> do
618637 st <- get
619638 let notes = stNotes st