stripLinkReferences :: C.Doc -> (LinkMap, C.Doc)
stripLinkReferences = foldr f (M.empty, [])
  where f (LinkReference ref url mtitle) (map, xs) =
          (M.insert ref (url, mtitle) map, xs)
        f x (map, xs) =
          (map, x : xs)
stripLinkReferences :: C.Doc -> (LinkMap, C.Doc)
stripLinkReferences = foldr f (M.empty, [])
  where f (LinkReference ref url mtitle) (map, xs) =
          (M.insert ref (url, mtitle) map, xs)
        f x (map, xs) =
          (map, x : xs)
stripLinkReferences = foldr f (M.empty, [])
  where f (LinkReference ref url mtitle) (map, xs) =
          (M.insert ref (url, mtitle) map, xs)
        f x (map, xs) =
          (map, x : xs)