130
130
"dl", (`Block, `Elements ["dt"; "dd"]);
131
131
"div", (`Block, `Flow);
132
132
"noscript", (`Block, `Flow);
133
"blockquote", (`Block, (`Block |. `Elements ["script"]));
133
"blockquote", (`Block, (`Flow |. `Elements ["script"]));
134
(* strict DTD has `Block here *)
134
135
"form", (`Block, `Sub_exclusions( ["form"],
136
137
`Elements ["script"]));
138
(* strict DTD has `Block here *)
137
139
"hr", (`Block, `Empty);
138
140
"table", (`Block, `Elements ["caption"; "col"; "colgroup";
139
141
"thead"; "tfoot"; "tbody"; "tr"]);
145
147
"isindex", (`Block, `Empty);
146
148
(* ------------ OTHER ELEMENTS ----------*)
147
149
"body", (`None, (`Flow |. `Elements ["script"]));
150
(* strict DTD has `Block here *)
148
151
"area", (`None, `Empty);
149
152
"link", (`None, `Empty);
150
153
"param", (`None, `Empty);
364
367
let backup_excl = !current_excl in
366
369
while not (is_possible_subelement !current_name !current_excl sub_name) do
370
(* Maybe we are not allowed to end the current element: *)
371
let (current_class, _) = model_of !current_name in
372
if current_class = `Essential_block then raise Stack.Empty;
367
373
(* End the current element and remove it from the stack: *)
368
374
let grant_parent = Stack.pop stack in
369
375
Stack.push grant_parent backup; (* Save it; may we need it *)
371
377
(* If gp_name is an essential element, we are not allowed to close
372
378
* it implicitly, even if that violates the DTD.
374
let (gp_class, _) = model_of gp_name in
375
if gp_class = `Essential_block then raise Stack.Empty;
376
380
let current = Element (!current_name, !current_atts,
377
381
List.rev !current_subs) in
378
382
current_name := gp_name;
706
710
write_ ~dtd (ch # output_string) doc
709
module Deprecated = struct
710
let parse_string ?dtd ?return_declarations ?return_pis ?return_comments s =
711
let buf = Lexing.from_string s in
712
parse_document ?dtd ?return_declarations ?return_comments ?return_pis buf
716
let parse_file ?dtd ?return_declarations ?return_pis ?return_comments fd =
717
let buf = Lexing.from_channel fd in
718
parse_document ?dtd ?return_declarations ?return_comments ?return_pis buf
721
let write ?(dtd = html40_dtd) os doc =
725
(fun s -> Buffer.add_string b s)
727
(fun s -> output_string ch s)
729
(fun s -> f s 0 (String.length s))
731
write_ ~dtd write_os doc
735
713
(* ======================================================================
738
716
* $Log: nethtml.ml,v $
717
* Revision 2.9 2005/01/22 10:58:26 stolpmann
718
* Error: FORM, BLOCKQUOTE: Content is "flow" in the transitional DTD, not
719
* "block" as in the strict DTD.
721
* Revision 2.8 2004/07/08 23:04:25 stolpmann
724
* Revision 2.7 2004/06/23 21:47:52 stolpmann
725
* Handling of essential blocks was wrong when the block was
726
* the direct parent of the element to add. The block was implicitly
727
* closed in this case although this is not allowed (e.g.
728
* <ul><li>x</li><ol><li>y</li></ol></ul>: When <ol> is found, the
729
* ul element must not be closed).
739
732
* Revision 2.6 2003/03/02 13:09:28 stolpmann