pCSSUrl :: MediaBag -> Maybe String -> FilePath
        -> ParsecT ByteString () IO ByteString
pCSSUrl media sourceURL d = P.try $ do
  P.string "url("
  P.spaces
  quote <- P.option Nothing (Just <$> P.oneOf "\"'")
  url <- P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)
  P.spaces
  P.char ')'
  let fallback = B.pack ("url(" ++ maybe "" (:[]) quote ++ trim url ++
                            maybe "" (:[]) quote ++ ")")
  case trim url of
      '#':_ -> return fallback
      'd':'a':'t':'a':':':_ -> return fallback
      u ->  do let url' = if isURI u then u else d </> u
               enc <- lift $ getDataURI media sourceURL "" url'
               return (B.pack enc)
pCSSUrl :: MediaBag -> Maybe String -> FilePath
        -> ParsecT ByteString () IO ByteString
pCSSUrl media sourceURL d = P.try $ do
  P.string "url("
  P.spaces
  quote <- P.option Nothing (Just <$> P.oneOf "\"'")
  url <- P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)
  P.spaces
  P.char ')'
  let fallback = B.pack ("url(" ++ maybe "" (:[]) quote ++ trim url ++
                            maybe "" (:[]) quote ++ ")")
  case trim url of
      '#':_ -> return fallback
      'd':'a':'t':'a':':':_ -> return fallback
      u ->  do let url' = if isURI u then u else d </> u
               enc <- lift $ getDataURI media sourceURL "" url'
               return (B.pack enc)
pCSSUrl media sourceURL d = P.try $ do
  P.string "url("
  P.spaces
  quote <- P.option Nothing (Just <$> P.oneOf "\"'")
  url <- P.manyTill P.anyChar (maybe (P.lookAhead (P.char ')')) P.char quote)
  P.spaces
  P.char ')'
  let fallback = B.pack ("url(" ++ maybe "" (:[]) quote ++ trim url ++
                            maybe "" (:[]) quote ++ ")")
  case trim url of
      '#':_ -> return fallback
      'd':'a':'t':'a':':':_ -> return fallback
      u ->  do let url' = if isURI u then u else d </> u
               enc <- lift $ getDataURI media sourceURL "" url'
               return (B.pack enc)