RTL and MathJax

Hello all :slight_smile:
I have some small question on how to use topics that mix English and RTL language like Hebrew, especially if they use the MathJax plugin. In our Discourse forum it looks like:

The final result is great! The only problem is to write those equations. It could get really hard to write long equations. I understand that mixing RTL with LTR could make problems but I was wondering if it’s doable? Is there a way to solve it?

You could try enabling the support mixed text direction site setting. Have a look at Supporting mixed text directions 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 :slight_smile:

안녕하세요 :slight_smile:
다시 한번 도전해 봅니다. 코드 블록과 MathJax 블록 사이에 LTR(왼쪽에서 오른쪽) 정렬을 어떻게든 적용할 수 있을까요? RTL(오른쪽에서 왼쪽) 포럼에서 코드나 수식을 작성하는 것이 불편하게 느껴집니다:

아래와 같이 보이길 바랍니다:

이를 달성할 수 있는 방법이 있을까요?

네, 그렇게 하면 어려울 수 있습니다. 이상적인 해결책은 아니지만, 테마 구성 요소를 사용하여 편집기(composer)에 방향 전환 토글을 추가할 수 있습니다. 이를 통해 코드 작성 시 편집기 편집 영역 전체의 방향을 LTR로 전환할 수 있습니다. 아래 코드는 혼합 텍스트 방향 지원 사이트 설정이 활성화될 때 사용되는 코드에서 추출한 것입니다. 사이트의 기본 방향이 RTL인 경우 코드를 그대로 유지하십시오. 기본 방향이 LTR인 경우, 토글을 처음 사용할 때 더블 클릭하지 않도록 삼항 연산자에서 'rtl'을 'ltr'로 대체하십시오.

<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', // 기본값을 사이트의 기본 텍스트 방향으로 설정하십시오.
                    newDir = currentDir === "ltr" ? "rtl" : "ltr";
                $textArea.attr("dir", newDir).focus();
            }
        });
    });
</script>

편집기의 방향을 변경하려면 방향 전환(Toggle Direction) 아이콘을 클릭하십시오: