MCPcopy Index your code
hub / github.com/ipython/ipython / unicode_name_matcher

Method unicode_name_matcher

IPython/core/completer.py:3141–3170  ·  view source on GitHub ↗

Match Latex-like syntax for unicode characters base on the name of the character. This does ``\\GREEK SMALL LETTER ETA`` -> ``η`` Works only on valid python 3 identifier, or on combining characters that will combine to form a valid identifier.

(self, context: CompletionContext)

Source from the content-addressed store, hash-verified

3139
3140 @context_matcher()
3141 def unicode_name_matcher(self, context: CompletionContext) -> SimpleMatcherResult:
3142 """Match Latex-like syntax for unicode characters base
3143 on the name of the character.
3144
3145 This does ``\\GREEK SMALL LETTER ETA`` -> ``η``
3146
3147 Works only on valid python 3 identifier, or on combining characters that
3148 will combine to form a valid identifier.
3149 """
3150
3151 text = context.text_until_cursor
3152
3153 slashpos = text.rfind('\\')
3154 if slashpos > -1:
3155 s = text[slashpos+1:]
3156 try :
3157 unic = unicodedata.lookup(s)
3158 # allow combining chars
3159 if ('a'+unic).isidentifier():
3160 return {
3161 "completions": [SimpleCompletion(text=unic, type="unicode")],
3162 "suppress": True,
3163 "matched_fragment": "\\" + s,
3164 }
3165 except KeyError:
3166 pass
3167 return {
3168 "completions": [],
3169 "suppress": False,
3170 }
3171
3172 @context_matcher()
3173 def latex_name_matcher(self, context: CompletionContext):

Callers

nothing calls this directly

Calls 2

SimpleCompletionClass · 0.85
lookupMethod · 0.80

Tested by

no test coverage detected