forked from VimPlug/emmet-vim
fix indent. close #27
This commit is contained in:
@@ -318,12 +318,17 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
let str .= ">"
|
||||
let str .= current.value[1:-2]
|
||||
let nc = len(current.child)
|
||||
let dr = 0
|
||||
if nc > 0
|
||||
for n in range(nc)
|
||||
let child = current.child[n]
|
||||
if len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if child.multiplier > 1
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
endif
|
||||
endif
|
||||
let inner = zencoding#toString(child, type, 0, filters)
|
||||
@@ -334,17 +339,15 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
||||
else
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if nc > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (nc == 1 && len(current.child[0].name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current.child[0].name.',') == -1)
|
||||
let str .= "\n"
|
||||
endif
|
||||
if dr
|
||||
let str .= "\n"
|
||||
endif
|
||||
let str .= "</" . current_name . ">"
|
||||
endif
|
||||
if len(comment) > 0
|
||||
let str .= "\n<!-- /" . comment . " -->"
|
||||
endif
|
||||
if len(current_name) > 0 && (current.multiplier > 0 && !empty(current.parent) && len(current.parent.child) > 1)|| stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
|
||||
22
unittest.vim
22
unittest.vim
@@ -201,7 +201,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a[title=TITLE]",
|
||||
'result': "<a href=\"\" title=\"TITLE\"></a>",
|
||||
'result': "<a href=\"\" title=\"TITLE\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper.box",
|
||||
@@ -233,7 +233,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a",
|
||||
'result': "<a href=\"\"></a>",
|
||||
'result': "<a href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "obj",
|
||||
@@ -249,11 +249,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/].foo#hoge",
|
||||
'result': "<a id=\"hoge\" href=\"http://www.google.com/\" class=\"foo\"></a>",
|
||||
'result': "<a id=\"hoge\" href=\"http://www.google.com/\" class=\"foo\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/]{Google}",
|
||||
'result': "<a href=\"http://www.google.com/\">Google</a>",
|
||||
'result': "<a href=\"http://www.google.com/\">Google</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "{ZenCoding}",
|
||||
@@ -265,7 +265,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a>b>i<b",
|
||||
'result': "<a href=\"\"><b><i></i></b><b></b></a>",
|
||||
'result': "<a href=\"\"><b><i></i></b><b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i<<b",
|
||||
@@ -277,11 +277,11 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a[href=foo][class=bar]",
|
||||
'result': "<a href=\"foo\" class=\"bar\"></a>",
|
||||
'result': "<a href=\"foo\" class=\"bar\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]{foo}*2",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a><a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]*2{foo}",
|
||||
@@ -293,7 +293,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a{foo}*2>b",
|
||||
'result': "<a href=\"\">foo<b></b></a><a href=\"\">foo<b></b></a>",
|
||||
'result': "<a href=\"\">foo<b></b></a>\n<a href=\"\">foo<b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a*2{foo}>b",
|
||||
@@ -317,7 +317,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a#foo$$$*3",
|
||||
'result': "<a id=\"foo001\" href=\"\"></a><a id=\"foo002\" href=\"\"></a><a id=\"foo003\" href=\"\"></a>",
|
||||
'result': "<a id=\"foo001\" href=\"\"></a>\n<a id=\"foo002\" href=\"\"></a>\n<a id=\"foo003\" href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "ul+",
|
||||
@@ -381,7 +381,7 @@ finish
|
||||
},
|
||||
{
|
||||
'query': "a[title=\"Hello', world\" rel]",
|
||||
'result': "<a rel=\"\" href=\"\" title=\"Hello', world\"></a>",
|
||||
'result': "<a rel=\"\" href=\"\" title=\"Hello', world\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div>a#foo{bar}",
|
||||
@@ -464,7 +464,7 @@ finish
|
||||
'tests': [
|
||||
{
|
||||
'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\" />",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\" />\n",
|
||||
},
|
||||
{
|
||||
'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
|
||||
Reference in New Issue
Block a user