0 | module Text.PrettyPrint.Prettyprinter.Render.HTML
7 | htmlEscape : String -> String
8 | htmlEscape s = concat $
reverse $
go [] s
10 | isSafe : Char -> Bool
19 | isSafe c = (c >= ' ' && c <= '~')
21 | htmlQuote : Char -> String
22 | htmlQuote '"' = """
23 | htmlQuote '<' = "<"
24 | htmlQuote '>' = ">"
25 | htmlQuote '&' = "&"
26 | htmlQuote '\'' = "'"
27 | htmlQuote c = "&#" ++ (show $
ord c) ++ ";"
29 | go : List String -> String -> List String
32 | case span isSafe s of
33 | (safe, "") => safe::acc
34 | (safe, rest) => let c = assert_total (strIndex rest 0)
35 | escaped = htmlQuote c in
36 | go (escaped::safe::acc) (assert_total $
strTail rest)