MCPcopy Create free account
hub / github.com/ipython/ipython / back_unicode_name_matches

Function back_unicode_name_matches

IPython/core/completer.py:889–917  ·  view source on GitHub ↗

u"""Match unicode characters back to unicode name This does ``☃`` -> ``\\snowman`` Note that snowman is not a valid python3 combining character but will be expanded. Though it will not recombine back to the snowman character by the completion machinery. This will not either back-

(text)

Source from the content-addressed store, hash-verified

887
888
889def back_unicode_name_matches(text):
890 u"""Match unicode characters back to unicode name
891
892 This does ``☃`` -> ``\\snowman``
893
894 Note that snowman is not a valid python3 combining character but will be expanded.
895 Though it will not recombine back to the snowman character by the completion machinery.
896
897 This will not either back-complete standard sequences like \\n, \\b ...
898
899 Used on Python 3 only.
900 """
901 if len(text)<2:
902 return u'', ()
903 maybe_slash = text[-2]
904 if maybe_slash != '\\':
905 return u'', ()
906
907 char = text[-1]
908 # no expand on quote for completion in strings.
909 # nor backcomplete standard ascii keys
910 if char in string.ascii_letters or char in ['"',"'"]:
911 return u'', ()
912 try :
913 unic = unicodedata.name(char)
914 return '\\'+char,['\\'+unic]
915 except KeyError:
916 pass
917 return u'', ()
918
919def back_latex_name_matches(text:str):
920 """Match latex characters back to unicode name

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected