Drop Batteries dependency

This commit is contained in:
Stavros Polymenis 2017-11-06 23:10:03 +00:00
parent 328e6da91e
commit f79803cdfd
2 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,6 @@ depends: [
"uuidm" "uuidm"
"omd" "omd"
"opium" "opium"
"batteries"
"lwt" "lwt"
"ptime" "ptime"
"re" "re"

View File

@ -88,16 +88,17 @@ let string_alias t =
let is_reserved = function let is_reserved = function
| '!' | '*' | '\'' | '(' | ')' | ';' | ':' | '@' | '&' | '=' | '+' | '$' | '!' | '*' | '\'' | '(' | ')' | ';' | ':' | '@' | '&' | '=' | '+' | '$'
| ',' | '/' | '?' | '#' | '[' | ']' | ' ' | '\t' | '\x00' -> true | ',' | '/' | '?' | '#' | '[' | ']' | ' ' | '\t' | '\x00' -> true
| _ -> false in | _ -> false
let drop h t = t in in
let dash h t = '-' :: t in let b = Buffer.create (String.length t) in
let rec filter fn = function let filter char =
| [] -> [] let open Buffer in
| head :: tail -> if is_reserved char
if is_reserved head then (try (if nth b (pred (length b)) <> '-' then add_char b '-') with Invalid_argument _ -> prerr_endline "reserved")
then fn head (filter drop tail) else add_char b char
else Char.lowercase_ascii head :: (filter dash tail) in in
Batteries.String.of_list @@ filter drop (Batteries.String.to_list t) String.iter filter t;
Buffer.contents b
type t = { type t = {
title: string; title: string;