Closed mooreryan closed 9 months ago
hmm, that might be due to some over-enthusiastic case normalisation ...
I looked into this some more and found that the Markup
code either parsing or writing html (not sure yet which) is lowercasing the stddeviation
, but not feGaussianBlur
. Here is an example:
let () =
let open Markup in
string {|<feGaussianBlur in="sourceAlpha" stdDeviation="1"></feGaussianBlur>|}
|> parse_html |> signals |> pretty_print |> write_html
|> to_channel Out_channel.stdout
Which outputs:
<feGaussianBlur in="sourceAlpha" stddeviation="1"></feGaussianBlur>
I will continue to look into it.
I may have found the source of the problem. I noticed in the above example switching from parse_html
to parse_xml
works.
The tyxml-ppx uses Markup.parse_html
.
https://github.com/ocsigen/tyxml/blob/47423cf70b804c67386583a9b7eccd9157316475/ppx/tyxml_ppx.ml#L291
Here are some links to lines in a couple of files showing what I think may be going on.
If you look in Markup.parse_html
function, you will see a spot in which the attributes either get pushed through here, or adjusted with adjust_svg_attributes
(here).
If you look at the adjust_svg_attributes
function, it fixes the case of the stdDeviation
attribute here.
I think the lowercasing comes in around here. In contrast, the xml_parser
is fine for that toy example, because it doesn't lowercase anything first (I think...).
(Sorry for the mess of links!)
Anyway, I think that may be what's causing the issue here....
Thanks for all the hints @mooreryan, I started looking into this issue as well because I tried parsing an <svg viewBox="...">...</svg>
with tyxml-ppx
.
I describe my findings here https://github.com/aantron/markup.ml/pull/69.
It looks like this is solved in markup, closing !
I have a preexisting SVG that I would like to process with the tyxml ppx. However, when doing so I get an error:
Error: Unknown attribute in SVG element: stddeviation
.I'm not sure if this is a bug or if I'm misunderstanding something about the ppx.
Here is a tiny example to reproduce the problem.
I have this code (just a tiny example) that makes part of an svg and sticks it into a div. (The created html is a stand in for the actual svg that I would like to process.)
It compiles fine, and when I write it out to a string I get this html:
When I read that html back in using the ppx like this:
I get an error: