fix implicit tag expansion.

Close #307
This commit is contained in:
Yasuhiro Matsumoto
2015-12-14 00:39:47 +09:00
parent e24ea1734e
commit ea47fca11e

View File

@@ -60,6 +60,13 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
let settings = emmet#getSettings() let settings = emmet#getSettings()
let indent = emmet#getIndentation(type) let indent = emmet#getIndentation(type)
let pmap = {
\ 'html': 'body',
\ 'table': 'tr',
\ 'tr': 'td',
\ 'ul': 'li',
\ 'ol': 'li',
\}
" try 'foo' to (foo-x) " try 'foo' to (foo-x)
let rabbr = emmet#getExpandos(type, abbr) let rabbr = emmet#getExpandos(type, abbr)
@@ -91,7 +98,7 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
endif endif
if tag_name =~# '^#' if tag_name =~# '^#'
let attributes = tag_name . attributes let attributes = tag_name . attributes
let tag_name = 'div' let tag_name = ''
endif endif
if tag_name =~# '[^!]!$' if tag_name =~# '[^!]!$'
let tag_name = tag_name[:-2] let tag_name = tag_name[:-2]
@@ -99,12 +106,20 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
endif endif
if tag_name =~# '^\.' if tag_name =~# '^\.'
let attributes = tag_name . attributes let attributes = tag_name . attributes
let tag_name = 'div' let tag_name = ''
endif endif
if tag_name =~# '^\[.*\]$' if tag_name =~# '^\[.*\]$'
let attributes = tag_name . attributes let attributes = tag_name . attributes
let tag_name = ''
endif
if empty(tag_name)
let pname = len(parent.child) > 0 ? parent.child[0].name : ''
if !empty(pname) && has_key(pmap, pname)
let tag_name = pmap[pname]
else
let tag_name = 'div' let tag_name = 'div'
endif endif
endif
let basedirect = basevalue[1] ==# '-' ? -1 : 1 let basedirect = basevalue[1] ==# '-' ? -1 : 1
let basevalue = 0 + abs(basevalue[1:]) let basevalue = 0 + abs(basevalue[1:])
if multiplier <= 0 | let multiplier = 1 | endif if multiplier <= 0 | let multiplier = 1 | endif