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

Commit

Permalink
Checker html/validator can be used for xhtml and svg.
Browse files Browse the repository at this point in the history
  • Loading branch information
lcd047 committed Jan 22, 2019
1 parent 0d25f4f commit f6ec8a4
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 17 deletions.
198 changes: 198 additions & 0 deletions doc/syntastic-checkers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang*
Solidity.................................|syntastic-checkers-solidity|
SQL......................................|syntastic-checkers-sql|
Stylus...................................|syntastic-checkers-stylus|
SVG......................................|syntastic-checkers-svg|

Tcl......................................|syntastic-checkers-tcl|
TeX......................................|syntastic-checkers-tex|
Expand Down Expand Up @@ -3132,6 +3133,13 @@ Sets the "nsfilter" for the parser. See:

https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter

*'g:syntastic_html_validator_schema'*
Type: string
Default: empty
Sets the "schema" for the parser. See:

https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema

*'g:syntastic_html_validator_exec'*
Type: string
Default: "curl"
Expand All @@ -3153,6 +3161,8 @@ You can lookup the meaning of these codes in cURL's manual:

http://curl.haxx.se/docs/manpage.html#EXIT

See also: |syntastic-svg-validator|, |syntastic-xhtml-validator|.

------------------------------------------------------------------------------
10. W3 *syntastic-html-w3*

Expand Down Expand Up @@ -6563,6 +6573,103 @@ You might also find useful the "vim-stylus" plugin:

https://github.com/wavded/vim-stylus

==============================================================================
SYNTAX CHECKERS FOR SVG *syntastic-checkers-svg*

The following checkers are available for SVG (filetype "svg"):

1. Validator................|syntastic-svg-validator|

------------------------------------------------------------------------------
1. Validator *syntastic-svg-validator*

Name: validator
Maintainer: LCD 47 <lcd047@gmail.com>

"Validator" is a non-DTD-based HTML linter. See the project's page for
details:

http://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_svg_validator_api'*
Type: string
Default: "http://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:

http://validator.github.io/validator/#standalone

*'g:syntastic_svg_validator_parser'*
Type: string
Default: empty
Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4",
and "html4tr". References:

https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser

*'g:syntastic_svg_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_svg_validator_schema'*
Type: string
Default: empty
Sets the "schema" for the parser. See:

https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema

*'g:syntastic_svg_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_svg_validator_<option>' variables. The only exception
is 'g:syntastic_svg_validator_exec', which can be used to override the path
to the "cURL" executable.

Note~

Non-zero exit codes from "cURL" are typically network errors, and are signaled
by syntastic with messages such as: >
syntastic: error: checker svg/validator returned abnormal status 26
<
You can lookup the meaning of these codes in cURL's manual:

http://curl.haxx.se/docs/manpage.html#EXIT

Example~
>
let g:syntastic_svg_validator_parser = 'xml'
let g:syntastic_svg_validator_schema =
\ 'http://s.validator.nu/svg-xhtml5-rdf-mathml.rnc ' .
\ 'http://s.validator.nu/html5/assertions.sch ' .
\ 'http://c.validator.nu/all/'
<
See also: |syntastic-html-validator|, |syntastic-xhtml-validator|.

==============================================================================
SYNTAX CHECKERS FOR TCL *syntastic-checkers-tcl*

Expand Down Expand Up @@ -7375,6 +7482,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*
Expand Down Expand Up @@ -7470,6 +7578,96 @@ 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 <lcd047@gmail.com>

"Validator" is a non-DTD-based HTML linter. See the project's page for
details:

http://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: "http://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:

http://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". 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_schema'*
Type: string
Default: empty
Sets the "schema" for the parser. See:

https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema

*'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_<option>' variables. The only exception
is 'g:syntastic_xhtml_validator_exec', which can be used to override the path
to the "cURL" executable.

Note~

Non-zero exit codes from "cURL" are typically network errors, and are signaled
by syntastic with messages such as: >
syntastic: error: checker xhtml/validator returned abnormal status 26
<
You can lookup the meaning of these codes in cURL's manual:

http://curl.haxx.se/docs/manpage.html#EXIT

