Of course it is possible to use the good old online tools like the W3C Validator, but I think it would be more efficient to validate in Vim directly.
I tried the built-in HTML validation of a plugin called "Syntastic", which used HTML Tidy by default. Although it seems to work, I found out that HTML Tidy doesn't开发者_开发问答 really support HTML5 yet and the solution looks more like a hack. Please let me know if I'm wrong.
However I also found a rather old article about using an online service in Vim:
http://blog.whatwg.org/vim-checker
Although it didn't work for me so far, I think it is possible to make it work with Syntastic.
Last but not least, I checked the internet for some command line apps and this is all I found:
http://about.validator.nu/html5check.py
A script that uploads a file to the same online service and outputs errors to the commandline.
Does anybody of you know whether I can at least make this script work together with syntastic or Vim in general? Or does anybody know another solution? A step by step guide would be really cool.
thx in advance
UPDATE: a better solution for me was the following:
Download this script, make it executeable and put it into your path.
http://about.validator.nu/html5check.py
Then add this to you vimrc:
"check html
map ,h5 :!html5check %<CR>
You don't need to read the rest.
Wow, suddenly it worked and I wondered myself why not right away...
Here is my solution for Vim users like me:
- Install Syntastic
- Navigate to
[Syntastic plugin folder]/syntax_checkers/html.vim
Comment out the original
"let makeprg=..."
and"let errorformat=..."
Add the following snippet
let makeprg="html5check ".shellescape(expand('%'))
let errorformat='%m'
As you might guess it calls a commandline app to check the code.
In order to use it, download the following file and make sure it is executeable:
http://about.validator.nu/html5check.py
I removed the extension and pasted it to the other commandline apps I have in
opt/local/bin
. In your case it might be a different location.
Hope it helps somebody.
Here's a simple plugin that looks like it does the same thing.
https://github.com/sorin-ionescu/vim-htmlvalidator
ALE is the preferred lint engine for Vim if you're into IDE-like Vim-experience:
https://github.com/w0rp/ale#1-supported-languages-and-tools
Look under HTML - install one of these and what you get is asynchronous as-you-type HTML-validation.
精彩评论