hints kitten: Match and strip Unicode single and double quotes
This commit is contained in:
parent
b2317e0f12
commit
d40e6a9ece
@ -230,7 +230,7 @@ def regex_finditer(pat: 'Pattern[str]', minimum_match_length: int, text: str) ->
|
|||||||
yield s, e, m.groupdict()
|
yield s, e, m.groupdict()
|
||||||
|
|
||||||
|
|
||||||
closing_bracket_map = {'(': ')', '[': ']', '{': '}', '<': '>', '*': '*', '"': '"', "'": "'"}
|
closing_bracket_map = {'(': ')', '[': ']', '{': '}', '<': '>', '*': '*', '"': '"', "'": "'", "“": "”", "‘": "’"}
|
||||||
opening_brackets = ''.join(closing_bracket_map)
|
opening_brackets = ''.join(closing_bracket_map)
|
||||||
PostprocessorFunc = Callable[[str, int, int], Tuple[int, int]]
|
PostprocessorFunc = Callable[[str, int, int], Tuple[int, int]]
|
||||||
postprocessor_map: Dict[str, PostprocessorFunc] = {}
|
postprocessor_map: Dict[str, PostprocessorFunc] = {}
|
||||||
@ -288,11 +288,12 @@ def quotes(text: str, s: int, e: int) -> Tuple[int, int]:
|
|||||||
# Remove matching quotes
|
# Remove matching quotes
|
||||||
if s < e <= len(text):
|
if s < e <= len(text):
|
||||||
before = text[s]
|
before = text[s]
|
||||||
if before in '\'"':
|
if before in '\'"“‘':
|
||||||
if text[e-1] == before:
|
q = closing_bracket_map[before]
|
||||||
|
if text[e-1] == q:
|
||||||
s += 1
|
s += 1
|
||||||
e -= 1
|
e -= 1
|
||||||
elif text[e:e+1] == before:
|
elif text[e:e+1] == q:
|
||||||
s += 1
|
s += 1
|
||||||
return s, e
|
return s, e
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user