Match latex characters back to unicode name This does ``\\ℵ`` -> ``\\aleph``
(context: CompletionContext)
| 1774 | |
| 1775 | @context_matcher() |
| 1776 | def 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 | |
| 1812 | def _formatparamchildren(parameter) -> str: |
| 1813 | """ |
nothing calls this directly
no test coverage detected
searching dependent graphs…