forked from ahrefs/devkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
htmlStream.mli
36 lines (27 loc) · 1.03 KB
/
htmlStream.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(** HTML scanner *)
module Raw = HtmlStream_ragel.Raw
type elem =
| Tag of (string * (string * Raw.t) list)
| Script of ((string * Raw.t) list * string) (** attributes and contents. TODO investigate script contents encoding *)
| Style of ((string * Raw.t) list * string)
| Text of Raw.t
| Close of string
type ctx
val init : unit -> ctx
val get_lnum : ctx -> int
(**
Scan string for html tags.
NB
1. self-closing tags (e.g. [<x/>]) will result in two tags generated [<x></x>] (except for [<a/>])
2. unfinished tags at the end of input are ignored
*)
val parse : ?ctx:ctx -> (elem -> unit) -> string -> unit
(** @return html string for [elem] *)
val show_raw : elem -> string
(** @return html string for [elem] using single quote for attributes *)
val show_raw' : elem -> string
val attrs_include : (string * Raw.t) list -> (string * string) list -> bool
val tag : string -> ?a:(string * string) list -> elem -> bool
val close : string -> elem -> bool
(** extract text from the list elements *)
val make_text : ?br:bool -> elem list -> Raw.t