diff --git a/autoload/zencoding/lorem/ja.vim b/autoload/zencoding/lorem/ja.vim new file mode 100644 index 0000000..6e9db9a --- /dev/null +++ b/autoload/zencoding/lorem/ja.vim @@ -0,0 +1,27 @@ +scriptencoding utf-8 + +function! zencoding#lorem#ja#expand(command) + let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '') + let wcount = wcount > 0 ? wcount : 30 + + let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html" + let content = zencoding#util#cache(url) + if len(content) == 0 + let content = zencoding#util#getContentFromURL(url) + let content = matchstr(content, ']*>\zs.\{-}') + let content = substitute(content, '[ \r]', '', 'g') + let content = substitute(content, ']*>', "\n", 'g') + let content = substitute(content, '<[^>]\+>', '', 'g') + let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n") + call zencoding#util#cache(url, content) + endif + + let content = substitute(content, "、\n", "、", "g") + let clines = split(content, '\n') + let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount') + if len(lines) == 0 + let lines = clines + endif + let r = zencoding#util#rand() + return lines[r % len(lines)] +endfunction diff --git a/autoload/zencoding/util.vim b/autoload/zencoding/util.vim index 437ef0f..ada509c 100644 --- a/autoload/zencoding/util.vim +++ b/autoload/zencoding/util.vim @@ -147,7 +147,6 @@ endfunction function! zencoding#util#getContentFromURL(url) let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', '')))) let charset = matchstr(res, ']\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>') - let g:hoge = charset if len(charset) == 0 let charset = matchstr(res, ']*>') endif