comparison html.urs @ 9:8eaaca74a64c

Import HTML parser
author Adam Chlipala <adam@chlipala.net>
date Wed, 15 Dec 2010 09:27:46 -0500
parents
children
comparison
equal deleted inserted replaced
8:ec4de8f848f8 9:8eaaca74a64c
1 (** Safe HTML parsing *)
2
3 con attribute = fn t => {Nam : string,
4 Parse : string -> option t}
5
6 con tag = fn ts => {Nam : string,
7 Attributes : $(map attribute ts),
8 Folder : folder ts,
9 Construct : ctx ::: {Unit} -> [[Body] ~ ctx] => $ts
10 -> xml ([Body] ++ ctx) [] [] -> xml ([Body] ++ ctx) [] []}
11
12 val tag : use ::: {Type} -> ignore ::: {Type} -> [use ~ ignore] => folder use -> string
13 -> $(map attribute use)
14 -> (ctx ::: {Unit} -> [[Body] ~ ctx] => Basis.tag (use ++ ignore) ([Body] ++ ctx) ([Body] ++ ctx) [] [])
15 -> tag use
16
17 val simpleTag : ignore ::: {Type} -> string -> bodyTag ignore -> tag []
18 val simpleTag' : use ::: {Type} -> ignore ::: {Type} -> [use ~ ignore] => folder use
19 -> string -> bodyTag (use ++ ignore) -> $(map attribute use) -> tag use
20
21 val url : string -> attribute url
22
23 val format : tags ::: {{Type}} -> folder tags -> $(map tag tags)
24 -> ctx ::: {Unit} -> [[Body] ~ ctx] => string
25 -> Parse.parse (xml ([Body] ++ ctx) [] [])
26
27 val b : tag []
28 val i : tag []
29 val a : tag [Href = url]