CurryInfo: currydoc-4.0.0 / CurryDoc.Html.replaceIdLinks

definition: Info
 
replaceIdLinks :: DocOptions -> String -> String
replaceIdLinks opts str = case str of
  []             -> []
  ('\\':'\'':cs) -> '\'' : replaceIdLinks opts cs
  (c:cs)         -> if c == '\'' then tryReplaceIdLink [] cs
                                 else c : replaceIdLinks opts cs
 where
  tryReplaceIdLink ltxt [] = '\'' : reverse ltxt
  tryReplaceIdLink ltxt (c:cs)
   | isSpace c
   = '\'' : reverse ltxt ++ c : replaceIdLinks opts cs -- no space in id
   | c == '\''
   = checkId (reverse ltxt) ++ replaceIdLinks opts cs
   | otherwise
   = tryReplaceIdLink (c:ltxt) cs

  checkId s
    | ' ' `elem` s
    = '\'' : s ++ ['\'']
    | otherwise
    = let xs     = splitOn "." s
          urlref = if length xs == 1
                     then '#':s
                     else docURL opts (intercalate "." (init xs)) ++
                          ".html#" ++ last xs
      in if withMarkdown opts
           then "[" ++ s ++ "](" ++ urlref ++ ")"
           else "<code><a href=\"" ++ urlref ++ "\">"++s++"</a></code>"
demand: Info
 argument 2
deterministic: Info
 deterministic operation
documentation: Info
 
Replace identifier hyperlinks in a string (i.e., enclosed in single quotes)
by HTML refences:
indeterministic: Info
 referentially transparent operation
infix: Info
 no fixity defined
iotype: Info
 {(_,{[]}) |-> {[]} || (_,{:}) |-> _}
name: Info
 replaceIdLinks
precedence: Info
 no precedence defined
result-values: Info
 _
signature: Info
 CurryDoc.Options.DocOptions -> String -> String
solution-complete: Info
 operation might suspend on free variables
terminating: Info
 possibly non-terminating
totally-defined: Info
 possibly non-reducible on same data term