let cell_arguments tab args =
let parse_1arg str =
let head = ref false in
let cols = ref 1 in
let alig = ref tab.default_align in
let rec p str =
if str = "" then ()
else (
try Scanf.sscanf
str "%d%s" (fun c s -> cols := c; p s)
with
e ->
begin match str.[0] with
| 'h' -> head := true;
| 'r' -> alig := `right;
| 'l' -> alig := `left;
| 'c' -> alig := `center;
| '_' -> ()
| _ -> ()
end;
p (String.sub str 1 (String.length str - 1));
);
in
p str;
(!head, 1, !cols, !alig) in
let parse_2args a1 a2 =
let h, _, _, a = parse_1arg a1 in
let r, c =
try
(try Scanf.sscanf a2 "%dx%d" (fun r c -> (r, c))
with e -> Scanf.sscanf a2 "%d" (fun c -> (1, c)))
with e ->
(1, 1)
in
(h, r, c, a) in
match args with
| [] -> (false, 1, 1, tab.default_align)
| arg :: [] ->
(parse_1arg arg)
| arg1 :: arg2 :: _ ->
(parse_2args arg1 arg2)