diff --git a/.gitignore b/.gitignore index 0c8a953..04f1e2e 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ tags # JavaScript guidejs/node_modules/ +front/node_modules/ static/js/ diff --git a/src/Guide/Diff/Tokenize.hs b/src/Guide/Diff/Tokenize.hs index 6fd0bdc..5fd50b2 100644 --- a/src/Guide/Diff/Tokenize.hs +++ b/src/Guide/Diff/Tokenize.hs @@ -62,10 +62,10 @@ consolidate s@("-":_) = consolidate (".":".":".":xs) = "..." : consolidate xs -- links consolidate s@("http":":":"/":"/":_) = - let (l, r) = span (\x -> x /= ")" && not (isSpace (T.head x))) s + let (l, r) = span (\x -> x /= ")" && not (startsWithSpace x)) s in T.concat l : consolidate r consolidate s@("https":":":"/":"/":_) = - let (l, r) = span (\x -> x /= ")" && not (isSpace (T.head x))) s + let (l, r) = span (\x -> x /= ")" && not (startsWithSpace x)) s in T.concat l : consolidate r consolidate ("(":"@":"hk":")":xs) = "(" : "@hk" : ")" : consolidate xs @@ -88,3 +88,8 @@ op = over _1 mconcat . span (isOpToken . T.unpack) where isOpToken [c] = c `elem` (":!#$%&*+./<=>?@\\^|-~" :: String) isOpToken _ = False + +startsWithSpace :: Text -> Bool +startsWithSpace s = case T.uncons s of + Nothing -> False + Just (c, _) -> isSpace c diff --git a/src/Guide/Markdown.hs b/src/Guide/Markdown.hs index 842a08f..948b934 100644 --- a/src/Guide/Markdown.hs +++ b/src/Guide/Markdown.hs @@ -189,7 +189,7 @@ extractInlines = concatMap go CODE_BLOCK _ xs -> [MD.Node Nothing (CODE xs) []] shortcutLinks :: MD.Node -> MD.Node -shortcutLinks node@(MD.Node pos (LINK url title) ns) | '@' <- T.head url = +shortcutLinks node@(MD.Node pos (LINK url title) ns) | "@" <- T.take 1 url = -- %20s are possibly introduced by cmark (Pandoc definitely adds them, -- no idea about cmark but better safe than sorry) and so they need to -- be converted back to spaces