Merge pull request #408 from Oberon00/rst-fix-python3

rst: Improve compatibility of snippets with Python 3
This commit is contained in:
Holger Rapp 2014-07-26 14:42:08 +02:00
commit 23e1406784

View File

@ -42,18 +42,9 @@ INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def has_cjk(s):
"""Detect if s contains CJK characters."""
return CJK_RE.search(s) is not None
def real_filename(filename):
"""pealeextension name off if possible
@ -96,7 +87,7 @@ def make_items(times, leading='+'):
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
for x in range(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
@ -182,7 +173,7 @@ endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
# dirty but works with CJK character detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):