こんにちは ![]()
英語とヘブライ語のような RTL 言語を混在させるトピックの使い方、特に MathJax プラグインを使用する場合について、小さな質問があります。私たちの Discourse フォーラムでは、以下のように表示されます。
最終的な結果は素晴らしいです!唯一の問題は、それらの数式を書くことです。長い数式を書くのは本当に大変になる可能性があります。RTL と LTR を混在させることで問題が発生することは理解していますが、実現可能かどうか気になっています。何か解決策はありますか?
こんにちは ![]()
英語とヘブライ語のような RTL 言語を混在させるトピックの使い方、特に MathJax プラグインを使用する場合について、小さな質問があります。私たちの Discourse フォーラムでは、以下のように表示されます。
最終的な結果は素晴らしいです!唯一の問題は、それらの数式を書くことです。長い数式を書くのは本当に大変になる可能性があります。RTL と LTR を混在させることで問題が発生することは理解していますが、実現可能かどうか気になっています。何か解決策はありますか?
You could try enabling the support mixed text direction site setting. Have a look at What does the support mixed text direction setting do? for details about the setting.
When enabled, the setting adds a Toggle Direction button to the composer:
I haven’t tested this with the MathJax plugin, but it should make it a lot easier to write long equations. If you try the setting and run into any issues, please let us know.
Thanks for the reply!
I actually have tried it before posting this topic but forgot to mention it. It does help to look better at equations that are separated with $$-$$, but it does not help for one-liner equations. Also, it converts the RTL language to be LTR (because you can’t switch directions for only one line) which also makes it look messy. Do you have other ideas?
Thanks again for the reply 
Hi all 
Trying my luck again. Is it possible to somehow achieve LTR in between the code and MathJax blocks? It feels awkward to write code or formulas in RTL forums:
It should look like:
Anyway to achieve this?
Yes, that would be difficult. It’s not an ideal solution, but you can add a direction toggle to the composer with a theme component. That will allow you to switch the direction of the entire composer edit area to ltr when you are writing code. The code below is extracted from the code that is used when the support mixed text direction site setting is enabled. If your site’s default direction is rtl, keep the code as it is. If the default direction is ltr, replace 'rtl' in the ternary operator with 'ltr' to avoid having to double click the first time the toggle is used.
<script type="text/discourse-plugin" version="0.8.32">
api.onToolbarCreate(toolbar => {
toolbar.addButton({
id: "toggle-direction",
group: "extras",
icon: "exchange-alt",
shortcut: "Shift+6",
title: "Toggle Direction",
perform: () => {
const $textArea = $(".d-editor-input");
let currentDir = $textArea.attr("dir") ? $textArea.attr("dir") : 'rtl', // set the default to your site's default text direction.
newDir = currentDir === "ltr" ? "rtl" : "ltr";
$textArea.attr("dir", newDir).focus();
}
});
});
</script>
Click the Toggle Direction icon to change the composer’s direction: