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

Function back_latex_name_matcher

IPython/core/completer.py:1776–1810  ·  view source on GitHub ↗

Match latex characters back to unicode name This does ``\\ℵ`` -> ``\\aleph``

(context: CompletionContext)

Source from the content-addressed store, hash-verified

1774
1775@context_matcher()
1776def back_latex_name_matcher(context: CompletionContext) -> SimpleMatcherResult:
1777 """Match latex characters back to unicode name
1778
1779 This does ``\\ℵ`` -> ``\\aleph``
1780 """
1781
1782 text = context.text_until_cursor
1783 no_match = {
1784 "completions": [],
1785 "suppress": False,
1786 }
1787
1788 if len(text)<2:
1789 return no_match
1790 maybe_slash = text[-2]
1791 if maybe_slash != '\\':
1792 return no_match
1793
1794 char = text[-1]
1795 # no expand on quote for completion in strings.
1796 # nor backcomplete standard ascii keys
1797 if char in string.ascii_letters or char in ('"',"'"):
1798 return no_match
1799 try :
1800 latex = reverse_latex_symbol[char]
1801 # '\\' replace the \ as well
1802 return {
1803 "completions": [SimpleCompletion(text=latex, type="latex")],
1804 "suppress": True,
1805 "matched_fragment": "\\" + char,
1806 }
1807 except KeyError:
1808 pass
1809
1810 return no_match
1811
1812def _formatparamchildren(parameter) -> str:
1813 """

Callers

nothing calls this directly

Calls 1

SimpleCompletionClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…