Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RTL in Markdown

Is there any existing addon spec for markdown that includes support for RTL languages?

What I'm hoping for is something like

This paragraph is left to right <- This paragraph is right to left 

Or something... I can tweak my parser to handle this but I want to make sure it doesn't exist already.

like image 756
Karim Avatar asked Feb 13 '10 15:02

Karim


People also ask

Does markdown support RTL?

Right-to-left languages are now supported natively in Markdown files, issues, pull requests, discussions, and comments.

How do you write RTL in markdown?

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.


2 Answers

Actually as my friend Aevyz reminded me, Markdown parses HTML in it.

You won't need to change your parser. The quickest path to solve that I could think of is this:

<div dir="rtl">  سلام دنیا  مرحبا العالم  שלום בעולם  ہیلو دنیا </div> 

So you need to add literally two lines to turn a whole document or an arbitrary section of it into RTL. It will be more compatible than an own script.

like image 158
Makan Tayebi Avatar answered Sep 19 '22 13:09

Makan Tayebi


Not exactly markdown, but this is how you can override paragraph direction in StackExchange questions and answers (this method does not work for comments):

add &#x202b; (RIGHT-TO-LEFT EMBEDDING) in the beginning of a paragraph does control the direction of this paragraph (auto-reset on <br/> or empty line):

&#x202b;test מה זה? YES<br/> test1 מה זה? NO test2 מה זה? NO  &#x202b;test1 מה זה? YES test2 מה זה? YES 

‫test מה זה? YES
test1 מה זה? NO test2 מה זה? NO

‫test1 מה זה? YES test2 מה זה? YES

like image 45
Alex Cohn Avatar answered Sep 21 '22 13:09

Alex Cohn