From 8551b28a74b2180886bc54d089e120bc187a1fed Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 11 Jun 2012 10:05:41 +0900 Subject: [PATCH] fix indent. close #27 --- autoload/zencoding/lang/html.vim | 15 +++++++++------ unittest.vim | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/autoload/zencoding/lang/html.vim b/autoload/zencoding/lang/html.vim index 46bee05..ba388fc 100644 --- a/autoload/zencoding/lang/html.vim +++ b/autoload/zencoding/lang/html.vim @@ -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 .= "" endif if len(comment) > 0 let str .= "\n" 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 diff --git a/unittest.vim b/unittest.vim index e761518..d93a524 100644 --- a/unittest.vim +++ b/unittest.vim @@ -201,7 +201,7 @@ finish }, { 'query': "a[title=TITLE]", - 'result': "", + 'result': "\n", }, { 'query': "div#wrapper.box", @@ -233,7 +233,7 @@ finish }, { 'query': "a", - 'result': "", + 'result': "\n", }, { 'query': "obj", @@ -249,11 +249,11 @@ finish }, { 'query': "a[href=http://www.google.com/].foo#hoge", - 'result': "", + 'result': "\n", }, { 'query': "a[href=http://www.google.com/]{Google}", - 'result': "Google", + 'result': "Google\n", }, { 'query': "{ZenCoding}", @@ -265,7 +265,7 @@ finish }, { 'query': "a>b>i", + 'result': "\n", }, { 'query': "a>b>i<", + 'result': "\n", }, { 'query': "a[a=b][b=c=d][e]{foo}*2", - 'result': "foofoo", + 'result': "foo\nfoo\n", }, { 'query': "a[a=b][b=c=d][e]*2{foo}", @@ -293,7 +293,7 @@ finish }, { 'query': "a{foo}*2>b", - 'result': "foofoo", + 'result': "foo\nfoo\n", }, { 'query': "a*2{foo}>b", @@ -317,7 +317,7 @@ finish }, { 'query': "a#foo$$$*3", - 'result': "", + 'result': "\n\n\n", }, { 'query': "ul+", @@ -381,7 +381,7 @@ finish }, { 'query': "a[title=\"Hello', world\" rel]", - 'result': "", + 'result': "\n", }, { 'query': "div>a#foo{bar}", @@ -464,7 +464,7 @@ finish 'tests': [ { 'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\,\\i$$$$", - 'result': "\"\"", + 'result': "\"\"\n", }, { 'query': "img[src=/logo.png]$$$$\\,\\i$$$$",