prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Cannot use Token.ZeroWidthEscape with pygments

Open
#740 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

I had a patch at https://github.com/jonathanslenders/python-prompt-toolkit/pull/615 that fixed this, but it was never merged. Right now I have to use

class MyPygmentsTokens(PygmentsTokens):
    """
    Support ZeroWidthEscape
    """

    def __pt_formatted_text__(self):
        result = []

        for token, text in self.token_list:
            if list(token) == ['ZeroWidthEscape']:
                result.append(('[ZeroWidthEscape]', text))
            else:
                result.append(('class:' + pygments_token_to_classname(token), text))

        return result

and use MyPygmentsTokens everywhere instead of PygmentsTokens.

Questions I never got answers to:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing pull request 615 and commit 33d47a1f25ec4b10dacb7fb83f7bb91512d0e2c5, then trace how PygmentsTokens handles Token.ZeroWidthEscape. Determine why the proposed change was not merged and verify that zero-width escape sequences work alongside Pygments theming without requiring a subclass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.