Skip to content

Commit

Permalink
put back remove_terminal_escapes. Fixes #173.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robyn Speer committed Apr 12, 2021
1 parent f1e3175 commit e17af07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions ftfy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def fix_and_explain(
"uncurl_quotes",
"fix_line_breaks",
"fix_surrogates",
"remove_terminal_escapes",
"remove_control_chars",
]:
text = _try_fix(fixer, text, config, steps)
Expand Down
13 changes: 12 additions & 1 deletion tests/test_characters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from ftfy import fix_encoding, fix_encoding_and_explain, fix_text, apply_plan
from ftfy import (
fix_encoding, fix_encoding_and_explain, fix_text, fix_and_explain, apply_plan
)
from ftfy.fixes import remove_control_chars, fix_surrogates
from ftfy.chardata import possible_encoding
from ftfy.badness import badness
Expand Down Expand Up @@ -44,3 +46,12 @@ def test_surrogates():
assert fix_surrogates('\udbff\udfff') == '\U0010ffff'
assert fix_surrogates('\ud800\udc00') == '\U00010000'


def test_color_escapes():
fixed, plan = fix_and_explain("\001\033[36;44mfoo")
print(plan)
assert fixed == "foo"
assert plan == [
("apply", "remove_terminal_escapes"),
("apply", "remove_control_chars")
]

0 comments on commit e17af07

Please sign in to comment.