Fix to table checker

This commit is contained in:
John Whitington 2024-07-02 14:28:39 +01:00
parent 4a3f830202
commit c8447f0ba1
1 changed files with 13 additions and 9 deletions

View File

@ -22,6 +22,11 @@ type st = E of string * st list
(* Now one which contains the attributes too. *) (* Now one which contains the attributes too. *)
type st2 = E2 of string * string list * st2 list type st2 = E2 of string * string list * st2 list
let print_children (E (n, cs)) =
Printf.printf "%S: " n;
iter (fun (E (n, _)) -> Printf.printf "%S " n) cs;
flprint "\n"
(* FIXME What about /C? *) (* FIXME What about /C? *)
(* FIXME What about class map? *) (* FIXME What about class map? *)
(* Read attributes. *) (* Read attributes. *)
@ -240,8 +245,8 @@ let matterhorn_09_004 st st2 pdf =
| E ("/Caption", _)::cs -> cs | E ("/Caption", _)::cs -> cs
| l -> | l ->
begin match rev cs with begin match rev cs with
| E ("/Caption", _)::cs -> cs | E ("/Caption", _)::cs -> rev cs
| cs -> cs | cs -> rev cs
end end
end end
in in
@ -267,9 +272,12 @@ let matterhorn_09_004 st st2 pdf =
and check_tr = function and check_tr = function
| E (("/TH" | "/TD"), _) -> () | E (("/TH" | "/TD"), _) -> ()
| _ -> merror_str "Every /TR element must be a /TH or /TD" | _ -> merror_str "Every /TR element must be a /TH or /TD"
and check_thead_tbody_tfoot node = and check_thead_tbody_tfoot cs =
iter
(fun node ->
if List.exists (function E ("/TR", _) -> false | _ -> true) node then if List.exists (function E ("/TR", _) -> false | _ -> true) node then
merror_str "Element in /THead | /TBody | /TFoot not a /TR" merror_str "Element in /THead | /TBody | /TFoot not a /TR")
(map (function (E (_, cs')) -> cs') cs)
in in
check_table st check_table st
@ -302,10 +310,6 @@ let matterhorn_09_005 st st2 pdf =
(* A TOC-related structure element is used in a way that does not conform to (* A TOC-related structure element is used in a way that does not conform to
Table 333 in ISO 32000-1. *) Table 333 in ISO 32000-1. *)
let print_children (E (n, cs)) =
Printf.printf "%S: " n;
iter (fun (E (n, _)) -> Printf.printf "%S " n) cs;
flprint "\n"
(* We test two things: a) everything under a TOC is correct; and b) There is no (* We test two things: a) everything under a TOC is correct; and b) There is no
TOCI except under a TOC. *) TOCI except under a TOC. *)