RTL Languages Support

It’s mind-blowing that not a single flavor of markdown tried to address the localization issue. RTL (right-to-left) languages should be represented correctly in the rendered document (HTML or not). There’s been fragmented discussions on how to best work that in, some suggested using some right-pointing brackets ‘>’ before any RTL text and others chimed in variations of that.

I believe text in RTL languages should be treated just like any other text, except when rendered, where the parser should hopefully have a mechanism to detect RTL text blocks and adding the necessary ‘dir=“rtl”’ paragraphs.

Twitter has a js library that detects if the text being entered in from an RTL language and adjusts the direction directly. https://github.com/twitter/RTLtextarea Something like that should be worked into the parser itself.

9 Likes

Good point. I suppose one big question is whether an RTL mode should enable you to write Markdown special syntax RTL too, since otherwise when you are typing RTL you’ll have to write them “backwards”.

So for example in RTL mode an image link like hello world ![alt text](http://blah.com)

could be this:

(http://blah.com)[alt text]! مرحبا العالم

(disclaimer - arabic supposedly says “hello world” according to google, no way to verify)
Although since URLs remain LTR you get an odd mix of text directions.

Note that there is already a topic about RTL.

I have shared my thought on this matter here: Explicit RTL indication in pure Markdown

As per my experience and over a year following this issue, applying dir="auto" and in some cases applying unicode-bidi: plaintext solves 99% problem.

I have made a very simple Firefox add-on which applies dir=auto and text-align: start to headings and paragraphs of all pages. It works almost perfect in most of the cases. I have put some screenshot of how it works well in github for instance.

Please find it here and share your comments with me.

My idea for this add-on was to show how easily we can handle this issue universally and perhaps provide a simple but practical guideline for handling such issues. I hope soon there be no need for such add-ons.

2 Likes

I just want to inform all of you that long after Gitlab, Github also took the approach of using dir="auto" of tags to make them render text in relevant direction based on their content.

This is a so far the best approach I am came across and I don’t know why it doens’t become the standard way of parsing md into html.

Regarding editors, of course we need to ask them to add bidi support in the same way (consider the first strong character to determine direction of the text). Some editors (like Gedit or Kate) already support it. Others should also do. If they don’t there will be no way to properly make RTL markdown documents which is bad for sure.