4

I'm editting my GitHub readme and I need to add text in two different alignments. Part of the readme is in English and should be left to right and another part is in a different language (Persian, in my case) which has a right to left alignment. Since GitHub editor does not have any setting to change the text alignment, I wonder if there's any other way to do this?

I've already tried HTML tags like <div dir="rtl">متن فارسی</div> to change the alignment but it doesn't work.

Desired output: enter image description here

Edit

After getting feedback from @Quentin, I realized that the problem was that when you go to the Preview tab, you cannot see the changes, however, once you Commit, changes will be applied. So, <div dir="rtl">متن فارسی</div> does work, the only thing is that you will see changes after the commit, not in preview tab.

Pedram
  • 2,421
  • 4
  • 31
  • 49
  • I think this question in StackOverFlow help you [enter link description here](https://stackoverflow.com/questions/14051715/markdown-native-text-alignment) – Mostafa Hasanpour Feb 02 '20 at 08:54
  • I can't reproduce the issue: https://i.imgur.com/q6m8Pbg.jpg – Quentin Feb 02 '20 at 09:22
  • @Quentin may I ask how you generated the output? – Pedram Feb 02 '20 at 09:28
  • I copy/pasted `
    متن فارسی
    ` into a README.md, added two blank lines then typed a line of english, then pushed it to Github.
    – Quentin Feb 02 '20 at 09:31
  • @Quentin just made an edit. Still did not get an answer to my previous comment though: align attribute should not be used if we have an option to use CSS. I don't see how I can use CSS for markdown?! – Pedram Feb 02 '20 at 09:42

3 Answers3

2

This input which has 2 separate DIV's with one empty line after the last line of the first DIV: enter image description here

Will be rendered to: enter image description here

VahidN
  • 18,457
  • 8
  • 73
  • 117
2

For a quick fix, I've just realized that <p align="right">text</p> works, but a lot of variations with divs and style within the tag did not.

Sylvia Pap
  • 316
  • 2
  • 4
1

Update Jan. 2022: GitHub editor supports RtL.


Original answer (Q1 2020)

This is followed by dear-github/dear-github issue 275

I think this support is also needed in markdown files, especially in ReadMe files.

Adding such support is very easy: just allow to add a tag "dir='rtl'" at the beginning of a document, and then wrap the entire document inside a "div dir='rtl'".

Also today it is possible to put all text inside a "div dir='rtl'", but then it is not possible to use markdown inside.

So this is not yet supported (at least in the preview, as mentioned by the OP).
It seems to be applied once committed, as tested by Quentin.

There is a discussion on Mardown/Commonmark RTL support.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250