mpcabd / python-arabic-reshaper

Reconstruct Arabic sentences to be used in applications that don't support Arabic
MIT License
395 stars 81 forks source link

[FR] Support ANSI color codes #65

Open NightMachinery opened 3 years ago

NightMachinery commented 3 years ago

I am using this package to be able to use my terminal in the rare cases where some RTL text is involved. I currently have this script:

#!/usr/bin/env python3

import arabic_reshaper
import sys
from bidi.algorithm import get_display

text_to_be_reshaped = sys.stdin.read()
reshaped_text = arabic_reshaper.reshape(text_to_be_reshaped)
bidi_text = get_display(reshaped_text)
print(bidi_text, end='')

And it works great: image

But it would be even more awesome if it could support ANSI color codes: image

mpcabd commented 3 years ago

I am not sure this problem is by the reshaper or by the fact that get_display is called on the text, could you write a unit test that fails with this case?