Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Checker html/w3: Add support for SVG and XHTML #2246

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

kevinoid
Copy link
Contributor

This PR applies the same changes that were applied to html/validator in #2241 to w3/html so that it can be used to validate SVG and XHTML as well. It makes html/w3 nearly identical to html/validator, except for errorformat, and for w3 lacking some of validator's options.

Thanks for considering,
Kevin

@lcd047
Copy link
Collaborator

lcd047 commented Jan 30, 2019

I'm afraid I don't understand what are you trying to achieve here. Your patch is either too much or too little to check SVG files. If you're trying to duplicate the functionality of https://validator.w3.org/ just setting Content-Type is not going to cut it. There seems to be no documented way to distinguish between, say, SVG 1.0 and SVG 1.1 with the API. On the other hand, if you're trying to do DTD-based validation you need to supply the relevant DTDs, and your patch doesn't provide the means to do that.

Unrelated: a feature that isn't documented can be used (and maintained) only by its author. shrug

@kevinoid
Copy link
Contributor Author

I'm afraid I don't understand what are you trying to achieve here. Your patch is either too much or too little to check SVG files. If you're trying to duplicate the functionality of https://validator.w3.org/ just setting Content-Type is not going to cut it.

You are right. Good catch. I expected it to detect SVG without a DTD in the same way it detects HTML and XHTML without a DTD, but currently it validates SVG without a DTD as generic XML.

There seems to be no documented way to distinguish between, say, SVG 1.0 and SVG 1.1 with the API. On the other hand, if you're trying to do DTD-based validation you need to supply the relevant DTDs, and your patch doesn't provide the means to do that.

You can do this by setting the doctype POST parameter to SVG 1.0 or SVG 1.1 (or SVG 1.1 Tiny, SVG 1.1 Basic). The validator will add the DTD if it is missing and the doctype parameter is specified.

I could add code to detect the version from the version= attribute on the <svg> element. This would probably be painful to do correctly without an external XML parser. Alternatively, I could set doctype from g:syntastic_{type}_w3_doctype (and b:syntastic_{type}_w3_doctype?) with a default of SVG 1.1 for SVG. Or something else? Do you have a preference for how it should work?

Unrelated: a feature that isn't documented can be used (and maintained) only by its author. shrug

Ha. That was an oversight on my part. Good catch. Docs updated.

@lcd047
Copy link
Collaborator

lcd047 commented Jan 30, 2019

I could add code to detect the version from the version= attribute on the <svg> element. This would probably be painful to do correctly without an external XML parser. Alternatively, I could set doctype from g:syntastic_{type}_w3_doctype (and b:syntastic_{type}_w3_doctype?) with a default of SVG 1.1 for SVG. Or something else? Do you have a preference for how it should work?

Leaving this to the user (i.e. reading doctype from a variable) is probably the only reasonable approach. Reading it from the version attribute doesn't allow user to override it (in case somebody wants to check backwards compatibility, or whatever), and parsing XML in Vim is a hack at best.

@kevinoid
Copy link
Contributor Author

I agree. PR updated. Let me know what you think.

@lcd047
Copy link
Collaborator

lcd047 commented Jan 30, 2019

One more thing: please don't attribute to other people the new files you added. 😄

@kevinoid
Copy link
Contributor Author

One more thing: please don't attribute to other people the new files you added. 😄

Haha. Indeed. Are you referencing the Maintainer: lines? I had assumed that Martin Grenfell would continue to be the maintainer of html/w3, so the redirects would also fall under his purview. Should I change the Maintainer: lines in all 3 files (and doc/syntastic-checkers.txt?) or only svg/w3 and xhtml/w3? I'm certainly happy to help with maintenance of the stuff I touched in any case.

@lcd047
Copy link
Collaborator

lcd047 commented Jan 30, 2019

Only in the new checkers svg/w3 and xhtml/w3.

@kevinoid
Copy link
Contributor Author

Gotcha. That makes sense to me. Thanks! PR updated.

Apply the same changes that were applied to html/validator in
vim-syntastic#2241 to w3/html so that it can be used to
validate SVG and XHTML as well.

Add support for `g:syntastic_{type}_w3_doctype` to control the doctype
POST parameter sent to the validator.  This is necessary for SVG without
a DTD (which would otherwise be validated as generic XML) and useful for
all the types to control validation.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
@lcd047 lcd047 merged commit fca2caf into vim-syntastic:master Jan 30, 2019
@lcd047
Copy link
Collaborator

lcd047 commented Jan 30, 2019

Thank you. Merged with this patch on top: 8c76c04.

@kevinoid
Copy link
Contributor Author

Great! Thanks for all of the feedback and for merging it @lcd047!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants