Open szantner opened 10 years ago
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?
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.
"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 - 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".
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.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:
but that may mess up line/character matches in the linter. I don't think this will work well.
@cfjedimaster - Good idea. It looks like the validator's web interface supports partials, but possibly only 4.0.1.
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)