fixed ${nr}. and fixed multi-line text for haml & slim.

This commit is contained in:
mattn
2012-06-13 18:02:23 +09:00
parent 65c8fe1d23
commit 16e3a95d7f
3 changed files with 22 additions and 16 deletions

View File

@@ -35,7 +35,8 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
let str .= '.' . substitute(val, ' ', '.', 'g')
else
if len(tmp) > 0 | let tmp .= ',' | endif
let tmp .= ' :' . attr . ' => "' . val . '"'
let val = substitute(val, '\${cursor}', '', '')
let tmp .= ' :' . attr . ' => "' . val . '${cursor}' . '"'
endif
endfor
if len(tmp)
@@ -52,10 +53,13 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
let lines = split(text, "\n")
let str .= " " . lines[0]
for line in lines[1:]
let str .= " |\n" . line
endfor
if len(lines) == 1
let str .= " " . text
else
for line in lines
let str .= "\n" . indent . line . " |"
endfor
endif
endif
if len(current.child) == 1 && len(current.child[0].name) == 0
let text = current.child[0].value[1:-2]
@@ -63,17 +67,20 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
let text = substitute(text, '\${nr}', "\n", 'g')
let text = substitute(text, '\\\$', '$', 'g')
let lines = split(text, "\n")
let str .= " " . lines[0]
for line in lines[1:]
let str .= " |\n" . line
endfor
if len(lines) == 1
let str .= " " . text
else
for line in lines
let str .= "\n" . indent . line . " |"
endfor
endif
elseif len(current.child) > 0
for child in current.child
let inner .= zencoding#toString(child, type, inline, filters, itemno)
endfor
let inner = substitute(inner, "\n", "\n ", 'g')
let inner = substitute(inner, "\n $", "", 'g')
let str .= "\n " . inner
let inner = substitute(inner, "\n", "\n" . indent, 'g')
let inner = substitute(inner, "\n" . indent . "$", "", 'g')
let str .= "\n" . indent . inner
endif
else
let str = current.value[1:-2]

View File

@@ -1,6 +1,6 @@
let s:mx = '\([+>]\|<\+\)\{-}\s*'
\ .'\((*\)\{-}\s*'
\ .'\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\$\${\w\+}\|\$\+\)*}[ \t\r\n}]*\)'
\ .'\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}[ \t\r\n}]*\)'
\ .'\('
\ .'\%('
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
@@ -8,7 +8,7 @@ let s:mx = '\([+>]\|<\+\)\{-}\s*'
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
\ .'\)*'
\ .'\)'
\ .'\%(\({\%([^$}]\+\|\$#\|\$\${\w\+}\|\$\+\)*}\)\)\{0,1}'
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\)\)\{0,1}'
\ .'\%(\*\([0-9]\+\)\)\{0,1}'
\ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'

View File

@@ -28,8 +28,7 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
endwhile
let attr = substitute(attr, '\$$', itemno+1, '')
let sval = substitute(val, '\${cursor}', '', '')
let str .= ' ' . attr . '="' . val . '"'
let str .= ' ' . attr . '="' . val . '${cursor}' . '"'
endfor
let inner = ''