diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-04-26 12:04:08 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-04-26 12:04:08 -0700 |
commit | 35ea8de3690fcd9bf06532576ced4d82fd51f26d (patch) | |
tree | 2ee01e0e29668850b29ccec6916917a4979b915c | |
parent | 2b3926d63a74b5b9ff9c61181608a6fac30968d8 (diff) | |
download | pandoc-35ea8de3690fcd9bf06532576ced4d82fd51f26d.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index e0385af25..1de4345f9 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -40,6 +40,7 @@ import Text.Pandoc.Slides import Text.Pandoc.Highlighting ( highlight, styleToCss, formatHtmlInline, formatHtmlBlock ) import Text.Pandoc.XML (fromEntities, escapeStringForXML) +import Network.URI ( parseURIReference, URI(..) ) import Network.HTTP ( urlEncode ) import Numeric ( showHex ) import Data.Char ( ord, toLower ) @@ -396,7 +397,10 @@ imageExts = [ "art", "bmp", "cdr", "cdt", "cpt", "cr2", "crw", "djvu", "erf", treatAsImage :: FilePath -> Bool treatAsImage fp = - let ext = map toLower $ drop 1 $ takeExtension fp + let path = case uriPath `fmap` parseURIReference fp of + Nothing -> fp + Just up -> up + ext = map toLower $ drop 1 $ takeExtension path in null ext || ext `elem` imageExts -- | Convert Pandoc block element to HTML. |