generator: add a simple HTML escaping function

This commit is contained in:
Pino Toscano
2015-02-10 14:22:14 +01:00
parent 4905d6eb95
commit 8b268bd897
2 changed files with 10 additions and 1 deletions

View File

@@ -360,4 +360,10 @@ let args_of_optargs optargs =
| OInt64 n -> Int64 n
| OString n -> String n
| OStringList n -> StringList n
) optargs;
) optargs
let html_escape text =
let text = replace_str text "&" "&" in
let text = replace_str text "<" "&lt;" in
let text = replace_str text ">" "&gt;" in
text

View File

@@ -131,3 +131,6 @@ val spaces : int -> string
val args_of_optargs : Types.optargs -> Types.args
(** Convert a list of optargs into an equivalent list of args *)
val html_escape : string -> string
(** Escape a text for HTML display. *)