From b34b53526cac2ee57fa026c624f6c2b595954f83 Mon Sep 17 00:00:00 2001 From: Kevin Locke Date: Mon, 28 Jan 2019 12:02:58 -0700 Subject: [PATCH] Checker html/w3: Add support for SVG and XHTML Apply the same changes that were applied to html/validator in vim-syntastic/syntastic#2241 to w3/html so that it can be used to validate SVG and XHTML as well. Signed-off-by: Kevin Locke --- syntax_checkers/html/w3.vim | 43 ++++++++++++++++++++++++++++-------- syntax_checkers/svg/w3.vim | 23 +++++++++++++++++++ syntax_checkers/xhtml/w3.vim | 23 +++++++++++++++++++ 3 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 syntax_checkers/svg/w3.vim create mode 100644 syntax_checkers/xhtml/w3.vim diff --git a/syntax_checkers/html/w3.vim b/syntax_checkers/html/w3.vim index e26381fab..41b5758e5 100644 --- a/syntax_checkers/html/w3.vim +++ b/syntax_checkers/html/w3.vim @@ -15,18 +15,39 @@ if exists('g:loaded_syntastic_html_w3_checker') endif let g:loaded_syntastic_html_w3_checker = 1 -if !exists('g:syntastic_html_w3_api') - let g:syntastic_html_w3_api = 'http://validator.w3.org/check' -endif - let s:save_cpo = &cpo set cpo&vim -function! SyntaxCheckers_html_w3_GetLocList() dict +" Constants {{{1 + +let s:DEFAULTS = { + \ 'api': 'https://validator.w3.org/check' } + +let s:CONTENT_TYPE = { + \ 'html': 'text/html', + \ 'svg': 'image/svg+xml', + \ 'xhtml': 'application/xhtml+xml' } + +" }}}1 + +" @vimlint(EVL101, 1, l:api) +function! SyntaxCheckers_html_w3_GetLocList() dict " {{{1 let buf = bufnr('') - let makeprg = self.getExecEscaped() . ' -q -L -s -F output=json ' . - \ '-F uploaded_file=@' . syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) . '\;type=text/html ' . - \ g:syntastic_html_w3_api + 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 . '_w3_' . key, get(s:DEFAULTS, key)) + endfor + let ctype = get(s:CONTENT_TYPE, type, '') + + " vint: -ProhibitUsingUndeclaredVariable + let makeprg = self.getExecEscaped() . ' -q -L -s --compressed -F output=json ' . + \ '-F uploaded_file=@' . fname . + \ (ctype !=# '' ? '\;type=' . ctype : '') . + \ '\;filename=' . fname . + \ ' ' . api + " vint: ProhibitUsingUndeclaredVariable let errorformat = \ '%A %\+{,' . @@ -50,7 +71,11 @@ function! SyntaxCheckers_html_w3_GetLocList() dict endfor return loclist -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', diff --git a/syntax_checkers/svg/w3.vim b/syntax_checkers/svg/w3.vim new file mode 100644 index 000000000..96718af41 --- /dev/null +++ b/syntax_checkers/svg/w3.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: w3.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: Martin Grenfell +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_svg_w3_checker') + finish +endif +let g:loaded_syntastic_svg_w3_checker = 1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'svg', + \ 'name': 'w3', + \ 'redirect': 'html/w3'}) + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/syntax_checkers/xhtml/w3.vim b/syntax_checkers/xhtml/w3.vim new file mode 100644 index 000000000..44896f7b7 --- /dev/null +++ b/syntax_checkers/xhtml/w3.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: w3.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: Martin Grenfell +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +" +"============================================================================ + +if exists('g:loaded_syntastic_xhtml_w3_checker') + finish +endif +let g:loaded_syntastic_xhtml_w3_checker = 1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'xhtml', + \ 'name': 'w3', + \ 'redirect': 'html/w3'}) + +" vim: set sw=4 sts=4 et fdm=marker: