diff options
author | Marc Coquand <marcc@fastmail.fr> | 2023-12-02 09:49:42 -0600 |
---|---|---|
committer | Marc Coquand <marcc@fastmail.fr> | 2023-12-02 09:49:42 -0600 |
commit | 69d3f53365568524e18dfb1200a386309e174359 (patch) | |
tree | 30e465d36ea03bceb1f4e9b54aadfdb6d7093162 /lib/xml.ml | |
download | wormhole-69d3f53365568524e18dfb1200a386309e174359.tar.gz wormhole-69d3f53365568524e18dfb1200a386309e174359.tar.bz2 wormhole-69d3f53365568524e18dfb1200a386309e174359.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | lib/xml.ml | 10 | ||||
-rw-r--r-- | lib/xml.mli | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/xml.ml b/lib/xml.ml new file mode 100644 index 0000000..fe4abdc --- /dev/null +++ b/lib/xml.ml @@ -0,0 +1,10 @@ +type xml = Tag of string * xml list | String of string + +let tag name body = Tag (name, body) +let format, format_list = Format.(fprintf, pp_print_list) + +let rec format_xml f = function + | Tag (name, body) -> + let format_body = format_list format_xml in + format f "@[<hv 3><%s>@,%a@;<0 -3></%s>@]" name format_body body name + | String text -> format f "%s" text diff --git a/lib/xml.mli b/lib/xml.mli new file mode 100644 index 0000000..e1d3eb9 --- /dev/null +++ b/lib/xml.mli @@ -0,0 +1,13 @@ +type xml = Tag of string * xml list | String of string + +val tag : string -> xml list -> xml +val format : Format.formatter -> ('a, Format.formatter, unit) format -> 'a + +val format_list : + ?pp_sep:(Format.formatter -> unit -> unit) -> + (Format.formatter -> 'a -> unit) -> + Format.formatter -> + 'a list -> + unit + +val format_xml : Format.formatter -> xml -> unit |