Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Svg.animate type, name and attributes #308

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* Expand options for `autocomplete` attribute on `<input>` elements
(#302 by Aron @aronerben Erben)

* Fix the SVG animation attributes `a_animation_values`, `a_keyTimes` and `a_keySplines`
to contain semicolon separated values.
(#?? by @rand00)

* Fix the SVG element `<animate>` (by the way, deprecate `animation` et
al. in favor of `animate` et al.)
(#306 by Idir @ilankri Lankri)
Expand Down
3 changes: 2 additions & 1 deletion implem/tyxml_xml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module M = struct
let uri_of_string s = s
let string_of_uri s = s

type separator = Space | Comma
type separator = Space | Comma | Semicolon

(** Attributes *)

Expand All @@ -56,6 +56,7 @@ module M = struct
let string_attrib name value = name, AStr value
let space_sep_attrib name values = name, AStrL (Space, values)
let comma_sep_attrib name values = name, AStrL (Comma, values)
let semicolon_sep_attrib name values = name, AStrL (Semicolon, values)
let event_handler_attrib name value = name, AStr value
let mouse_event_handler_attrib name value = name, AStr value
let keyboard_event_handler_attrib name value = name, AStr value
Expand Down
6 changes: 3 additions & 3 deletions lib/svg_f.ml
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ struct
let a_calcMode x =
user_attrib C.string_of_big_variant "calcMode" x

let a_animation_values = Xml.comma_sep_attrib "values"
let a_animation_values = Xml.semicolon_sep_attrib "values"

let a_keyTimes = Xml.comma_sep_attrib "keyTimes"
let a_keyTimes = Xml.semicolon_sep_attrib "keyTimes"

let a_keySplines = Xml.comma_sep_attrib "keySplines"
let a_keySplines = Xml.semicolon_sep_attrib "keySplines"

let a_from = string_attrib "from"

Expand Down
2 changes: 2 additions & 0 deletions lib/xml_iter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ module Make(Xml : Xml_sigs.Iterable) = struct
match sep with
| Space -> space_sep_attrib (aname head) values' :: tail
| Comma -> comma_sep_attrib (aname head) values' :: tail
| Semicolon -> semicolon_sep_attrib (aname head) values' :: tail
end
| _ -> head :: rm_attrib_from_list is_attrib is_value tail

Expand All @@ -118,6 +119,7 @@ module Make(Xml : Xml_sigs.Iterable) = struct
begin match sep with
| Comma -> comma_sep_attrib (aname head) (List.map f values)
| Space -> space_sep_attrib (aname head) (List.map f values)
| Semicolon -> semicolon_sep_attrib (aname head) (List.map f values)
end
| _ -> head in
List.map aux l
Expand Down
2 changes: 2 additions & 0 deletions lib/xml_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ struct
let pp_sep indent = function
| Space -> fun fmt () -> sp indent fmt
| Comma -> fun fmt () -> Format.fprintf fmt ",%t" (sp indent)
| Semicolon -> fun fmt () -> Format.fprintf fmt ";%t" (sp indent)

let pp_attrib_value encode indent fmt a = match acontent a with
| AFloat f -> Format.fprintf fmt "\"%a\"" pp_number f
Expand Down Expand Up @@ -363,6 +364,7 @@ struct
let separator_to_string = function
| Space -> " "
| Comma -> ", "
| Semicolon -> "; "

let attrib_value_to_string encode a = match acontent a with
| AFloat f -> Printf.sprintf "\"%s\"" (string_of_number f)
Expand Down
3 changes: 2 additions & 1 deletion lib/xml_sigs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module type T = sig
val string_attrib : aname -> string wrap -> attrib
val space_sep_attrib : aname -> string list wrap -> attrib
val comma_sep_attrib : aname -> string list wrap -> attrib
val semicolon_sep_attrib : aname -> string list wrap -> attrib
val event_handler_attrib : aname -> event_handler -> attrib
val mouse_event_handler_attrib : aname -> mouse_event_handler -> attrib
val keyboard_event_handler_attrib : aname -> keyboard_event_handler -> attrib
Expand Down Expand Up @@ -75,7 +76,7 @@ module type Iterable = sig

include NoWrap

type separator = Space | Comma
type separator = Space | Comma | Semicolon

val aname : attrib -> aname

Expand Down