Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RTL #7

Open
NightMachinery opened this issue Oct 29, 2018 · 9 comments
Open

Support RTL #7

NightMachinery opened this issue Oct 29, 2018 · 9 comments

Comments

@NightMachinery
Copy link

Like this one:

Found 1 items, similar to سلام.
-->Moin
-->سلام

<p align=right dir=rtl>(سَ) [<font color="green"> ع.</font> ] (<font color="green">مص ل.</font>)<br><font color="#7030a0">۱-</font> درود گفتن.<br><font color="#7030a0">۲-</font> بی گزند شدن.<br><font color="#7030a0">۳-</font> گردن نهادن.<br>~ علیک درود بر تو باد.<br>~ علیکم درود بر شما.</p>```
@jugglerchris
Copy link
Owner

Hi,

I definitely would like to get RTL text right, but might need some help; I don't know any RTL languages, but am willing to read documentation! If there is a problem (I'm not sure if closing the ticket was a mistake or not), could you provide a complete (though ideally small) example HTML file and roughly how it should come out?

Thanks,

Chris

@NightMachinery
Copy link
Author

NightMachinery commented Oct 30, 2018 via email

@jugglerchris
Copy link
Owner

Thanks. I passed that page through html2term and it doesn't look too bad (to me) in pterm/PuTTY:

screenshot_rtl

However (assuming it looks right) it's for the wrong reasons. html2text doesn't currently understand the dir="rtl" attribute, so the table columns are in the wrong order... but (presumably) the bidirectional text algorithm in pterm ends up reversing the entire line. (This is more obvious if the columns weren't exactly the same width - the vertical bar between the columns is offset compared to the top/bottom borders).

I'm not completely sure what the most correct thing for html2text to be doing is - I think it should at least understand dir="rtl" and output some characters for swapping direction explicitly.

@jugglerchris
Copy link
Owner

I'm re-opening but it may take a little while to work out the best way to address this (and it sounds like different terminals behave differently, which won't help).

@jugglerchris jugglerchris reopened this Nov 4, 2018
@NightMachinery
Copy link
Author

@jugglerchris Can you share a screenshot of the textual content, not the table?
I have macOS so I cannot test on pterm. My results with Kitty were unreadable because the word order got reversed.

@jugglerchris
Copy link
Owner

Sure:
image

@NightMachinery
Copy link
Author

NightMachinery commented Nov 4, 2018 via email

@jugglerchris
Copy link
Owner

jugglerchris commented Nov 5, 2018

I'll try in kitty at some point (but I haven't got it handy at the moment).
I've just tried copying your two examples and pasting them into pterm - they both show the same as you say. Does kitty get that part right, and if so what font is it using? I'm a bit concerned that it might be tricky in a terminal with fixed-size character cells, but perhaps it's no different to other combining characters (I looked at the bytes and can see that the difference is a U+200C zero width non joiner).

(Edit: it was zero width non joiner)

@jugglerchris
Copy link
Owner

Although this is still an issue, I'm not currently working on it; currently I don't know of a way to get terminals to do the right thing with mixed LTR/RTL text, particularly in cases like tables, where some rows may have RTL and others LTR (for example the horizontal borders between two rows of cells). I also suspect different terminals behave differently - I'm open to multiple backend implementations if that's what's required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants