mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-07 03:04:27 +08:00
check encoding more smart.
This commit is contained in:
@@ -492,10 +492,7 @@ function! zencoding#anchorizeURL(flag)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let mx = '.*<title[^>]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*'
|
let mx = '.*<title[^>]*>\s*\zs\([^<]\+\)\ze\s*<\/title[^>]*>.*'
|
||||||
let content = zencoding#util#getContentFromURL(url, 0)
|
let content = zencoding#util#getContentFromURL(url)
|
||||||
if len(matchstr(content, mx)) == 0
|
|
||||||
let content = zencoding#util#getContentFromURL(url, 1)
|
|
||||||
endif
|
|
||||||
let content = substitute(content, '\r', '', 'g')
|
let content = substitute(content, '\r', '', 'g')
|
||||||
let content = substitute(content, '[ \n]\+', ' ', 'g')
|
let content = substitute(content, '[ \n]\+', ' ', 'g')
|
||||||
let content = substitute(content, '<!--.\{-}-->', '', 'g')
|
let content = substitute(content, '<!--.\{-}-->', '', 'g')
|
||||||
|
|||||||
@@ -144,16 +144,12 @@ endfunction
|
|||||||
"==============================================================================
|
"==============================================================================
|
||||||
" html utils
|
" html utils
|
||||||
"==============================================================================
|
"==============================================================================
|
||||||
function! zencoding#util#getContentFromURL(url, utf8)
|
function! zencoding#util#getContentFromURL(url)
|
||||||
silent! new
|
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||||
if a:utf8
|
let s1 = len(split(res, '?'))
|
||||||
silent! exec '0r ++enc=utf8 !'.g:zencoding_curl_command.' "'.substitute(a:url, '#.*', '', '').'"'
|
let utf8 = iconv(res, 'utf-8', &encoding)
|
||||||
else
|
let s2 = len(split(utf8, '?'))
|
||||||
silent! exec '0r!'.g:zencoding_curl_command.' "'.substitute(a:url, '#.*', '', '').'"'
|
return s2 > s1 * 2 ? utf8 : res
|
||||||
endif
|
|
||||||
let ret = join(getline(1, '$'), "\n")
|
|
||||||
silent! bw!
|
|
||||||
return ret
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! zencoding#util#getTextFromHTML(buf)
|
function! zencoding#util#getTextFromHTML(buf)
|
||||||
|
|||||||
Reference in New Issue
Block a user