Commit cc030724 authored by Ben Gamari's avatar Ben Gamari 🐢

More thorough linkification

parent cdbe9c7f
{-# LANGUAGE OverloadedStrings #-}
import Data.Char
import Data.List
import Data.Maybe
import Data.Monoid
......@@ -100,12 +101,17 @@ linkifyIssues :: Pandoc -> Pandoc
linkifyIssues = walk linkify
where
linkify :: [Inline] -> [Inline]
linkify (Str ('#':s) : xs)
| [(n, "")] <- reads s
= issueLink n : linkify xs
linkify (Str s : xs) = linkifyStr s ++ linkify xs
linkify (x:xs) = x : linkify xs
linkify [] = []
linkifyStr :: String -> [Inline]
linkifyStr ('#':s)
| [(n, rest)] <- reads s
= issueLink n : linkifyStr rest
linkifyStr (c:s) = Str [c] : linkifyStr s
linkifyStr [] = []
issueLink :: Int -> Inline
issueLink n = Link nullAttr [Str $ "#"++show n] (url, "")
where url = "https://gitlab.haskell.org/ghc/ghc/issues/" ++ show n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment