From 86b38d07387e03d6bd4ad12157f4e01c6529f5e4 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 21 Jan 2019 14:36:49 -0700 Subject: [PATCH 1/3] Refactor SyntaxCheckers_html_validator_GetLocList Refactor SyntaxCheckers_html_validator_GetLocList into SyntaxCheckers_html_validator_GetLocListForType which takes the escaped executable and type as arguments and call it from a new SyntaxCheckers_html_validator_GetLocList. This will allow sharing the validator.nu logic between checkers for multiple types. Signed-off-by: Kevin Locke --- syntax_checkers/html/validator.vim | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/syntax_checkers/html/validator.vim b/syntax_checkers/html/validator.vim index 007be8436..8383f41c6 100644 --- a/syntax_checkers/html/validator.vim +++ b/syntax_checkers/html/validator.vim @@ -30,13 +30,16 @@ endif let s:save_cpo = &cpo set cpo&vim -function! SyntaxCheckers_html_validator_GetLocList() dict +function! SyntaxCheckers_html_validator_GetLocListForType(exec_escaped, type) let buf = bufnr('') let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) - let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F out=gnu -F asciiquotes=yes' . - \ (g:syntastic_html_validator_parser !=# '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') . - \ (g:syntastic_html_validator_nsfilter !=# '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') . - \ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api + let media_type = + \ a:type ==# 'html' ? 'text/html' : + \ '' + let makeprg = a:exec_escaped . ' -q -L -s --compressed -F out=gnu -F asciiquotes=yes' . + \ (g:syntastic_{a:type}_validator_parser !=# '' ? ' -F parser=' . g:syntastic_{a:type}_validator_parser : '') . + \ (g:syntastic_{a:type}_validator_nsfilter !=# '' ? ' -F nsfilter=' . g:syntastic_{a:type}_validator_nsfilter : '') . + \ ' -F doc=@' . fname . (media_type !=# '' ? '\;type=' . media_type : '') . '\;filename=' . fname . ' ' . g:syntastic_{a:type}_validator_api let errorformat = \ '%E"%f":%l: %trror: %m,' . @@ -59,6 +62,10 @@ function! SyntaxCheckers_html_validator_GetLocList() dict \ 'returns': [0] }) endfunction +function! SyntaxCheckers_html_validator_GetLocList() dict + return SyntaxCheckers_html_validator_GetLocListForType(self.getExecEscaped(), 'html') +endfunction + call g:SyntasticRegistry.CreateAndRegisterChecker({ \ 'filetype': 'html', \ 'name': 'validator', From 6b0539c7a57b96d54caf6f862e3d397d818306f4 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 21 Jan 2019 14:40:30 -0700 Subject: [PATCH 2/3] Add xhtml/validator checker This checker shares most of its logic with html/validator which it loads via :runtime! (using the same convention as checkers based on pyflakes). Signed-off-by: Kevin Locke --- doc/syntastic-checkers.txt | 74 +++++++++++++++++++++++++++++ syntax_checkers/html/validator.vim | 1 + syntax_checkers/xhtml/validator.vim | 47 ++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 syntax_checkers/xhtml/validator.vim diff --git a/doc/syntastic-checkers.txt b/doc/syntastic-checkers.txt index b2c347ba8..fc7b56e94 100644 --- a/doc/syntastic-checkers.txt +++ b/doc/syntastic-checkers.txt @@ -7375,6 +7375,7 @@ The following checkers are available for xHTML (filetype "xhtml"): 1. HTML Tidy................|syntastic-xhtml-tidy| 2. jshint...................|syntastic-xhtml-jshint| 3. proselint................|syntastic-xhtml-proselint| + 4. validator................|syntastic-xhtml-validator| ------------------------------------------------------------------------------ 1. HTML tidy *syntastic-xhtml-tidy* @@ -7470,6 +7471,79 @@ See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|, |syntastic-rst-proselint|, |syntastic-tex-proselint|, |syntastic-texinfo-proselint|, |syntastic-text-proselint|. +------------------------------------------------------------------------------ +4. Validator *syntastic-xhtml-validator* + +Name: validator +Maintainer: LCD 47 + +"Validator" is a non-DTD-based HTML linter. See the project's page for +details: + + https://validator.github.io/validator/ + +As a syntastic linter, you can validate your files against the online service +(see https://validator.nu/), or you can install "vnu.jar": + + https://github.com/validator/validator/releases/latest + +then run it as a HTTP server: > + $ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888 +< +Requirement~ + +This checker uses cURL: + + http://curl.haxx.se/ + +Checker options~ + + *'g:syntastic_xhtml_validator_api'* +Type: string +Default: "https://validator.nu/" +URL of the service to use for checking. Leave it to the default to run the +checks against "https://validator.nu/", or set it to "http://localhost:8888/" +if you have "vnu.jar" installed, and you're running it as a standalone HTTP +server. See: + + https://validator.github.io/validator/#standalone + + *'g:syntastic_xhtml_validator_parser'* +Type: string +Default: empty +Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4", +and "html4tr". Set it to "html5" to check HTML5 files. References: + + https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser + + *'g:syntastic_xhtml_validator_nsfilter'* +Type: string +Default: empty +Sets the "nsfilter" for the parser. See: + + https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter + + *'g:syntastic_xhtml_validator_exec'* +Type: string +Default: "curl" +Path to the "cURL" executable. Override it with a full path if your "cURL" is +not installed in a standard location. + +This checker doesn't call the "makeprgBuild()" function, and thus it ignores +the usual 'g:syntastic_xhtml_validator_