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

Commit f6ec8a4

Browse files
committed
Checker html/validator can be used for xhtml and svg.
1 parent 0d25f4f commit f6ec8a4

File tree

4 files changed

+240
-17
lines changed

4 files changed

+240
-17
lines changed

doc/syntastic-checkers.txt

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ SYNTAX CHECKERS BY LANGUAGE *syntastic-checkers-lang*
107107
Solidity.................................|syntastic-checkers-solidity|
108108
SQL......................................|syntastic-checkers-sql|
109109
Stylus...................................|syntastic-checkers-stylus|
110+
SVG......................................|syntastic-checkers-svg|
110111

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

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

3136+
*'g:syntastic_html_validator_schema'*
3137+
Type: string
3138+
Default: empty
3139+
Sets the "schema" for the parser. See:
3140+
3141+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
3142+
31353143
*'g:syntastic_html_validator_exec'*
31363144
Type: string
31373145
Default: "curl"
@@ -3153,6 +3161,8 @@ You can lookup the meaning of these codes in cURL's manual:
31533161

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

3164+
See also: |syntastic-svg-validator|, |syntastic-xhtml-validator|.
3165+
31563166
------------------------------------------------------------------------------
31573167
10. W3 *syntastic-html-w3*
31583168

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

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

6576+
==============================================================================
6577+
SYNTAX CHECKERS FOR SVG *syntastic-checkers-svg*
6578+
6579+
The following checkers are available for SVG (filetype "svg"):
6580+
6581+
1. Validator................|syntastic-svg-validator|
6582+
6583+
------------------------------------------------------------------------------
6584+
1. Validator *syntastic-svg-validator*
6585+
6586+
Name: validator
6587+
Maintainer: LCD 47 <[email protected]>
6588+
6589+
"Validator" is a non-DTD-based HTML linter. See the project's page for
6590+
details:
6591+
6592+
http://validator.github.io/validator/
6593+
6594+
As a syntastic linter, you can validate your files against the online service
6595+
(see https://validator.nu/), or you can install "vnu.jar":
6596+
6597+
https://github.com/validator/validator/releases/latest
6598+
6599+
then run it as a HTTP server: >
6600+
$ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888
6601+
<
6602+
Requirement~
6603+
6604+
This checker uses cURL:
6605+
6606+
http://curl.haxx.se/
6607+
6608+
Checker options~
6609+
6610+
*'g:syntastic_svg_validator_api'*
6611+
Type: string
6612+
Default: "http://validator.nu/"
6613+
URL of the service to use for checking. Leave it to the default to run the
6614+
checks against "https://validator.nu/", or set it to "http://localhost:8888/"
6615+
if you have "vnu.jar" installed, and you're running it as a standalone HTTP
6616+
server. See:
6617+
6618+
http://validator.github.io/validator/#standalone
6619+
6620+
*'g:syntastic_svg_validator_parser'*
6621+
Type: string
6622+
Default: empty
6623+
Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4",
6624+
and "html4tr". References:
6625+
6626+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser
6627+
6628+
*'g:syntastic_svg_validator_nsfilter'*
6629+
Type: string
6630+
Default: empty
6631+
Sets the "nsfilter" for the parser. See:
6632+
6633+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
6634+
6635+
*'g:syntastic_svg_validator_schema'*
6636+
Type: string
6637+
Default: empty
6638+
Sets the "schema" for the parser. See:
6639+
6640+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
6641+
6642+
*'g:syntastic_svg_validator_exec'*
6643+
Type: string
6644+
Default: "curl"
6645+
Path to the "cURL" executable. Override it with a full path if your "cURL" is
6646+
not installed in a standard location.
6647+
6648+
This checker doesn't call the "makeprgBuild()" function, and thus it ignores
6649+
the usual 'g:syntastic_svg_validator_<option>' variables. The only exception
6650+
is 'g:syntastic_svg_validator_exec', which can be used to override the path
6651+
to the "cURL" executable.
6652+
6653+
Note~
6654+
6655+
Non-zero exit codes from "cURL" are typically network errors, and are signaled
6656+
by syntastic with messages such as: >
6657+
syntastic: error: checker svg/validator returned abnormal status 26
6658+
<
6659+
You can lookup the meaning of these codes in cURL's manual:
6660+
6661+
http://curl.haxx.se/docs/manpage.html#EXIT
6662+
6663+
Example~
6664+
>
6665+
let g:syntastic_svg_validator_parser = 'xml'
6666+
let g:syntastic_svg_validator_schema =
6667+
\ 'http://s.validator.nu/svg-xhtml5-rdf-mathml.rnc ' .
6668+
\ 'http://s.validator.nu/html5/assertions.sch ' .
6669+
\ 'http://c.validator.nu/all/'
6670+
<
6671+
See also: |syntastic-html-validator|, |syntastic-xhtml-validator|.
6672+
65666673
==============================================================================
65676674
SYNTAX CHECKERS FOR TCL *syntastic-checkers-tcl*
65686675

@@ -7375,6 +7482,7 @@ The following checkers are available for xHTML (filetype "xhtml"):
73757482
1. HTML Tidy................|syntastic-xhtml-tidy|
73767483
2. jshint...................|syntastic-xhtml-jshint|
73777484
3. proselint................|syntastic-xhtml-proselint|
7485+
4. Validator................|syntastic-xhtml-validator|
73787486

73797487
------------------------------------------------------------------------------
73807488
1. HTML tidy *syntastic-xhtml-tidy*
@@ -7470,6 +7578,96 @@ See also: |syntastic-asciidoc-proselint|, |syntastic-help-proselint|,
74707578
|syntastic-rst-proselint|, |syntastic-tex-proselint|,
74717579
|syntastic-texinfo-proselint|, |syntastic-text-proselint|.
74727580

7581+
------------------------------------------------------------------------------
7582+
4. Validator *syntastic-xhtml-validator*
7583+
7584+
Name: validator
7585+
Maintainer: LCD 47 <[email protected]>
7586+
7587+
"Validator" is a non-DTD-based HTML linter. See the project's page for
7588+
details:
7589+
7590+
http://validator.github.io/validator/
7591+
7592+
As a syntastic linter, you can validate your files against the online service
7593+
(see https://validator.nu/), or you can install "vnu.jar":
7594+
7595+
https://github.com/validator/validator/releases/latest
7596+
7597+
then run it as a HTTP server: >
7598+
$ java -Xss512k -cp /path/to/vnu.jar nu.validator.servlet.Main 8888
7599+
<
7600+
Requirement~
7601+
7602+
This checker uses cURL:
7603+
7604+
http://curl.haxx.se/
7605+
7606+
Checker options~
7607+
7608+
*'g:syntastic_xhtml_validator_api'*
7609+
Type: string
7610+
Default: "http://validator.nu/"
7611+
URL of the service to use for checking. Leave it to the default to run the
7612+
checks against "https://validator.nu/", or set it to "http://localhost:8888/"
7613+
if you have "vnu.jar" installed, and you're running it as a standalone HTTP
7614+
server. See:
7615+
7616+
http://validator.github.io/validator/#standalone
7617+
7618+
*'g:syntastic_xhtml_validator_parser'*
7619+
Type: string
7620+
Default: empty
7621+
Parser to use. Legal values are: "xml", "xmldtd", "html", "html5", "html4",
7622+
and "html4tr". References:
7623+
7624+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#parser
7625+
7626+
*'g:syntastic_xhtml_validator_nsfilter'*
7627+
Type: string
7628+
Default: empty
7629+
Sets the "nsfilter" for the parser. See:
7630+
7631+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#nsfilter
7632+
7633+
*'g:syntastic_xhtml_validator_schema'*
7634+
Type: string
7635+
Default: empty
7636+
Sets the "schema" for the parser. See:
7637+
7638+
https://wiki.whatwg.org/wiki/Validator.nu_Common_Input_Parameters#schema
7639+
7640+
*'g:syntastic_xhtml_validator_exec'*
7641+
Type: string
7642+
Default: "curl"
7643+
Path to the "cURL" executable. Override it with a full path if your "cURL" is
7644+
not installed in a standard location.
7645+
7646+
This checker doesn't call the "makeprgBuild()" function, and thus it ignores
7647+
the usual 'g:syntastic_xhtml_validator_<option>' variables. The only exception
7648+
is 'g:syntastic_xhtml_validator_exec', which can be used to override the path
7649+
to the "cURL" executable.
7650+
7651+
Note~
7652+
7653+
Non-zero exit codes from "cURL" are typically network errors, and are signaled
7654+
by syntastic with messages such as: >
7655+
syntastic: error: checker xhtml/validator returned abnormal status 26
7656+
<
7657+
You can lookup the meaning of these codes in cURL's manual:
7658+
7659+
http://curl.haxx.se/docs/manpage.html#EXIT
7660+
7661+
Example~
7662+
>
7663+
let g:syntastic_xhtml_validator_parser = 'xmldtd'
7664+
let g:syntastic_xhtml_validator_schema =
7665+
\ 'http://s.validator.nu/xhtml5.rnc ' .
7666+
\ 'http://s.validator.nu/html5/assertions.sch ' .
7667+
\ 'http://c.validator.nu/all/
7668+
<
7669+
See also: |syntastic-html-validator|, |syntastic-svg-validator|.
7670+
74737671
==============================================================================
74747672
SYNTAX CHECKERS FOR XML *syntastic-checkers-xml*
74757673

plugin/syntastic.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if has('reltime')
1919
lockvar! g:_SYNTASTIC_START
2020
endif
2121

22-
let g:_SYNTASTIC_VERSION = '3.9.0-23'
22+
let g:_SYNTASTIC_VERSION = '3.9.0-24'
2323
lockvar g:_SYNTASTIC_VERSION
2424

2525
" Sanity checks {{{1

plugin/syntastic/registry.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ let s:_DEFAULT_CHECKERS = {
9292
\ 'solidity': ['solc'],
9393
\ 'sql': ['sqlint'],
9494
\ 'stylus': ['stylint'],
95+
\ 'svg': [],
9596
\ 'tcl': ['nagelfar'],
9697
\ 'tex': ['lacheck', 'chktex'],
9798
\ 'texinfo': ['makeinfo'],

syntax_checkers/html/validator.vim

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,48 @@ if exists('g:loaded_syntastic_html_validator_checker')
1515
endif
1616
let g:loaded_syntastic_html_validator_checker=1
1717

18-
if !exists('g:syntastic_html_validator_api')
19-
let g:syntastic_html_validator_api = 'https://validator.nu/'
20-
endif
18+
let s:save_cpo = &cpo
19+
set cpo&vim
2120

22-
if !exists('g:syntastic_html_validator_parser')
23-
let g:syntastic_html_validator_parser = ''
24-
endif
21+
" Constants {{{1
2522

26-
if !exists('g:syntastic_html_validator_nsfilter')
27-
let g:syntastic_html_validator_nsfilter = ''
28-
endif
23+
let s:DEFAULTS = {
24+
\ 'api': 'https://validator.nu/',
25+
\ 'nsfilter': '',
26+
\ 'parser': '',
27+
\ 'schema': '' }
2928

30-
let s:save_cpo = &cpo
31-
set cpo&vim
29+
let s:CONTENT_TYPE = {
30+
\ 'html': 'text/html',
31+
\ 'svg': 'image/svg+xml',
32+
\ 'xhtm': 'application/xhtml+xml' }
33+
34+
" }}}1
3235

33-
function! SyntaxCheckers_html_validator_GetLocList() dict
36+
" @vimlint(EVL101, 1, l:api)
37+
" @vimlint(EVL101, 1, l:nsfilter)
38+
" @vimlint(EVL101, 1, l:parser)
39+
" @vimlint(EVL101, 1, l:schema)
40+
function! SyntaxCheckers_html_validator_GetLocList() dict " {{{1
3441
let buf = bufnr('')
42+
let type = self.getFiletype()
3543
let fname = syntastic#util#shescape(fnamemodify(bufname(buf), ':p'))
44+
45+
for key in keys(s:DEFAULTS)
46+
let l:{key} = syntastic#util#var(type . '_validator_' . key, get(s:DEFAULTS, key))
47+
endfor
48+
let ctype = get(s:CONTENT_TYPE, type, '')
49+
50+
" vint: -ProhibitUsingUndeclaredVariable
3651
let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F out=gnu -F asciiquotes=yes' .
37-
\ (g:syntastic_html_validator_parser !=# '' ? ' -F parser=' . g:syntastic_html_validator_parser : '') .
38-
\ (g:syntastic_html_validator_nsfilter !=# '' ? ' -F nsfilter=' . g:syntastic_html_validator_nsfilter : '') .
39-
\ ' -F doc=@' . fname . '\;type=text/html\;filename=' . fname . ' ' . g:syntastic_html_validator_api
52+
\ (nsfilter !=# '' ? ' -F nsfilter=' . syntastic#util#shescape(nsfilter) : '') .
53+
\ (parser !=# '' ? ' -F parser=' . parser : '') .
54+
\ (schema !=# '' ? ' -F schema=' . syntastic#util#shescape(schema) : '') .
55+
\ ' -F doc=@' . fname .
56+
\ (ctype !=# '' ? '\;type=' . ctype : '') .
57+
\ '\;filename=' . fname .
58+
\ ' ' . api
59+
" vint: ProhibitUsingUndeclaredVariable
4060

4161
let errorformat =
4262
\ '%E"%f":%l: %trror: %m,' .
@@ -57,7 +77,11 @@ function! SyntaxCheckers_html_validator_GetLocList() dict
5777
\ 'errorformat': errorformat,
5878
\ 'preprocess': 'validator',
5979
\ 'returns': [0] })
60-
endfunction
80+
endfunction " }}}1
81+
" @vimlint(EVL101, 0, l:schema)
82+
" @vimlint(EVL101, 0, l:parser)
83+
" @vimlint(EVL101, 0, l:nsfilter)
84+
" @vimlint(EVL101, 0, l:api)
6185

6286
call g:SyntasticRegistry.CreateAndRegisterChecker({
6387
\ 'filetype': 'html',

0 commit comments

Comments
 (0)