Support RTL blocks for LTR-layout website and vice versa

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:

4 Likes

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.

4 Likes

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

Should this be white listed @eviltrout?

2 Likes

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:
https://github.com/scossar/discourse-text-direction

2 Likes

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

https://github.com/discourse/discourse/commit/4d8584f427863fd3bed176808b82e38379c41147

9 Likes

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