html.urs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. (** Safe HTML parsing *)
  2. con attribute = fn t => {Nam : string,
  3. Parse : string -> option t}
  4. con tag = fn ts => {Nam : string,
  5. Attributes : $(map attribute ts),
  6. Folder : folder ts,
  7. Construct : ctx ::: {Unit} -> [[Body] ~ ctx] => $ts
  8. -> xml ([Body] ++ ctx) [] [] -> xml ([Body] ++ ctx) [] []}
  9. val tag : use ::: {Type} -> ignore ::: {Type} -> [use ~ ignore] => folder use -> string
  10. -> $(map attribute use)
  11. -> (ctx ::: {Unit} -> [[Body] ~ ctx] => Basis.tag (use ++ ignore) ([Body] ++ ctx) ([Body] ++ ctx) [] [])
  12. -> tag use
  13. val simpleTag : ignore ::: {Type} -> string -> bodyTag ignore -> tag []
  14. val simpleTag' : use ::: {Type} -> ignore ::: {Type} -> [use ~ ignore] => folder use
  15. -> string -> bodyTag (use ++ ignore) -> $(map attribute use) -> tag use
  16. val url : string -> attribute url
  17. val format : tags ::: {{Type}} -> folder tags -> $(map tag tags)
  18. -> ctx ::: {Unit} -> [[Body] ~ ctx] => string
  19. -> Parse.parse (xml ([Body] ++ ctx) [] [])
  20. val b : tag []
  21. val i : tag []
  22. val a : tag [Href = url]