Skip to content

Strip all ANSI sequences#3681

Merged
Rowlando13 merged 1 commit into
pallets:mainfrom
kdeldycke:fix-ansi-regex
Jul 10, 2026
Merged

Strip all ANSI sequences#3681
Rowlando13 merged 1 commit into
pallets:mainfrom
kdeldycke:fix-ansi-regex

Conversation

@kdeldycke

@kdeldycke kdeldycke commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR augment the ANSI regexp used in Click so it can recognize and strip all ANSI sequences, including those not produced by Click itself.

I made the tests a bit exhaustive to demonstrate the lack of regression between the older naive regexp and my new proposal. But if you are convinced I can just get rid of them.

The code is based on work I produced 6 years ago and contributed to boltons: mahmoud/boltons#258

It is in line with what is done upstream in the cpython project:

Follows up on:

@kdeldycke kdeldycke added the f:help feature: help text label Jul 9, 2026
@kdeldycke kdeldycke added this to the 8.5.0 milestone Jul 9, 2026
@Rowlando13
Rowlando13 merged commit 8c1a0a7 into pallets:main Jul 10, 2026
12 checks passed
@kdeldycke
kdeldycke deleted the fix-ansi-regex branch July 11, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f:help feature: help text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants