diff --git a/ocaml/doc/odoc_json.ml b/ocaml/doc/odoc_json.ml index 3c4432203e..0d93abb9f4 100644 --- a/ocaml/doc/odoc_json.ml +++ b/ocaml/doc/odoc_json.ml @@ -75,20 +75,20 @@ open String let remove_asterisks str = let n = String.length str in let res = Buffer.create n in - let phase = ref 0 in + let phase = ref false in for i = 0 to n-1 do match !phase with - | 0 -> + | false -> if str.[i] == '\n' then begin - phase := 1; + phase := true; Buffer.add_char res ' ' end else if i == 0 && str.[i] == '*' then - phase := 1 + phase := true else Buffer.add_char res str.[i] - | 1 -> + | true -> if not (List.mem str.[i] ['\n'; '\t'; ' '; '*']) then begin - phase := 0; + phase := false; Buffer.add_char res str.[i] end | _ -> failwith "something went wrong!" @@ -166,7 +166,7 @@ let rec json_to_string n = function | Object l -> (endl n) ^ "{ " ^ (String.concat ("," ^ (endl (n+1))) (List.map (fun (s, j) -> "\"" ^ s ^ "\": " ^ (json_to_string (n+2) j)) l)) ^ " }" | Array l -> "[ " ^ (String.concat ", " (List.map (fun j -> (json_to_string n j)) l)) ^ " ]" | String s -> "\"" ^ (escape_json s) ^ "\"" -| Number n -> string_of_float n +| Number n -> Printf.sprintf "%.4f" n | True -> "true" | False -> "false" | Empty -> "\"\""