···134134 system_id : string option; (** System identifier (legacy, rarely used) *)
135135}
136136137137+val pp_doctype_data : Format.formatter -> doctype_data -> unit
138138+(** Pretty-print DOCTYPE data. *)
139139+137140(** Quirks mode setting for the document.
138141139142 {i Quirks mode} is a browser rendering mode that emulates bugs and
···173176 WHATWG: How the parser determines quirks mode
174177*)
175178type quirks_mode = Dom_node.quirks_mode = No_quirks | Quirks | Limited_quirks
179179+180180+val pp_quirks_mode : Format.formatter -> quirks_mode -> unit
181181+(** Pretty-print quirks mode. *)
176182177183(** A DOM node in the parsed document tree.
178184···322328323329 Only doctype nodes use this field; for all other nodes it is [None]. *)
324330}
331331+332332+val pp : Format.formatter -> node -> unit
333333+(** Pretty-print a DOM node. Prints a summary representation showing the
334334+ node type and key attributes. Does not recursively print children. *)
325335326336(** {1 Node Name Constants}
327337
+31
lib/html5rw/dom/dom_node.ml
···162162 ) node.template_content
163163 end;
164164 new_node
165165+166166+(* Pretty printers *)
167167+let pp_doctype_data fmt (d : doctype_data) =
168168+ Format.fprintf fmt "<!DOCTYPE %s%s%s>"
169169+ (Option.value ~default:"" d.name)
170170+ (match d.public_id with Some p -> " PUBLIC \"" ^ p ^ "\"" | None -> "")
171171+ (match d.system_id with Some s -> " \"" ^ s ^ "\"" | None -> "")
172172+173173+let pp_quirks_mode fmt = function
174174+ | No_quirks -> Format.pp_print_string fmt "no-quirks"
175175+ | Quirks -> Format.pp_print_string fmt "quirks"
176176+ | Limited_quirks -> Format.pp_print_string fmt "limited-quirks"
177177+178178+let pp fmt node =
179179+ if is_text node then
180180+ Format.fprintf fmt "#text %S" node.data
181181+ else if is_comment node then
182182+ Format.fprintf fmt "<!-- %s -->" node.data
183183+ else if is_document node then
184184+ Format.pp_print_string fmt "#document"
185185+ else if is_document_fragment node then
186186+ Format.pp_print_string fmt "#document-fragment"
187187+ else if is_doctype node then
188188+ (match node.doctype with
189189+ | Some d -> pp_doctype_data fmt d
190190+ | None -> Format.pp_print_string fmt "<!DOCTYPE>")
191191+ else begin
192192+ Format.fprintf fmt "<%s" node.name;
193193+ List.iter (fun (k, v) -> Format.fprintf fmt " %s=%S" k v) node.attrs;
194194+ Format.pp_print_char fmt '>'
195195+ end
+10
lib/html5rw/dom/dom_node.mli
···134134 system_id : string option; (** System identifier (legacy, rarely used) *)
135135}
136136137137+val pp_doctype_data : Format.formatter -> doctype_data -> unit
138138+(** Pretty-print DOCTYPE data. *)
139139+137140(** Quirks mode setting for the document.
138141139142 {i Quirks mode} is a browser rendering mode that emulates bugs and
···173176 WHATWG: How the parser determines quirks mode
174177*)
175178type quirks_mode = No_quirks | Quirks | Limited_quirks
179179+180180+val pp_quirks_mode : Format.formatter -> quirks_mode -> unit
181181+(** Pretty-print quirks mode. *)
176182177183(** A DOM node in the parsed document tree.
178184···322328323329 Only doctype nodes use this field; for all other nodes it is [None]. *)
324330}
331331+332332+val pp : Format.formatter -> node -> unit
333333+(** Pretty-print a DOM node. Prints a summary representation showing the
334334+ node type and key attributes. Does not recursively print children. *)
325335326336(** {1 Node Name Constants}
327337
···107107(** DOM node type. See {!Dom} for manipulation functions. *)
108108type node = Dom.node
109109110110+let pp_node = Dom.pp
111111+110112(** Doctype information *)
111113type doctype_data = Dom.doctype_data = {
112114 name : string option;
···114116 system_id : string option;
115117}
116118119119+let pp_doctype_data = Dom.pp_doctype_data
120120+117121(** Quirks mode as determined during parsing *)
118122type quirks_mode = Dom.quirks_mode = No_quirks | Quirks | Limited_quirks
119123124124+let pp_quirks_mode = Dom.pp_quirks_mode
125125+120126(** Character encoding detected or specified *)
121127type encoding = Encoding.encoding =
122128 | Utf8
···125131 | Windows_1252
126132 | Iso_8859_2
127133 | Euc_jp
134134+135135+let pp_encoding = Encoding.pp
128136129137(** Parse error record *)
130138type parse_error = Parser.parse_error
···144152(** Get the namespace from a fragment context *)
145153let fragment_context_namespace = Parser.fragment_context_namespace
146154155155+let pp_fragment_context = Parser.pp_fragment_context
156156+147157(** Get the error code *)
148158let error_code = Parser.error_code
149159···152162153163(** Get the column number of an error (1-indexed) *)
154164let error_column = Parser.error_column
165165+166166+let pp_parse_error = Parser.pp_parse_error
155167156168(** Result of parsing an HTML document *)
157169type t = {
···159171 errors : parse_error list;
160172 encoding : encoding option;
161173}
174174+175175+let pp fmt t =
176176+ Format.fprintf fmt "{root=%a; errors=%d; encoding=%a}"
177177+ pp_node t.root
178178+ (List.length t.errors)
179179+ (Format.pp_print_option pp_encoding) t.encoding
162180163181(* Internal: convert Parser.t to our t *)
164182let of_parser_result (p : Parser.t) : t =
+22
lib/html5rw/html5rw.mli
···241241 WHATWG: The DOM *)
242242type node = Dom.node
243243244244+val pp_node : Format.formatter -> node -> unit
245245+(** Pretty-print a DOM node. Prints a summary representation showing the
246246+ node type and key attributes. Does not recursively print children. *)
247247+244248(** DOCTYPE information.
245249246250 The DOCTYPE declaration ([<!DOCTYPE html>]) appears at the start of HTML
···262266 (** System identifier (URL) for legacy DOCTYPEs *)
263267}
264268269269+val pp_doctype_data : Format.formatter -> doctype_data -> unit
270270+(** Pretty-print DOCTYPE data. *)
271271+265272(** Quirks mode as determined during parsing.
266273267274 {i Quirks mode} controls how browsers render CSS and compute layouts.
···285292 @see <https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode>
286293 WHATWG: How quirks mode is determined *)
287294type quirks_mode = Dom.quirks_mode = No_quirks | Quirks | Limited_quirks
295295+296296+val pp_quirks_mode : Format.formatter -> quirks_mode -> unit
297297+(** Pretty-print quirks mode. *)
288298289299(** Character encoding detected or specified.
290300···322332 | Euc_jp
323333 (** EUC-JP: Extended Unix Code for Japanese *)
324334335335+val pp_encoding : Format.formatter -> encoding -> unit
336336+(** Pretty-print an encoding using its canonical label. *)
337337+325338(** A parse error encountered during HTML5 parsing.
326339327340 HTML5 parsing {b never fails} - the specification defines error recovery
···371384372385 Column numbers count from 1 and reset at each newline. *)
373386val error_column : parse_error -> int
387387+388388+val pp_parse_error : Format.formatter -> parse_error -> unit
389389+(** Pretty-print a parse error with location information. *)
374390375391(** {1 Error Handling} *)
376392···524540(** Get the namespace of a fragment context. *)
525541val fragment_context_namespace : fragment_context -> string option
526542543543+val pp_fragment_context : Format.formatter -> fragment_context -> unit
544544+(** Pretty-print a fragment context. *)
545545+527546(** Result of parsing an HTML document.
528547529548 This record contains everything produced by parsing:
···557576 encoding detection, and [None] when using {!parse} (which expects
558577 pre-decoded UTF-8 input). *)
559578}
579579+580580+val pp : Format.formatter -> t -> unit
581581+(** Pretty-print a parse result summary. *)
560582561583(** {1 Parsing Functions} *)
562584
···328328(** Check if an error code is defined in the WHATWG specification.
329329330330 Returns [false] for [Tree_construction_error _], [true] for all others. *)
331331+332332+val pp : Format.formatter -> t -> unit
333333+(** Pretty-print an error code using the WHATWG specification string format. *)
···283283 not bytes or grapheme clusters. *)
284284val error_column : parse_error -> int
285285286286+val pp_parse_error : Format.formatter -> parse_error -> unit
287287+(** Pretty-print a parse error with location information. *)
288288+286289(** Context element for HTML fragment parsing.
287290288291 When parsing HTML fragments (the content that would be assigned to
···349352350353(** Get the namespace of a fragment context ([None] for HTML). *)
351354val fragment_context_namespace : fragment_context -> string option
355355+356356+val pp_fragment_context : Format.formatter -> fragment_context -> unit
357357+(** Pretty-print a fragment context. *)
352358353359(** Result of parsing an HTML document or fragment.
354360···485491 @see <https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding>
486492 WHATWG: Determining the character encoding *)
487493val encoding : t -> Encoding.encoding option
494494+495495+val pp : Format.formatter -> t -> unit
496496+(** Pretty-print a parse result summary. *)
488497489498(** {1 Querying} *)
490499
+21
lib/html5rw/selector/selector.mli
···107107108108 val to_human_string : t -> string
109109 (** Convert to a human-readable error message. *)
110110+111111+ val pp : Format.formatter -> t -> unit
112112+ (** Pretty-print a selector error code. *)
110113end
111114112115(** {1 Exceptions} *)
···169172 val make_compound : simple_selector list -> compound_selector
170173 val make_complex : (string option * compound_selector) list -> complex_selector
171174 val make_list : complex_selector list -> selector_list
175175+176176+ val pp_simple_selector_type : Format.formatter -> simple_selector_type -> unit
177177+ (** Pretty-print a simple selector type. *)
178178+179179+ val pp_simple_selector : Format.formatter -> simple_selector -> unit
180180+ (** Pretty-print a simple selector. *)
181181+182182+ val pp_compound_selector : Format.formatter -> compound_selector -> unit
183183+ (** Pretty-print a compound selector. *)
184184+185185+ val pp_complex_selector : Format.formatter -> complex_selector -> unit
186186+ (** Pretty-print a complex selector. *)
187187+188188+ val pp_selector_list : Format.formatter -> selector_list -> unit
189189+ (** Pretty-print a selector list. *)
190190+191191+ val pp : Format.formatter -> selector -> unit
192192+ (** Pretty-print a selector. *)
172193end
173194174195(** Token types for the selector lexer. *)
···7070 | Expected_selector_after_combinator -> "Expected selector after combinator"
7171 | Unexpected_token -> "Unexpected token"
7272 | Expected_end_of_selector -> "Expected end of selector"
7373+7474+let pp fmt t = Format.pp_print_string fmt (to_string t)
+3
lib/html5rw/selector/selector_error_code.mli
···6060 - [to_human_string Empty_selector] returns ["Empty selector"]
6161 - [to_human_string Expected_closing_bracket] returns ["Expected \]"]
6262*)
6363+6464+val pp : Format.formatter -> t -> unit
6565+(** Pretty-print a selector error code using its kebab-case string form. *)
+18
lib/html5rw/tokenizer/tokenizer.mli
···5050 val make_comment : string -> t
5151 val make_character : string -> t
5252 val eof : t
5353+5454+ val pp_tag_kind : Format.formatter -> tag_kind -> unit
5555+ (** Pretty-print a tag kind (Start or End). *)
5656+5757+ val pp_doctype : Format.formatter -> doctype -> unit
5858+ (** Pretty-print a DOCTYPE token. *)
5959+6060+ val pp_tag : Format.formatter -> tag -> unit
6161+ (** Pretty-print a tag token. *)
6262+6363+ val pp : Format.formatter -> t -> unit
6464+ (** Pretty-print a token. *)
5365end
54665567(** Tokenizer states. *)
···135147 | Hexadecimal_character_reference
136148 | Decimal_character_reference
137149 | Numeric_character_reference_end
150150+151151+ val pp : Format.formatter -> t -> unit
152152+ (** Pretty-print a tokenizer state. *)
138153end
139154140155(** Parse error types. *)
···153168 (** Create an error with a typed error code. *)
154169155170 val to_string : t -> string
171171+172172+ val pp : Format.formatter -> t -> unit
173173+ (** Pretty-print a tokenizer error. *)
156174end
157175158176(** Input stream with position tracking. *)