From c03599748f1eb829513d197285b4eb9c0f67e641 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 5 Jul 2016 09:45:13 +0900 Subject: [PATCH] fix bem filter --- autoload/emmet/lang/html.vim | 38 +++++++++++++++++++----------------- unittest.vim | 2 +- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 64b1e49..7bf66bf 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -514,31 +514,33 @@ function! emmet#lang#html#toString(settings, current, type, inline, filters, ite if len(Val) > 0 let Val .= ' ' endif - if _val =~# '_' - if _val =~# '^_' - if has_key(current.parent.attr, 'class') - let lead = current.parent.attr["class"] - if _val =~# '^__' - let Val .= lead . _val - else - let Val .= lead . ' ' . lead . _val - endif - else - let b = split(vals[0], '_')[0] + if _val =~# '^_' + if has_key(current.parent.attr, 'class') + let lead = current.parent.attr["class"] + if _val =~# '^__' let Val .= lead . _val + else + let Val .= lead . ' ' . lead . _val endif else let lead = split(vals[0], '_')[0] - let Val .= lead . ' ' . _val + let Val .= lead . _val endif elseif _val =~# '^-' - if len(lead) == 0 - let pattr = current.parent.attr - if has_key(pattr, 'class') - let lead = split(pattr['class'], '\s\+')[0] + for l in split(_val, '_') + if len(Val) > 0 + let Val .= ' ' endif - endif - let Val .= lead . _val + let l = substitute(l, '^-', '__', '') + if len(lead) == 0 + let pattr = current.parent.attr + if has_key(pattr, 'class') + let lead = split(pattr['class'], '\s\+')[0] + endif + endif + let Val .= lead . l + let lead .= l . '_' + endfor else let Val .= _val endif diff --git a/unittest.vim b/unittest.vim index 2d04921..98fcf57 100644 --- a/unittest.vim +++ b/unittest.vim @@ -538,7 +538,7 @@ finish }, { 'query': "form.search-form._wide>input.-query-string+input:s.-btn_large|bem", - 'result': "
\n\t\n\t\n
\n", + 'result': "
\n\t\n\t\n
\n", }, { 'query': "form>fieldset>legend+(label>input[type=\"checkbox\"])*3",