ArunSahadeo / Webval

HTML and CSS validation for Vim
Other
2 stars 1 forks source link

Validate CSS3+SVG ? #1

Open aphecetche opened 5 years ago

aphecetche commented 5 years ago

Hi,

Is there a way to use this plugin to validate CSS3+SVG ?

Thanks,

ArunSahadeo commented 5 years ago

Hi there.

CSS3 should be validated by default, there is a ValiCSS method that makes a POST request to the W3C's CSS validation API.

For SVG, I think https://validator.nu/ validates SVG, so I will either check if they have an API or, if not, build my own API middleware that I can use to fetch data from https://validator.nu and send back to VIM.

Can you let me know which standards / editions of SVG you would need to be validated?

aphecetche commented 5 years ago

Hi, thanks for your fast reply.

The thing is, it seems the css validator is already able to validate css + svg (SVG 1.1 is the one I'm using)

For instance, if I paste my css style.css.txt in https://jigsaw.w3.org/css-validator/#validate_by_input it does validate as "(CSS level 3 + SVG)"

So it might just be a matter of changing the profile used in the api ?

ArunSahadeo commented 5 years ago

Hi, I just saved your style.css.txt file as style.css and ran through my ValiCSS method, and it seems to throw the CSS errors back fine - although I noticed an error thrown by the JSON parser I am using, so will look into that.

css-errors

Please refer to the above.

ArunSahadeo commented 5 years ago

Sorry, was at work, I see what you mean now. I will see if that's viable.

ArunSahadeo commented 5 years ago

Hi @aphecetche I made the following CURL request on my machine - curl -sF "file=@style.css; type=text/css" -F output=json warning=0 profile=css3svg "https://jigsaw.w3.org/css-validator/validator" > test.json - and it returned CSS validation errors in the JSON as you can see from this fiddle: https://bpaste.net/show/2fab0ede8f2c

Supposedly css3svg is a possible value for the profile parameter, need to do some digging, but can you send over the stylesheet - not as a TXT file - so I can confirm whether it's to do with MIME type?

Once I have ruled out MIME type as a potential issue, I will play around with different values for the profile parameter - otherwise we'll just have to ask them to support css3svg as a profile parameter value.

aphecetche commented 5 years ago

Well, I guess your test already show that css3svg is not a value understood by the validator API as in the fiddle you point to it says " "csslevel" : "css3"" and all the errors are related to SVG keys. (and the mime type is not embedded into the file, right ?, so I don't see that as a plausible issue).

ArunSahadeo commented 5 years ago

Hi, the documentation is inconsistent for their API, but it seems as though the allowed values are css1, css2, css21, css3, svg, svgbasic, svgtiny, mobile, atsc-tv, tv and none.

I am going to enquire about this with them, to see if we can css3svg as an option, and will report back to you in this thread once I get an answer.

sideshowbarker commented 5 years ago

Note that https://validator.w3.org/nu/ now has support for checking CSS directly — using the CSS validator backend, with the CSS3+SVG profile.

Here’s how you can send a CSS stylesheet to https://validator.w3.org/nu/ for checking and get a JSON-formatted error report back:

curl -H "Content-Type: text/css; charset=utf-8" \
    --data-binary @style.css \
    https://validator.w3.org/nu/?out=json
ylafon commented 5 years ago

@ArunSahadeo I tried with a css file containing only a svg property.

curl -sF "file=@s.css; type=text/css" -F output=json warning=0 profile=css3svg "https://jigsaw.w3.org/css-validator/validator" returns "message" : "Property \u201Cfill\u201D doesn't exist : "

curl -sF "file=@s.css; type=text/css" -F output=json -F warning=0 -F profile=css3svg "https://jigsaw.w3.org/css-validator/validator" returns "errorcount" : 0,

So maybe your call is not correct. (note the multiple -F instead of just one)