Skip to content

Commit aba295b

Browse files
committed
[#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
1 parent 09783e0 commit aba295b

7 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎src/Xrefcheck/Core.hs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Data.List qualified as L
2222
import Data.Reflection (Given)
2323
import Data.Text qualified as T
2424
import Fmt (Buildable (..))
25-
import System.FilePath (isPathSeparator, pathSeparator)
25+
import System.FilePath.Posix (isPathSeparator)
2626
import Text.Interpolation.Nyan
2727
import Time (Second, Time)
2828

@@ -339,7 +339,7 @@ canonizeLocalRef :: Text -> Text
339339
canonizeLocalRef ref =
340340
maybe ref canonizeLocalRef (T.stripPrefix localPrefix ref)
341341
where
342-
localPrefix = toText ['.', pathSeparator]
342+
localPrefix = "./"
343343

344344
-----------------------------------------------------------
345345
-- Visualisation

‎src/Xrefcheck/Scan.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import Data.Map qualified as M
3838
import Data.Reflection (Given)
3939
import Fmt (Buildable (..), fmt)
4040
import System.Directory (doesDirectoryExist)
41-
import System.FilePath
41+
import System.FilePath.Posix
4242
(dropTrailingPathSeparator, equalFilePath, splitDirectories, takeDirectory, takeExtension, (</>))
4343
import System.Process (cwd, readCreateProcess, shell)
4444
import Text.Interpolation.Nyan

‎src/Xrefcheck/System.hs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ import Data.Coerce (coerce)
2121
import GHC.IO.Unsafe (unsafePerformIO)
2222
import System.Directory (canonicalizePath)
2323
import System.Environment (lookupEnv)
24-
import System.FilePath (isRelative, (</>))
25-
import System.FilePath.Glob (CompOptions (errorRecovery))
2624
import System.FilePath.Glob qualified as Glob
2725
import Text.Interpolation.Nyan
26+
import System.FilePath.Posix (isRelative, (</>))
2827

2928
import Xrefcheck.Util (normaliseWithNoTrailing)
3029

@@ -89,4 +88,4 @@ instance FromJSON RelGlobPattern where
8988

9089
-- | Glob compilation options we use.
9190
globCompileOptions :: Glob.CompOptions
92-
globCompileOptions = Glob.compDefault{errorRecovery = False}
91+
globCompileOptions = Glob.compDefault{Glob.errorRecovery = False}

‎src/Xrefcheck/Util.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Data.Time (UTCTime)
2727
import Data.Time.Clock (nominalDiffTimeToSeconds)
2828
import Data.Time.Clock.POSIX (POSIXTime, utcTimeToPOSIXSeconds)
2929
import Fmt (Builder)
30-
import System.FilePath (dropTrailingPathSeparator, normalise)
30+
import System.FilePath.Posix (dropTrailingPathSeparator, normalise)
3131
import Time (Second, Time (..), sec)
3232

3333
import Xrefcheck.Util.Colorize

‎src/Xrefcheck/Verify.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import Network.HTTP.Req
5656
HttpMethod, NoReqBody (..), defaultHttpConfig, ignoreResponse, req, runReq, useURI)
5757
import Network.HTTP.Types.Header (hRetryAfter)
5858
import Network.HTTP.Types.Status (Status, statusCode, statusMessage)
59-
import System.FilePath
59+
import System.FilePath.Posix
6060
(equalFilePath, joinPath, makeRelative, normalise, splitDirectories, takeDirectory, (</>))
6161
import Text.Interpolation.Nyan
6262
import Text.ParserCombinators.ReadPrec qualified as ReadPrec (lift)

‎stack.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extra-deps:
1313
- firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519
1414
- cmark-gfm-0.2.5
1515
- git: https://github.com/serokell/nyan-interpolation
16-
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
16+
commit: 348355385466d6d0116251b463a2842ecce0360d
1717
subdirs:
1818
- full
1919
- core

‎stack.yaml.lock‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ packages:
1919
original:
2020
hackage: cmark-gfm-0.2.5
2121
- completed:
22-
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
22+
commit: 348355385466d6d0116251b463a2842ecce0360d
2323
git: https://github.com/serokell/nyan-interpolation
2424
name: nyan-interpolation
2525
pantry-tree:
@@ -28,20 +28,20 @@ packages:
2828
subdir: full
2929
version: '0.9'
3030
original:
31-
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
31+
commit: 348355385466d6d0116251b463a2842ecce0360d
3232
git: https://github.com/serokell/nyan-interpolation
3333
subdir: full
3434
- completed:
35-
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
35+
commit: 348355385466d6d0116251b463a2842ecce0360d
3636
git: https://github.com/serokell/nyan-interpolation
3737
name: nyan-interpolation-core
3838
pantry-tree:
39-
sha256: 59d1c732629b06d0035229dccce484d6b4c3078d6bb3e493317afddc9be233df
39+
sha256: 4802161ce5d38f895e3b5106c789bfbe20b8d12c2f6c5fcba3999bec105283bc
4040
size: 1516
4141
subdir: core
4242
version: '0.9'
4343
original:
44-
commit: 5e158057b167275d2150454e2bb731cfe686ea7a
44+
commit: 348355385466d6d0116251b463a2842ecce0360d
4545
git: https://github.com/serokell/nyan-interpolation
4646
subdir: core
4747
snapshots:

0 commit comments

Comments
 (0)