@@ -24,6 +24,7 @@ import System.FilePath.Posix ((</>))
24
24
25
25
import qualified Data.Map as Map
26
26
import qualified Data.Set as Set
27
+ import qualified Data.List as List
27
28
28
29
import Text.XHtml (Html , HtmlAttr , (!) )
29
30
import qualified Text.XHtml as Html
@@ -249,14 +250,20 @@ hyperlink (srcs, srcs') ident = case ident of
249
250
Left name -> externalModHyperlink name
250
251
251
252
where
253
+ -- In a Nix environment, we have file:// URLs with absolute paths
254
+ makeHyperlinkUrl url | List. isPrefixOf " file://" url = url
255
+ makeHyperlinkUrl url = " .." </> url
256
+
252
257
internalHyperlink name content =
253
258
Html. anchor content ! [ Html. href $ " #" ++ internalAnchorIdent name ]
254
259
255
260
externalNameHyperlink name content = case Map. lookup mdl srcs of
256
261
Just SrcLocal -> Html. anchor content !
257
262
[ Html. href $ hypSrcModuleNameUrl mdl name ]
258
- Just (SrcExternal path) -> Html. anchor content !
259
- [ Html. href $ spliceURL Nothing (Just mdl) (Just name) Nothing (" .." </> path) ]
263
+ Just (SrcExternal path) ->
264
+ let hyperlinkUrl = makeHyperlinkUrl path </> hypSrcModuleNameUrl mdl name
265
+ in Html. anchor content !
266
+ [ Html. href $ spliceURL Nothing (Just mdl) (Just name) Nothing hyperlinkUrl ]
260
267
Nothing -> content
261
268
where
262
269
mdl = nameModule name
@@ -265,8 +272,10 @@ hyperlink (srcs, srcs') ident = case ident of
265
272
case Map. lookup moduleName srcs' of
266
273
Just SrcLocal -> Html. anchor content !
267
274
[ Html. href $ hypSrcModuleUrl' moduleName ]
268
- Just (SrcExternal path) -> Html. anchor content !
269
- [ Html. href $ spliceURL' Nothing (Just moduleName) Nothing Nothing (" .." </> path) ]
275
+ Just (SrcExternal path) ->
276
+ let hyperlinkUrl = makeHyperlinkUrl path </> hypSrcModuleUrl' moduleName
277
+ in Html. anchor content !
278
+ [ Html. href $ spliceURL' Nothing (Just moduleName) Nothing Nothing hyperlinkUrl ]
270
279
Nothing -> content
271
280
272
281
0 commit comments