From 7b0c846018eedad6043dc12d2d6cf73185320533 Mon Sep 17 00:00:00 2001 From: mattn Date: Sat, 2 Jun 2012 23:06:28 +0900 Subject: [PATCH] fix re-set parent of brother node. all tests are passed again! --- autoload/zencoding.vim | 2 +- autoload/zencoding/lang/html.vim | 9 ++++++--- unittest.vim | 12 +++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim index e15d319..71b1269 100644 --- a/autoload/zencoding.vim +++ b/autoload/zencoding.vim @@ -1,7 +1,7 @@ "============================================================================= " zencoding.vim " Author: Yasuhiro Matsumoto -" Last Change: 01-Jun-2012. +" Last Change: 02-Jun-2012. let s:save_cpo = &cpo set cpo&vim diff --git a/autoload/zencoding/lang/html.vim b/autoload/zencoding/lang/html.vim index 6976c49..9ddde00 100644 --- a/autoload/zencoding/lang/html.vim +++ b/autoload/zencoding/lang/html.vim @@ -21,7 +21,7 @@ function! zencoding#lang#html#findTokens(str) if token == '' break endif - if token =~ '^\s' + if token =~ '^\s' let token = matchstr(token, '^\s*\zs.*') let last_pos = stridx(str, token, pos) endif @@ -218,6 +218,7 @@ function! zencoding#lang#html#parseIntoTree(abbr, type) break endif let parent = tmp + let current.parent = tmp endfor endif @@ -301,7 +302,9 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters, let current_name = substitute(current.name, '\$$', itemno+1, '') if len(current.parent.name) > 0 && current.multiplier > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 - let str .= "\n" + if current.parent.multiplier > 0 + let str .= "\n" + endif endif let tmp = '<' . current_name @@ -365,7 +368,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters, else if inline == 0 if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 - let str .= " />\n" + let str .= " />" else let str .= ">" . inner . '${cursor}" endif diff --git a/unittest.vim b/unittest.vim index b1ead31..abffcb9 100644 --- a/unittest.vim +++ b/unittest.vim @@ -321,15 +321,13 @@ finish 'name': "a>b>i<b>i<\n", - 'skip': 0, + 'result': "\n\n", }, { 'name': "blockquote>b>i<b>i<\n", - 'skip': 0, + 'result': "
\n\n", }, { 'name': "a[href=foo][class=bar]", @@ -414,7 +412,6 @@ finish 'query': "#header>li<#content", 'type': "html", 'result': "
\n\t
  • \n
    \n
    \n", - 'skip': 1, }, { 'name': "(#header>li)<#content", @@ -427,7 +424,6 @@ finish 'query': "a>b>i<\n
    \n", - 'skip': 1, }, { 'name': "(#header>h1)+#content+#footer", @@ -439,8 +435,7 @@ finish 'name': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)", 'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)", 'type': "html", - 'result': "
    \n\t

    \n
    \n
    \n\t
    \n\t\t

    \n\t\t
    \n\t\t\t

    \n\t\t\t\t\n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t\t\n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t\t\n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t\t\n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t\t\n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t
    \n\t
    \n
    \n
    \n\t
    \n
    \n", - 'skip': 1, + 'result': "
    \n\t

    \n
    \n
    \n\t
    \n\t\t

    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t\t
    \n\t\t\t

    \n\t\t\t
    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t

    \n\t\t\t\t
      \n\t\t\t\t\t
    • \n\t\t\t\t
    \n\t\t\t
    \n\t\t
    \n\t
    \n\t
    \n
    \n
    \n\t
    \n
    \n", }, { 'name': "(div>(ul*2)*2)+(#utilities)", @@ -489,7 +484,6 @@ finish 'query': "link:css", 'type': "html", 'result': "\n", - 'skip': 1, }, { 'name': "a[title=\"Hello', world\" rel]",