fix CJK lens

This commit is contained in:
Meng Zhuo 2013-06-20 11:29:44 +08:00
parent d666cfc6a5
commit 6ac725a309

View File

@ -3,46 +3,52 @@
########################################################################### ###########################################################################
# General Stuff # # General Stuff #
########################################################################### ###########################################################################
global !p
import re
def rst_char_len(char):
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
endglobal
snippet part "Part" b snippet part "Part" b
`!p snip.rv = len(t[1])*'#'` `!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name} ${1:Part name}
`!p snip.rv = len(t[1])*'#'` `!p snip.rv = rst_char_len(t[1])*'#'`
$0 $0
endsnippet endsnippet
snippet sec "Section" b snippet sec "Section" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'='` `!p snip.rv = rst_char_len(t[1])*'='`
$0 $0
endsnippet endsnippet
snippet ssec "Subsection" b snippet ssec "Subsection" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'-'` `!p snip.rv = rst_char_len(t[1])*'-'`
$0 $0
endsnippet endsnippet
snippet sssec "Subsubsection" b snippet sssec "Subsubsection" b
${1:Section name} ${1:Section name}
`!p snip.rv = len(t[1])*'^'` `!p snip.rv = rst_char_len(t[1])*'^'`
$0 $0
endsnippet endsnippet
snippet chap "Chapter" b snippet chap "Chapter" b
`!p snip.rv = len(t[1])*'*'` `!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name} ${1:Chapter name}
`!p snip.rv = len(t[1])*'*'` `!p snip.rv = rst_char_len(t[1])*'*'`
$0 $0
endsnippet endsnippet
snippet para "Paragraph" b snippet para "Paragraph" b
${1:Paragraph name} ${1:Paragraph name}
`!p snip.rv = len(t[1])*'"'` `!p snip.rv = rst_char_len(t[1])*'"'`
$0 $0
endsnippet endsnippet
@ -94,7 +100,6 @@ endsnippet
# More Specialized Stuff. # # More Specialized Stuff. #
########################################################################### ###########################################################################
global !p global !p
import re
from collections import Counter from collections import Counter
def get_popular_code_type(path): def get_popular_code_type(path):
with open(path) as source: with open(path) as source: