blob: c582b9c26699354cc0d4afb22a10fc5143a8eb6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
let match_date = Re.Str.regexp {|[0-9]+/[0-9]+/[0-9]+|}
type t =
| Null
| Error of string
| Content of string
| Integer of int
| Float of float
let to_string = function
| Null -> ""
| Error s -> s
| Integer i -> string_of_int i
| Float f -> string_of_float f
| Content c -> (
match String.starts_with ~prefix:"0" c with
| false -> c
| true ->
(* If the string is a date, do not escape it *)
if Re.Str.string_match match_date c 0 then c
else String.concat "" [ "=\""; c; "\"" ])
|