Display RTL (right-to-left) text properly #1021

Closed
opened 2023-05-14 08:03:17 +02:00 by mokazemi · 9 comments
Image

If a markdown text is in a Right-to-Left language (Farsi, Arabic, etc), Codeberge doesn't show it in proper way. Instead, it shows it Left-to-Right.

Also the same thing is true for textboxes (Like the one that I'm righting in)!

I attach the screenshots to see how it's now and how it should be.

Wrong (Codeberg)
image

Correct (Github)
image

If a markdown text is in a Right-to-Left language (Farsi, Arabic, etc), Codeberge doesn't show it in proper way. Instead, it shows it Left-to-Right. Also the same thing is true for textboxes (Like the one that I'm righting in)! I attach the screenshots to see how it's now and how it should be. ❌ Wrong (Codeberg) ![image](/attachments/405f2368-8488-4f17-a5ae-a54ff16fda27) ✅ Correct (Github) ![image](/attachments/c64e58e6-87fa-4a92-b639-1835c1675cc6)
Image

Any link to such a sample file?

Any link to such a sample file?
Image
Author
> Any link to such a sample file? Yes. @silverwind This is the file on Codeberg: https://codeberg.org/mokazemi/Linux-notes-and-cheatsheet/src/branch/main/Set-Persian-Font-Globally.md And this is the same file on Github: https://github.com/mokazemi/Linux-notes-and-cheatsheet/blob/main/Set-Persian-Font-Globally.md
Image

To display bidirectional texts properly, the best way is to add dir="auto" to every element. and in CSS, should use start and end instead of left and right. for example: text-align: start;. and similar things for margins, padding and...

To display bidirectional texts properly, the best way is to add `dir="auto"` to every element. and in CSS, should use `start` and `end` instead of `left` and `right`. for example: `text-align: start;`. and similar things for margins, padding and...
Image

...the best way is to add dir="auto" to every element...

Not exactly.
This doesn't work on nested elements (for example li inside ul)

> ...the best way is to add `dir="auto"` to every element... Not exactly. This doesn't work on nested elements (for example `li` inside `ul`)
Image

Looking at how GitHub does it, they do appear to indeed add dir=auto to many elements. There are CSS properties like direction, but apparently those do not have a auto value.

image

Looking at how GitHub does it, they do appear to indeed add `dir=auto` to many elements. There are CSS properties like `direction`, but apparently those do not have a `auto` value. ![image](/attachments/738a4d5b-50d0-4aba-a428-25929873ab37)
133 KiB
Image

WIP at https://github.com/go-gitea/gitea/pull/24816, I added the dir=auto, but it does nothing. Not sure what else is needed. Feedback welcome on how to get it to work.

WIP at https://github.com/go-gitea/gitea/pull/24816, I added the `dir=auto`, but it does nothing. Not sure what else is needed. Feedback welcome on how to get it to work.
Image
Author

WIP at https://github.com/go-gitea/gitea/pull/24816, I added the dir=auto, but it does nothing. Not sure what else is needed. Feedback welcome on how to get it to work.

I did a lot of experiments on Codeberg and Github and I guess finally found the problem.
The thing is, somewhere on Codeberg css you are setting text-align: left; which causes the text direction to be RTL, but the align is still LTR.

image

That .ui.table selector is selecting the grandparent div of markdown text.
Removing that text-align: left; or adding text-align: initial; to the child(s) solves the issue.

> WIP at https://github.com/go-gitea/gitea/pull/24816, I added the `dir=auto`, but it does nothing. Not sure what else is needed. Feedback welcome on how to get it to work. I did a lot of experiments on Codeberg and Github and I guess finally found the problem. The thing is, somewhere on Codeberg css you are setting `text-align: left;` which causes the text direction to be RTL, but the align is still LTR. ![image](/attachments/432b2294-7180-44f5-952e-19a5d44eecd5) That `.ui.table` selector is selecting the grandparent div of markdown text. Removing that `text-align: left;` or adding `text-align: initial;` to the child(s) solves the issue.
Image

Thanks, I figured that out as well. It's a short-sighted style coming from the Fomantic UI framework, which we now override to text-align: start and then it works. https://github.com/go-gitea/gitea/pull/24816 will merge momentarily.

Thanks, I figured that out as well. It's a short-sighted style coming from the Fomantic UI framework, which we now override to `text-align: start` and then it works. https://github.com/go-gitea/gitea/pull/24816 will merge momentarily.
Image
Owner

This seems to have been fixed. Huge thanks @silverwind! Closing...

This seems to have been fixed. Huge thanks @silverwind! Closing...
Sign in to join this conversation.
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#1021
No description provided.