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