Example~
>
let g:syntastic_xhtml_validator_parser = 'xmldtd'
let g:syntastic_xhtml_validator_schema =
\ 'http://s.validator.nu/xhtml5.rnc ' .
\ 'http://s.validator.nu/html5/assertions.sch ' .
\ 'http://c.validator.nu/all/
<
See also: |syntastic-html-validator|, |syntastic-svg-validator|.

==============================================================================
SYNTAX CHECKERS FOR XML *syntastic-checkers-xml*

Expand Down
2 changes: 1 addition & 1 deletion plugin/syntastic.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:_SYNTASTIC_START
endif

let g:_SYNTASTIC_VERSION = '3.9.0-23'
let g:_SYNTASTIC_VERSION = '3.9.0-24'
lockvar g:_SYNTASTIC_VERSION

" Sanity checks {{{1
Expand Down
1 change: 1 addition & 0 deletions plugin/syntastic/registry.vim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ let s:_DEFAULT_CHECKERS = {
\ 'solidity': ['solc'],
\ 'sql': ['sqlint'],
\ 'stylus': ['stylint'],
\ 'svg': [],
\ 'tcl': ['nagelfar'],
\ 'tex': ['lacheck', 'chktex'],
\ 'texinfo': ['makeinfo'],
Expand Down
56 changes: 40 additions & 16 deletions syntax_checkers/html/validator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,48 @@ if exists('g:loaded_syntastic_html_validator_checker')
endif
let g:loaded_syntastic_html_validator_checker=1

if !exists('g:syntastic_html_validator_api')
let g:syntastic_html_validator_api = 'https://validator.nu/'
endif
let s:save_cpo = &cpo
set cpo&vim

if !exists('g:syntastic_html_validator_parser')
let g:syntastic_html_validator_parser = ''
endif
" Constants {{{1

if !exists('g:syntastic_html_validator_nsfilter')
let g:syntastic_html_validator_nsfilter = ''
endif
let s:DEFAULTS = {
\ 'api': 'https://validator.nu/',
\ 'nsfilter': '',
\ 'parser': '',
\ 'schema': '' }

let s:save_cpo = &cpo
set cpo&vim
let s:CONTENT_TYPE = {
\ 'html': 'text/html',
\ 'svg': 'image/svg+xml',
\ 'xhtm': 'application/xhtml+xml' }

" }}}1

function! SyntaxCheckers_html_validator_GetLocList() dict
" @vimlint(EVL101, 1, l:api)
" @vimlint(EVL101, 1, l:nsfilter)
" @vimlint(EVL101, 1, l:parser)
" @vimlint(EVL101, 1, l:schema)
function! SyntaxCheckers_html_validator_GetLocList() dict " {{{1
let buf = bufnr('')
let type = self.getFiletype()
let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p'))

for key in keys(s:DEFAULTS)
let l:{key} = syntastic#util#var(type . '_validator_' . key, get(s:DEFAULTS, key))
endfor
let ctype = get(s:CONTENT_TYPE, type, '')

" vint: -ProhibitUsingUndeclaredVariable
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
\ (nsfilter !=# '' ? ' -F nsfilter=' . syntastic#util#shescape(nsfilter) : '') .
\ (parser !=# '' ? ' -F parser=' . parser : '') .
\ (schema !=# '' ? ' -F schema=' . syntastic#util#shescape(schema) : '') .
\ ' -F doc=@' . fname .
\ (ctype !=# '' ? '\;type=' . ctype : '') .
\ '\;filename=' . fname .
\ ' ' . api
" vint: ProhibitUsingUndeclaredVariable

let errorformat =
\ '%E"%f":%l: %trror: %m,' .
Expand All @@ -57,7 +77,11 @@ function! SyntaxCheckers_html_validator_GetLocList() dict
\ 'errorformat': errorformat,
\ 'preprocess': 'validator',
\ 'returns': [0] })
endfunction
endfunction " }}}1
" @vimlint(EVL101, 0, l:schema)
" @vimlint(EVL101, 0, l:parser)
" @vimlint(EVL101, 0, l:nsfilter)
" @vimlint(EVL101, 0, l:api)

call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'html',
Expand Down

0 comments on commit f6ec8a4

Please sign in to comment.