Refactoring

This commit is contained in:
Yasuhiro Matsumoto
2026-03-07 11:08:24 +09:00
parent e983971449
commit 7c44caa0e6
14 changed files with 2452 additions and 2452 deletions
+27 -27
View File
@@ -1,9 +1,9 @@
function! emmet#lorem#en#expand(command) abort
let wcount = matchstr(a:command, '\(\d*\)$')
let wcount = wcount > 0 ? wcount : 30
let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
let l:wcount = matchstr(a:command, '\(\d*\)$')
let l:wcount = l:wcount > 0 ? l:wcount : 30
let l:common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
let l:words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
@@ -32,34 +32,34 @@ function! emmet#lorem#en#expand(command) abort
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
\ 'maxime', 'corrupti']
let ret = []
let sentence = 0
for i in range(wcount)
let arr = common
if sentence > 0
let arr += words
let l:ret = []
let l:sentence = 0
for l:i in range(l:wcount)
let l:arr = l:common
if l:sentence > 0
let l:arr += l:words
endif
let r = emmet#util#rand()
let word = arr[r % len(arr)]
if sentence == 0
let word = substitute(word, '^.', '\U&', '')
let l:r = emmet#util#rand()
let l:word = l:arr[l:r % len(l:arr)]
if l:sentence == 0
let l:word = substitute(l:word, '^.', '\U&', '')
endif
let sentence += 1
call add(ret, word)
if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
if i == wcount - 1
let endc = '?!...'[emmet#util#rand() % 5]
call add(ret, endc)
let l:sentence += 1
call add(l:ret, l:word)
if (l:sentence > 5 && emmet#util#rand() < 10000) || l:i == l:wcount - 1
if l:i == l:wcount - 1
let l:endc = '?!...'[emmet#util#rand() % 5]
call add(l:ret, l:endc)
else
let endc = '?!,...'[emmet#util#rand() % 6]
call add(ret, endc . ' ')
let l:endc = '?!,...'[emmet#util#rand() % 6]
call add(l:ret, l:endc . ' ')
endif
if endc !=# ','
let sentence = 0
if l:endc !=# ','
let l:sentence = 0
endif
else
call add(ret, ' ')
call add(l:ret, ' ')
endif
endfor
return join(ret, '')
return join(l:ret, '')
endfunction
+20 -20
View File
@@ -1,27 +1,27 @@
scriptencoding utf-8
function! emmet#lorem#ja#expand(command) abort
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
let wcount = wcount > 0 ? wcount : 30
let l:wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
let l:wcount = l:wcount > 0 ? l:wcount : 30
let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
let content = emmet#util#cache(url)
if len(content) == 0
let content = emmet#util#getContentFromURL(url)
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
let content = substitute(content, '[ \r]', '', 'g')
let content = substitute(content, '<br[^>]*>', "\n", 'g')
let content = substitute(content, '<[^>]\+>', '', 'g')
let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n")
call emmet#util#cache(url, content)
let l:url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
let l:content = emmet#util#cache(l:url)
if len(l:content) == 0
let l:content = emmet#util#getContentFromURL(l:url)
let l:content = matchstr(l:content, '<div[^>]*>\zs.\{-}</div>')
let l:content = substitute(l:content, '[ \r]', '', 'g')
let l:content = substitute(l:content, '<br[^>]*>', "\n", 'g')
let l:content = substitute(l:content, '<[^>]\+>', '', 'g')
let l:content = join(filter(split(l:content, "\n"), 'len(v:val)>0'), "\n")
call emmet#util#cache(l:url, l: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
let l:content = substitute(l:content, "、\n", "、", "g")
let l:clines = split(l:content, '\n')
let l:lines = filter(l:clines, 'len(substitute(v:val,".",".","g"))<=l:wcount')
if len(l:lines) == 0
let l:lines = l:clines
endif
let r = emmet#util#rand()
return lines[r % len(lines)]
let l:r = emmet#util#rand()
return l:lines[l:r % len(l:lines)]
endfunction