mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-25 09:47:06 +00:00
Use uriPathToPath with file: URIs.
Closes #4613. Needs testing on Windows.
This commit is contained in:
@@ -93,7 +93,7 @@ import Text.Pandoc.Highlighting (highlightingStyles)
|
||||
import Text.Pandoc.PDF (makePDF)
|
||||
import Text.Pandoc.SelfContained (makeDataURI, makeSelfContained)
|
||||
import Text.Pandoc.Shared (eastAsianLineBreakFilter, stripEmptyParagraphs,
|
||||
headerShift, isURI, ordNub, safeRead, tabFilter)
|
||||
headerShift, isURI, ordNub, safeRead, tabFilter, uriPathToPath)
|
||||
import qualified Text.Pandoc.UTF8 as UTF8
|
||||
import Text.Pandoc.Writers.Math (defaultKaTeXURL, defaultMathJaxURL)
|
||||
import Text.Pandoc.XML (toEntities)
|
||||
@@ -795,7 +795,7 @@ readSource src = case parseURI src of
|
||||
readURI src
|
||||
| uriScheme u == "file:" ->
|
||||
liftIO $ UTF8.toText <$>
|
||||
BS.readFile (uriPath u)
|
||||
BS.readFile (uriPathToPath $ uriPath u)
|
||||
_ -> liftIO $ UTF8.toText <$>
|
||||
BS.readFile src
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ import qualified Text.Pandoc.UTF8 as UTF8
|
||||
import qualified System.Directory as Directory
|
||||
import Data.Time (UTCTime)
|
||||
import Text.Pandoc.Logging
|
||||
import Text.Pandoc.Shared (uriPathToPath)
|
||||
import Text.Parsec (ParsecT, getPosition, sourceLine, sourceName)
|
||||
import qualified Data.Time as IO (getCurrentTime)
|
||||
import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
|
||||
@@ -598,7 +599,7 @@ downloadOrRead s = do
|
||||
-- We don't want to treat C:/ as a scheme:
|
||||
Just u' | length (uriScheme u') > 2 -> openURL (show u')
|
||||
Just u' | uriScheme u' == "file:" ->
|
||||
readLocalFile $ dropWhile (=='/') (uriPath u')
|
||||
readLocalFile $ uriPathToPath (uriPath u')
|
||||
_ -> readLocalFile fp -- get from local file system
|
||||
where readLocalFile f = do
|
||||
resourcePath <- getResourcePath
|
||||
|
||||
Reference in New Issue
Block a user