@@ -1139,27 +1139,32 @@ applyCustomLinkFormat link = do
11391139 formatter <- M.lookup linkType <$> asksF orgStateLinkFormatters
11401140 return $ maybe link ($ drop 1 rest) formatter
11411141
1142−
11431142linkToInlinesF :: String -> Inlines -> F Inlines
1144−linkToInlinesF s@('#':_) = pure . B.link s ""
1145−linkToInlinesF s
1146− | isImageFilename s = const . pure $ B.image s "" ""
1147− | isUri s = pure . B.link s ""
1148− | isRelativeUrl s = pure . B.link s ""
1149−linkToInlinesF s = \title -> do
1150− anchorB <- (s `elem`) <$> asksF orgStateAnchorIds
1151− if anchorB
1152− then pure $ B.link ('#':s) "" title
1153− else pure $ B.emph title
1154−
1155−isRelativeUrl :: String -> Bool
1156−isRelativeUrl s = (':' `notElem` s) && ("./" `isPrefixOf` s)
1143+linkToInlinesF s =
1144+ case s of
1145+ ('#':_) -> pure . B.link s ""
1146+ _ | isImageFilename s -> const . pure $ B.image s "" ""
1147+ _ | isUri s -> pure . B.link s ""
1148+ _ | isRelativeFilePath s -> pure . B.link s ""
1149+ _ | isAbsoluteFilePath s -> pure . B.link ("file://" ++ s) ""
1150+ _ -> \title -> do
1151+ anchorB <- (s `elem`) <$> asksF orgStateAnchorIds
1152+ if anchorB
1153+ then pure $ B.link ('#':s) "" title
1154+ else pure $ B.emph title
1155+
1156+isRelativeFilePath :: String -> Bool
1157+isRelativeFilePath s = (("./" `isPrefixOf` s) || ("../" `isPrefixOf` s)) &&
1158+ (':' `notElem` s)
11571159
11581160isUri :: String -> Bool
11591161isUri s = let (scheme, path) = break (== ':') s
11601162 in all (\c -> isAlphaNum c || c `elem` ".-") scheme
11611163 && not (null path)
11621164
1165+isAbsoluteFilePath :: String -> Bool
1166+isAbsoluteFilePath = ('/' ==) . head
1167+
11631168isImageFilename :: String -> Bool
11641169isImageFilename filename =
11651170 any (\x -> ('.':x) `isSuffixOf` filename) imageExtensions &&