Support RTL blocks for LTR-layout website and vice versa


(Safa Alfulaij) #1

Users would like sometimes to write both RTL and LTR text in one single post.
Right now, the direction of everything in the website (including text editor and posted posts) depends on the layout of the language used. Arabic means RTL and English means LTR.
It would be helpful if one can choose that he wants these paragraphs to be opposite the direction of the website.
I tried:

<div dir="rtl">
…
</div>

to force a direction change since HTML is supported, but that didn’t do anything, even if it does on GitHub.
If the above works, then it will be enough as a first step :wink:


Recommended way to handle RTL mixed with LTR languages
Now in master: ES6 Modules + Text Rendering
(Simon Cossar) #2

You need to whitelist the dir attribute. I previously had this working in a plugin, but some changes have been made to the way text is rendered in the latest Discourse release. Now in master: ES6 Modules + Text Rendering
It won’t be difficult to get it working again.


(Eli the Bearded) #3

It’s a little more awkward, but don’t the RTL and LTR marks work?

http://dotancohen.com/howto/rtl_right_to_left.html#TableOfNonprintingCharacters


(Jeff Atwood) #4

Should this be white listed @eviltrout?


(Simon Cossar) #5

I’ve wanted to figure out how to work with the new text rendering setup for a while now, so I made a plugin that adds bbcode tags for text-direction. It lets you use the tags [text-direction=rtl][/text-direction] for rtl text and [text-direction=ltr][/text-direction] for ltr text.

I have only tested this lightly on my local setup, so if you use it and run into any problems, let me know. Note: this plugin will only work on the latest version of Discourse, where text rendering is using ES6 modules. If you are using an older version of Discourse, it wouldn’t be much work to convert the plugin to work for that.

Check it out here:


(Robin Ward) #6

Sure, this seems reasonable. I’ve whitelisted it:


(Jeff Atwood) #7

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.