forked from VimPlug/emmet-vim
Add default attributes(emmet v1.1beta)
This commit is contained in:
@@ -191,27 +191,34 @@ function! emmet#lang#html#parseIntoTree(abbr, type)
|
|||||||
endif
|
endif
|
||||||
if item[0] == '['
|
if item[0] == '['
|
||||||
let atts = item[1:-2]
|
let atts = item[1:-2]
|
||||||
while len(atts)
|
if matchstr(atts, '^\s*\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)') == ''
|
||||||
let amat = matchstr(atts, '\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
|
let keys = keys(current.attr)
|
||||||
if len(amat) == 0
|
if len(keys) > 0
|
||||||
break
|
let current.attr[keys[0]] = atts
|
||||||
endif
|
endif
|
||||||
let key = split(amat, '=')[0]
|
else
|
||||||
let Val = amat[len(key)+1:]
|
while len(atts)
|
||||||
if key =~ '\.$' && Val == ''
|
let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
|
||||||
let key = key[:-2]
|
if len(amat) == 0
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
let key = split(amat, '=')[0]
|
||||||
|
let Val = amat[len(key)+1:]
|
||||||
|
if key =~ '\.$' && Val == ''
|
||||||
|
let key = key[:-2]
|
||||||
|
unlet Val
|
||||||
|
let Val = function('emmet#types#true')
|
||||||
|
elseif Val =~ '^["'']'
|
||||||
|
let Val = Val[1:-2]
|
||||||
|
endif
|
||||||
|
let current.attr[key] = Val
|
||||||
|
if index(current.attrs_order, key) == -1
|
||||||
|
let current.attrs_order += [key]
|
||||||
|
endif
|
||||||
|
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||||
unlet Val
|
unlet Val
|
||||||
let Val = function('emmet#types#true')
|
endwhile
|
||||||
elseif Val =~ '^["'']'
|
endif
|
||||||
let Val = Val[1:-2]
|
|
||||||
endif
|
|
||||||
let current.attr[key] = Val
|
|
||||||
if index(current.attrs_order, key) == -1
|
|
||||||
let current.attrs_order += [key]
|
|
||||||
endif
|
|
||||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
|
||||||
unlet Val
|
|
||||||
endwhile
|
|
||||||
endif
|
endif
|
||||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
||||||
endwhile
|
endwhile
|
||||||
|
|||||||
45
unittest.vim
45
unittest.vim
@@ -1,3 +1,4 @@
|
|||||||
|
" {{{
|
||||||
let s:sfile = expand('<sfile>')
|
let s:sfile = expand('<sfile>')
|
||||||
|
|
||||||
function! s:reload(d)
|
function! s:reload(d)
|
||||||
@@ -192,10 +193,11 @@ command! -nargs=* -complete=customlist,g:emmet_unittest_complete EmmetUnitTest c
|
|||||||
if s:sfile == expand('%:p')
|
if s:sfile == expand('%:p')
|
||||||
EmmetUnitTest
|
EmmetUnitTest
|
||||||
endif
|
endif
|
||||||
|
" }}}
|
||||||
|
|
||||||
finish
|
finish
|
||||||
[
|
[
|
||||||
{
|
{ 'test-html': "{{{",
|
||||||
'type': "html",
|
'type': "html",
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -580,6 +582,15 @@ finish
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'name': 'default attributes',
|
||||||
|
'tests': [
|
||||||
|
{
|
||||||
|
'query': "p.title>a[/hoge/]",
|
||||||
|
'result': "<p class=\"title\"><a href=\"/hoge/\"></a></p>\n",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'name': 'multiple group',
|
'name': 'multiple group',
|
||||||
'tests': [
|
'tests': [
|
||||||
@@ -603,8 +614,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-css': '{{{',
|
||||||
'type': 'css',
|
'type': 'css',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -689,8 +700,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-haml': '{{{',
|
||||||
'type': 'haml',
|
'type': 'haml',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -745,8 +756,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-slim': "{{{",
|
||||||
'type': 'slim',
|
'type': 'slim',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -801,8 +812,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-xsl': "{{{",
|
||||||
'type': 'xsl',
|
'type': 'xsl',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -819,8 +830,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-xsd': "{{{",
|
||||||
'type': 'xsd',
|
'type': 'xsd',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -833,8 +844,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-mustache': "{{{",
|
||||||
'type': 'mustache',
|
'type': 'mustache',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -851,8 +862,8 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
{
|
{ 'test-sass': "{{{",
|
||||||
'type': 'sass',
|
'type': 'sass',
|
||||||
'categories': [
|
'categories': [
|
||||||
{
|
{
|
||||||
@@ -937,6 +948,6 @@ finish
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
'dummy': "}}}"},
|
||||||
]
|
]
|
||||||
" vim:set et:
|
" vim:set et fdm=marker:
|
||||||
|
|||||||
Reference in New Issue
Block a user