MeirKriheli / python-bidi

BIDI algorithm related functions
GNU Lesser General Public License v3.0
103 stars 13 forks source link

Using python-bidi with IRC colour codes #3

Open yuvallanger opened 8 years ago

yuvallanger commented 8 years ago

I am trying to use your library to replace the older pyfribidi library in the weechat script found in https://github.com/yuvallanger/weechat-biditext/ which is a fork of https://github.com/spacepluk/weechat-biditext/

When I use bidi.algorithm.get_display(line) on a line of weechat's buffer, IRC colour codes are stripped out. Is it possible to keep them?

python-bidi==0.4.0 and python 2.7.6

MeirKriheli commented 8 years ago

@yuvallanger Please provide some sample input which contains those codes, so I can try to debug it.

Thanks

yuvallanger commented 8 years ago

Using the pybuffer script, which opens a Python interpreter inside of WeeChat, I've generated the following string:

>>> "regular text\n{red}red text{regular}\n{green}green text{regular}\n{blue}blue
    text{regular}\nregular text again".format(regular=weechat.color('chat'),
    red=weechat.color('red'), green=weechat.color('green'), blue=weechat.color('blue'))
    'regular text\n\x19F03red text\x1901\n\x19F05green text\x1901\n\x19F09blue
    text\x1901\nregular text again'

Many thanks!

MeirKriheli commented 8 years ago

Hmm, those chars are BN Looks like it's removed in X9 stage of the algorithm:

Remove all RLE, LRE, RLO, LRO, PDF, and BN characters.

It says that removal is optional, and one can implement without it. It looks more complicated, don't know when I can get around to implementing it.