brackets-w3cvalidation icon indicating copy to clipboard operation
brackets-w3cvalidation copied to clipboard

Validating partial documents

Open szantner opened this issue 11 years ago • 7 comments

Hi. Is there a possibility to validate partial documents (for example with the help of comments - like with jslint, jshint)?

As I have seen, it is possible with w3c validator to validate snippets (http://stackoverflow.com/questions/8061087/do-you-know-a-html-snippet-validator)

szantner avatar Aug 26 '14 15:08 szantner

Not sure. The question would be, how would I (I being the extension) know when you are submitting a snippet or a "full" file. Remember the linter isn't interactive. It is based on the entire file only. So your file may be a snippet, but by what logic would I know that?

cfjedimaster avatar Oct 02 '14 14:10 cfjedimaster

I think probably if the validation of the full html fails (maybe with some threshold - number of errors and warnings) it could be sent to the validator as a snippet. If that succeeds it could send a message that validated as snippet, failed as html. Another solution would be to simply check if there is no html tag or body tag or something general and then validate as snippet otherwise as full html document - marking it in the result of course. Providing an option to revalidate as full document perhaps. These are just ideas. Never wrote a brackets extension so I may be completely wrong. The whole thing came to me while working with AngularJS - where except for index.html the html files are snippets. I guess it might be an interesting issue with other js frameworks too.

szantner avatar Oct 03 '14 08:10 szantner

"Providing an option to revalidate as full document perhaps." - This can't be done as the linting isn't interactive.

However - I too have run into the issues w/ Angular templates. I'll look into this.

cfjedimaster avatar Oct 03 '14 10:10 cfjedimaster

@cfjedimaster - How about doing this the SASS way and assuming that files who's name begins with an underscore are partials? For example "_itemsPanel.html"? And maybe also any HTML file in a folder called "view" or "views".

alvint avatar Jan 05 '15 17:01 alvint

That feels like a risky thing to assume imo. We could simply say, if no html tag, assume partial. That would still work if folks forget

for example but include html, so it would correctly flag it, but if no , then we assume partial. Now - the issue is - does the remote service even support partials or ignoring those rules.

cfjedimaster avatar Jan 07 '15 21:01 cfjedimaster

Nope, while the w3c validator on the site lets you use a partial, the API does not: http://validator.w3.org/docs/api.html

So to make this work, I'd need to add a fake wrapper around the content. I could do:

Temp content

but that may mess up line/character matches in the linter. I don't think this will work well.

cfjedimaster avatar Jan 07 '15 21:01 cfjedimaster

@cfjedimaster - Good idea. It looks like the validator's web interface supports partials, but possibly only 4.0.1.

alvint avatar Jan 07 '15 21:01 alvint