diff --git a/sparkup.py b/sparkup.py
index 9898421..4f31b27 100755
--- a/sparkup.py
+++ b/sparkup.py
@@ -302,7 +302,7 @@ def __init__(self, options=None, str=''):
self.tokens = []
self.str = str
self.options = options
- if self.options.has("filetype") and self.options.get("filetype") == "xml":
+ if self.options.has("xml"):
self.dialect = XmlDialect()
else:
self.dialect = HtmlDialect()
@@ -1095,7 +1095,6 @@ def has(self, attr):
cmdline_keys = [
('h', 'help', 'Shows help'),
('v', 'version', 'Shows the version'),
- ('', 'filetype=', 'enable html attribute fillings unless filetype=xml'),
('', 'no-guides', 'Deprecated'),
('', 'post-tag-guides', 'Adds comments at the end of DIV tags'),
('', 'textmate', 'Adds snippet info (textmate mode)'),
@@ -1105,6 +1104,7 @@ def has(self, attr):
('', 'no-last-newline', 'Skip the trailing newline'),
('', 'start-guide-format=', 'To be documented'), # << TODO
('', 'end-guide-format=', 'To be documented'), # << TODO
+ ('', 'xml', 'Skip html attribute fillings'),
('', 'no-html5-self-closing', 'Use HTML4
instead of HTML5
'),
]
diff --git a/vim/ftplugin/html/sparkup.vim b/vim/ftplugin/html/sparkup.vim
index 110b494..27ff97c 100644
--- a/vim/ftplugin/html/sparkup.vim
+++ b/vim/ftplugin/html/sparkup.vim
@@ -67,12 +67,11 @@ endif
function! s:Sparkup()
if !exists('s:sparkup')
let s:sparkup = exists('g:sparkup') ? g:sparkup : 'sparkup'
- let s:sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline'
- let s:sparkupArgs = s:sparkupArgs . ' --filetype=' . &filetype
- " check the user's path first. if not found then search relative to
- " sparkup.vim in the runtimepath.
if !executable(s:sparkup)
+ " If g:sparkup is not configured (and/or not found in $PATH),
+ " look for sparkup.vim in Vim's runtimepath.
+ " XXX: quite expensive for a Pathogen-like environment (where &rtp is huge)
let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g')
let s:sparkup = fnamemodify(findfile('sparkup.py', paths), ':p')
@@ -85,14 +84,28 @@ function! s:Sparkup()
endif
endif
let s:sparkup = '"' . s:sparkup . '"'
- let s:sparkup .= printf(' %s --indent-spaces=%s', s:sparkupArgs, &shiftwidth)
- " If the user's settings are to indent with tabs, do so!
- " TODO textmate version of this functionality
- if !&expandtab
- let s:sparkup .= ' --indent-tabs'
+ " Workaround for windows, where the Python file cannot be executed via shebang
+ if has('win32') || has('win64')
+ let s:sparkup = 'python ' . s:sparkup
endif
endif
- exec '.!python ' . s:sparkup
+
+ " Build arguments list (not cached, g:sparkupArgs might change, also
+ " &filetype, &expandtab etc)
+ let sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline'
+ " Pass '--xml' option, if 'xml' is used as filetype (default: none/'html')
+ " NOTE: &filetype can contain multiple values, e.g. 'smarty.html'
+ if index(split(&filetype, '\.'), 'xml') >= 0
+ let sparkupArgs .= ' --xml'
+ endif
+ " If the user's settings are to indent with tabs, do so!
+ " TODO textmate version of this functionality
+ if !&expandtab
+ let sparkupArgs .= ' --indent-tabs'
+ endif
+
+ let sparkupCmd = s:sparkup . printf(' %s --indent-spaces=%s', sparkupArgs, &shiftwidth)
+ exec '.!' . sparkupCmd
call s:SparkupNext()
endfunction