git.iko.soy/typeable/pandoc
on master help sign in
HTML writer: improved detection of image links.

Previously image links with queries were not recognized, leading to use of an embed tag rather than an img tag.

commit35ea8de3690fcd9bf06532576ced4d82fd51f26d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 26 Apr 2014, 12:04 (13 years ago) parent2b3926d
1 file changed+5−1
src/Text/Pandoc/Writers/HTML.hs+5−1
src/Text/Pandoc/Writers/HTML.hs+5−1
@@ -40,6 +40,7 @@ import Text.Pandoc.Slides
4040import Text.Pandoc.Highlighting ( highlight, styleToCss,
4141 formatHtmlInline, formatHtmlBlock )
4242import Text.Pandoc.XML (fromEntities, escapeStringForXML)
43+import Network.URI ( parseURIReference, URI(..) )
4344import Network.HTTP ( urlEncode )
4445import Numeric ( showHex )
4546import Data.Char ( ord, toLower )
@@ -396,7 +397,10 @@ imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf",
396397
397398treatAsImage :: FilePath -> Bool
398399treatAsImage fp =
399− let ext = map toLower $ drop 1 $ takeExtension fp
400+ let path = case uriPath `fmap` parseURIReference fp of
401+ Nothing -> fp
402+ Just up -> up
403+ ext = map toLower $ drop 1 $ takeExtension path
400404 in null ext || ext `elem` imageExts
401405
402406-- | Convert Pandoc block element to HTML.