forked from VimPlug/emmet-vim
add new option dollar_expr that don't replace $ to numbers.
This commit is contained in:
@@ -14,21 +14,26 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
|||||||
let filters = a:filters
|
let filters = a:filters
|
||||||
let itemno = a:itemno
|
let itemno = a:itemno
|
||||||
let indent = a:indent
|
let indent = a:indent
|
||||||
|
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||||
let str = ""
|
let str = ""
|
||||||
|
|
||||||
let comment_indent = ''
|
let comment_indent = ''
|
||||||
let comment = ''
|
let comment = ''
|
||||||
let current_name = current.name
|
let current_name = current.name
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
if dollar_expr
|
||||||
|
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||||
|
endif
|
||||||
if len(current.name) > 0
|
if len(current.name) > 0
|
||||||
let str .= '%' . current_name
|
let str .= '%' . current_name
|
||||||
let tmp = ''
|
let tmp = ''
|
||||||
for attr in keys(current.attr)
|
for attr in keys(current.attr)
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
if dollar_expr
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
endwhile
|
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
endwhile
|
||||||
|
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||||
|
endif
|
||||||
let valtmp = substitute(val, '\${cursor}', '', '')
|
let valtmp = substitute(val, '\${cursor}', '', '')
|
||||||
if attr == 'id' && len(valtmp) > 0
|
if attr == 'id' && len(valtmp) > 0
|
||||||
let str .= '#' . val
|
let str .= '#' . val
|
||||||
@@ -50,9 +55,11 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
|||||||
let inner = ''
|
let inner = ''
|
||||||
if len(current.value) > 0
|
if len(current.value) > 0
|
||||||
let text = current.value[1:-2]
|
let text = current.value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
let lines = split(text, "\n")
|
let lines = split(text, "\n")
|
||||||
if len(lines) == 1
|
if len(lines) == 1
|
||||||
let str .= " " . text
|
let str .= " " . text
|
||||||
@@ -64,9 +71,11 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
|||||||
endif
|
endif
|
||||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||||
let text = current.child[0].value[1:-2]
|
let text = current.child[0].value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
let lines = split(text, "\n")
|
let lines = split(text, "\n")
|
||||||
if len(lines) == 1
|
if len(lines) == 1
|
||||||
let str .= " " . text
|
let str .= " " . text
|
||||||
@@ -85,9 +94,11 @@ function! zencoding#lang#haml#toString(settings, current, type, inline, filters,
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let str = current.value[1:-2]
|
let str = current.value[1:-2]
|
||||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let str = substitute(str, '\\\$', '$', 'g')
|
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||||
|
let str = substitute(str, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
let str .= "\n"
|
let str .= "\n"
|
||||||
return str
|
return str
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
|||||||
let filters = a:filters
|
let filters = a:filters
|
||||||
let itemno = a:itemno
|
let itemno = a:itemno
|
||||||
let indent = a:indent
|
let indent = a:indent
|
||||||
|
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||||
|
|
||||||
if zencoding#useFilter(filters, 'haml')
|
if zencoding#useFilter(filters, 'haml')
|
||||||
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||||
@@ -300,24 +301,30 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
|||||||
|
|
||||||
let comment = ''
|
let comment = ''
|
||||||
let current_name = current.name
|
let current_name = current.name
|
||||||
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
if dollar_expr
|
||||||
|
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
||||||
|
endif
|
||||||
|
|
||||||
let str = ''
|
let str = ''
|
||||||
if len(current_name) == 0
|
if len(current_name) == 0
|
||||||
let text = current.value[1:-2]
|
let text = current.value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
return text
|
return text
|
||||||
endif
|
endif
|
||||||
if len(current_name) > 0
|
if len(current_name) > 0
|
||||||
let str .= '<' . current_name
|
let str .= '<' . current_name
|
||||||
for attr in keys(current.attr)
|
for attr in keys(current.attr)
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
if dollar_expr
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
endwhile
|
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
endwhile
|
||||||
|
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||||
|
endif
|
||||||
let str .= ' ' . attr . '="' . val . '"'
|
let str .= ' ' . attr . '="' . val . '"'
|
||||||
if zencoding#useFilter(filters, 'c')
|
if zencoding#useFilter(filters, 'c')
|
||||||
if attr == 'id' | let comment .= '#' . val | endif
|
if attr == 'id' | let comment .= '#' . val | endif
|
||||||
@@ -332,9 +339,11 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
|
|||||||
else
|
else
|
||||||
let str .= ">"
|
let str .= ">"
|
||||||
let text = current.value[1:-2]
|
let text = current.value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
let str .= text
|
let str .= text
|
||||||
let nc = len(current.child)
|
let nc = len(current.child)
|
||||||
let dr = 0
|
let dr = 0
|
||||||
|
|||||||
@@ -14,19 +14,24 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
|||||||
let filters = a:filters
|
let filters = a:filters
|
||||||
let itemno = a:itemno
|
let itemno = a:itemno
|
||||||
let indent = a:indent
|
let indent = a:indent
|
||||||
|
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||||
let str = ""
|
let str = ""
|
||||||
|
|
||||||
let comment_indent = ''
|
let comment_indent = ''
|
||||||
let comment = ''
|
let comment = ''
|
||||||
let current_name = current.name
|
let current_name = current.name
|
||||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
if dollar_expr
|
||||||
|
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||||
|
endif
|
||||||
if len(current.name) > 0
|
if len(current.name) > 0
|
||||||
let str .= current_name
|
let str .= current_name
|
||||||
for attr in keys(current.attr)
|
for attr in keys(current.attr)
|
||||||
let val = current.attr[attr]
|
let val = current.attr[attr]
|
||||||
while val =~ '\$\([^#{]\|$\)'
|
if dollar_expr
|
||||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
while val =~ '\$\([^#{]\|$\)'
|
||||||
endwhile
|
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
|
endwhile
|
||||||
|
endif
|
||||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||||
let str .= ' ' . attr . '="' . val . '"'
|
let str .= ' ' . attr . '="' . val . '"'
|
||||||
endfor
|
endfor
|
||||||
@@ -35,9 +40,11 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
|||||||
if len(current.value) > 0
|
if len(current.value) > 0
|
||||||
let str .= "\n"
|
let str .= "\n"
|
||||||
let text = current.value[1:-2]
|
let text = current.value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
for line in split(text, "\n")
|
for line in split(text, "\n")
|
||||||
let str .= indent . "| " . line . "\n"
|
let str .= indent . "| " . line . "\n"
|
||||||
endfor
|
endfor
|
||||||
@@ -45,9 +52,11 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
|||||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||||
let str .= "\n"
|
let str .= "\n"
|
||||||
let text = current.child[0].value[1:-2]
|
let text = current.child[0].value[1:-2]
|
||||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let text = substitute(text, '\\\$', '$', 'g')
|
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||||
|
let text = substitute(text, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
for line in split(text, "\n")
|
for line in split(text, "\n")
|
||||||
let str .= indent . "| " . line . "\n"
|
let str .= indent . "| " . line . "\n"
|
||||||
endfor
|
endfor
|
||||||
@@ -61,9 +70,11 @@ function! zencoding#lang#slim#toString(settings, current, type, inline, filters,
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let str = current.value[1:-2]
|
let str = current.value[1:-2]
|
||||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
if dollar_expr
|
||||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||||
let str = substitute(str, '\\\$', '$', 'g')
|
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||||
|
let str = substitute(str, '\\\$', '$', 'g')
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
if str !~ "\n$"
|
if str !~ "\n$"
|
||||||
let str .= "\n"
|
let str .= "\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user