diff --git a/autoload/zencoding.vim b/autoload/zencoding.vim
index d8e2999..480f524 100644
--- a/autoload/zencoding.vim
+++ b/autoload/zencoding.vim
@@ -157,17 +157,8 @@ function! zencoding#toString(...)
let tmp = substitute(tmp, '|', '${cursor}', 'g')
endif
let tmp = substitute(tmp, '\${zenname}', current.name, 'g')
- if zencoding#isExtends(type, "css") && zencoding#useFilter(filters, 'fc')
- let tmp = substitute(tmp, '^\([^:]\+\):\([^;]*;\)', '\1: \2', '')
- if current.important
- let tmp = substitute(tmp, ';', ' !important;', '')
- endif
- endif
- for attr in keys(current.attr)
- let val = current.attr[attr]
- let tmp = substitute(tmp, '\${' . attr . '}', val, 'g')
- endfor
- let str .= tmp
+ let snippet_node = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 0, 'parent': {}, 'value': '{'.tmp.'}', 'pos': 0, 'important': current.important }
+ let str = zencoding#lang#{rtype}#toString(s:zen_settings, snippet_node, type, inline, filters, group_itemno, indent)
else
if len(current.name)
let str .= current.name
@@ -209,15 +200,6 @@ function! zencoding#getResource(type, name, default)
endif
let ret = a:default
- if has_key(s:zen_settings[a:type], a:name)
- let v = s:zen_settings[a:type][a:name]
- if type(ret) == 3 || type(ret) == 4
- call s:mergeConfig(ret, s:zen_settings[a:type][a:name])
- else
- let ret = s:zen_settings[a:type][a:name]
- endif
- endif
-
if has_key(s:zen_settings[a:type], 'extends')
let extends = s:zen_settings[a:type].extends
if type(extends) == 1
@@ -231,6 +213,16 @@ function! zencoding#getResource(type, name, default)
endif
endfor
endif
+
+ if has_key(s:zen_settings[a:type], a:name)
+ let v = s:zen_settings[a:type][a:name]
+ if type(ret) == 3 || type(ret) == 4
+ call s:mergeConfig(ret, s:zen_settings[a:type][a:name])
+ else
+ let ret = s:zen_settings[a:type][a:name]
+ endif
+ endif
+
return ret
endfunction
@@ -451,6 +443,12 @@ function! zencoding#imageSize()
return zencoding#lang#{rtype}#imageSize()
endfunction
+function! zencoding#encodeImage()
+ let type = zencoding#getFileType()
+ let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
+ return zencoding#lang#{rtype}#encodeImage()
+endfunction
+
function! zencoding#toggleComment()
let type = zencoding#getFileType()
let rtype = len(globpath(&rtp, 'autoload/zencoding/lang/'.type.'.vim')) ? type : 'html'
@@ -1339,10 +1337,30 @@ let s:zen_settings = {
\ }
\ },
\ 'haml': {
-\ 'extends': 'html'
+\ 'indentation': ' ',
+\ 'extends': 'html',
+\ 'snippets': {
+\ 'html:5': "!!! 5\n"
+\ ."%html{:lang => \"${lang}\"}\n"
+\ ."\t%head\n"
+\ ."\t\t%meta{:charset => \"${charset}\"\n"
+\ ."\t\t%title\n"
+\ ."\t%body\n"
+\ ."\t\t${child}|\n"
+\ },
\ },
\ 'slim': {
-\ 'extends': 'html'
+\ 'indentation': ' ',
+\ 'extends': 'html',
+\ 'snippets': {
+\ 'html:5': "doctype 5\n"
+\ ."html lang=\"${lang}\"\n"
+\ ."\thead\n"
+\ ."\t\tmeta charset=\"${charset}\"\n"
+\ ."\t\ttitle\n"
+\ ."\tbody\n"
+\ ."\t\t${child}|\n"
+\ },
\ },
\ 'xhtml': {
\ 'extends': 'html'
diff --git a/autoload/zencoding/lang/css.vim b/autoload/zencoding/lang/css.vim
index da5cb33..bc52daa 100644
--- a/autoload/zencoding/lang/css.vim
+++ b/autoload/zencoding/lang/css.vim
@@ -15,9 +15,11 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
if tag_name =~ '.!$'
let tag_name = tag_name[:-2]
let important = 1
+ else
+ let important = 0
endif
" make default node
- let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
+ let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': important }
let current.name = tag_name
" aliases
@@ -45,12 +47,21 @@ function! zencoding#lang#css#parseIntoTree(abbr, type)
endfunction
function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
- return ''
+ let current = a:current
+ let value = current.value[1:-2]
+ let value = substitute(value, '^\([^:]\+\):\([^;]*;\)', '\1: \2', '')
+ if current.important
+ let value = substitute(value, ';', ' !important;', '')
+ endif
+ return value
endfunction
function! zencoding#lang#css#imageSize()
endfunction
+function! zencoding#lang#css#encodeImage()
+endfunction
+
function! zencoding#lang#css#parseTag(tag)
return {}
endfunction
diff --git a/autoload/zencoding/lang/haml.vim b/autoload/zencoding/lang/haml.vim
index c2fc9a4..771aaf5 100644
--- a/autoload/zencoding/lang/haml.vim
+++ b/autoload/zencoding/lang/haml.vim
@@ -75,6 +75,11 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
let inner = substitute(inner, "\n $", "", 'g')
let str .= "\n " . inner
endif
+ else
+ let str = current.value[1:-2]
+ let str = substitute(str, '\%(\\\)\@\ 0
let str .= '<' . current_name
for attr in keys(current.attr)
let val = current.attr[attr]
@@ -392,6 +400,34 @@ function! zencoding#lang#html#imageSize()
call zencoding#util#setContent(img_region, html)
endfunction
+function! zencoding#lang#html#encodeImage()
+ let img_region = zencoding#util#searchRegion('
')
+ if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
+ return
+ endif
+ let content = zencoding#util#getContent(img_region)
+ if content !~ '^
<]\+>$'
+ return
+ endif
+ let current = zencoding#lang#html#parseTag(content)
+ if empty(current) || !has_key(current.attr, 'src')
+ return
+ endif
+ let fn = current.attr.src
+ if fn !~ '^\(/\|http\)'
+ let fn = simplify(expand('%:h') . '/' . fn)
+ endif
+
+ let [width, height] = zencoding#util#getImageSize(fn)
+ if width == -1 && height == -1
+ return
+ endif
+ let current.attr.width = width
+ let current.attr.height = height
+ let html = zencoding#toString(current, 'html', 1)
+ call zencoding#util#setContent(img_region, html)
+endfunction
+
function! zencoding#lang#html#parseTag(tag)
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
diff --git a/autoload/zencoding/lang/slim.vim b/autoload/zencoding/lang/slim.vim
index 46ddd50..b89185b 100644
--- a/autoload/zencoding/lang/slim.vim
+++ b/autoload/zencoding/lang/slim.vim
@@ -60,6 +60,11 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
let inner = substitute(inner, "\n $", "", 'g')
let str .= "\n " . inner
endif
+ else
+ let str = current.value[1:-2]
+ let str = substitute(str, '\%(\\\)\@\