mirror of
https://github.com/serokell/xrefcheck.git
synced 2024-10-03 17:07:53 +03:00
[#164] Use only '/' as path separator
Problem: in markdown links, '/' should always be used as path separator , e.g. GitHub renderer is not threating link `[x](a\b.md)` as a link to file in dir `a` We use OS-dependent file separators everywhere, so e.g. `canonizeLocalRef "./a.md"="./a.md`"` on Windows Solution: replace '\' to '/' while constructing repo tree if needed and then use only '/', preferring functions from `System.FilePath.Posix`. We can do this, since 'a/b' and `a\b` are equivalent paths on Windows
This commit is contained in:
parent
09783e0213
commit
aba295b478
@ -22,7 +22,7 @@ import Data.List qualified as L
|
||||
import Data.Reflection (Given)
|
||||
import Data.Text qualified as T
|
||||
import Fmt (Buildable (..))
|
||||
import System.FilePath (isPathSeparator, pathSeparator)
|
||||
import System.FilePath.Posix (isPathSeparator)
|
||||
import Text.Interpolation.Nyan
|
||||
import Time (Second, Time)
|
||||
|
||||
@ -339,7 +339,7 @@ canonizeLocalRef :: Text -> Text
|
||||
canonizeLocalRef ref =
|
||||
maybe ref canonizeLocalRef (T.stripPrefix localPrefix ref)
|
||||
where
|
||||
localPrefix = toText ['.', pathSeparator]
|
||||
localPrefix = "./"
|
||||
|
||||
-----------------------------------------------------------
|
||||
-- Visualisation
|
||||
|
@ -38,7 +38,7 @@ import Data.Map qualified as M
|
||||
import Data.Reflection (Given)
|
||||
import Fmt (Buildable (..), fmt)
|
||||
import System.Directory (doesDirectoryExist)
|
||||
import System.FilePath
|
||||
import System.FilePath.Posix
|
||||
(dropTrailingPathSeparator, equalFilePath, splitDirectories, takeDirectory, takeExtension, (</>))
|
||||
import System.Process (cwd, readCreateProcess, shell)
|
||||
import Text.Interpolation.Nyan
|
||||
|
@ -21,10 +21,9 @@ import Data.Coerce (coerce)
|
||||
import GHC.IO.Unsafe (unsafePerformIO)
|
||||
import System.Directory (canonicalizePath)
|
||||
import System.Environment (lookupEnv)
|
||||
import System.FilePath (isRelative, (</>))
|
||||
import System.FilePath.Glob (CompOptions (errorRecovery))
|
||||
import System.FilePath.Glob qualified as Glob
|
||||
import Text.Interpolation.Nyan
|
||||
import System.FilePath.Posix (isRelative, (</>))
|
||||
|
||||
import Xrefcheck.Util (normaliseWithNoTrailing)
|
||||
|
||||
@ -89,4 +88,4 @@ instance FromJSON RelGlobPattern where
|
||||
|
||||
-- | Glob compilation options we use.
|
||||
globCompileOptions :: Glob.CompOptions
|
||||
globCompileOptions = Glob.compDefault{errorRecovery = False}
|
||||
globCompileOptions = Glob.compDefault{Glob.errorRecovery = False}
|
||||
|
@ -27,7 +27,7 @@ import Data.Time (UTCTime)
|
||||
import Data.Time.Clock (nominalDiffTimeToSeconds)
|
||||
import Data.Time.Clock.POSIX (POSIXTime, utcTimeToPOSIXSeconds)
|
||||
import Fmt (Builder)
|
||||
import System.FilePath (dropTrailingPathSeparator, normalise)
|
||||
import System.FilePath.Posix (dropTrailingPathSeparator, normalise)
|
||||
import Time (Second, Time (..), sec)
|
||||
|
||||
import Xrefcheck.Util.Colorize
|
||||
|
@ -56,7 +56,7 @@ import Network.HTTP.Req
|
||||
HttpMethod, NoReqBody (..), defaultHttpConfig, ignoreResponse, req, runReq, useURI)
|
||||
import Network.HTTP.Types.Header (hRetryAfter)
|
||||
import Network.HTTP.Types.Status (Status, statusCode, statusMessage)
|
||||
import System.FilePath
|
||||
import System.FilePath.Posix
|
||||
(equalFilePath, joinPath, makeRelative, normalise, splitDirectories, takeDirectory, (</>))
|
||||
import Text.Interpolation.Nyan
|
||||
import Text.ParserCombinators.ReadPrec qualified as ReadPrec (lift)
|
||||
|
@ -13,7 +13,7 @@ extra-deps:
|
||||
- firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
|
||||
- cmark-gfm-0.2.5
|
||||
- git: https://github.com/serokell/nyan-interpolation
|
||||
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
|
||||
commit: 348355385466d6d0116251b463a2842ecce0360d
|
||||
subdirs:
|
||||
- full
|
||||
- core
|
||||
|
@ -19,7 +19,7 @@ packages:
|
||||
original:
|
||||
hackage: cmark-gfm-0.2.5
|
||||
- completed:
|
||||
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
|
||||
commit: 348355385466d6d0116251b463a2842ecce0360d
|
||||
git: https://github.com/serokell/nyan-interpolation
|
||||
name: nyan-interpolation
|
||||
pantry-tree:
|
||||
@ -28,20 +28,20 @@ packages:
|
||||
subdir: full
|
||||
version: '0.9'
|
||||
original:
|
||||
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
|
||||
commit: 348355385466d6d0116251b463a2842ecce0360d
|
||||
git: https://github.com/serokell/nyan-interpolation
|
||||
subdir: full
|
||||
- completed:
|
||||
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
|
||||
commit: 348355385466d6d0116251b463a2842ecce0360d
|
||||
git: https://github.com/serokell/nyan-interpolation
|
||||
name: nyan-interpolation-core
|
||||
pantry-tree:
|
||||
sha256: 59d1c732629b06d0035229dccce484d6b4c3078d6bb3e493317afddc9be233df
|
||||
sha256: 4802161ce5d38f895e3b5106c789bfbe20b8d12c2f6c5fcba3999bec105283bc
|
||||
size: 1516
|
||||
subdir: core
|
||||
version: '0.9'
|
||||
original:
|
||||
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
|
||||
commit: 348355385466d6d0116251b463a2842ecce0360d
|
||||
git: https://github.com/serokell/nyan-interpolation
|
||||
subdir: core
|
||||
snapshots:
|
||||
|
Loading…
Reference in New Issue
Block a user