sagemath / cloud

*MOVED TO* https://github.com/sagemathinc/cocalc
https://cocalc.com
Other
137 stars 31 forks source link

RTL support #21

Open haraldschilly opened 10 years ago

haraldschilly commented 10 years ago

A large part of the world writes in languages that go from right-to-left. The first step to support their way of writing in a setting, where commands and other text is in English, is to selectively switch the writing direction for one single line of code. This can be accomplished by setting the dir="rtl" attribute in the div for one line.

<div class="CodeMirror" style="position: relative;" dir="rtl">

or via CSS: div { direction: rtl; }

This would make it necessary to make each line aware of its writing direction, store this, and handle surrounding line breaks and much more. Also, the user interface would need a button, which selectively toggles the writing direction and also serves as an indicator for the current line.

Also, a keyboard shortcut like Alt+d (?) could be introduced, which would also allow toggling the direction in other areas like chat, project name, etc.

(Originally, this arose in editing LaTeX documents, but it is a more general issue that covers all aspects where the CodeMirror editor is used to edit line-based documents.)

haraldschilly commented 10 years ago

Related links that might help learning about how to support this:

pointing to an automatic solution:

bsamadi commented 10 years ago

This is a blog post about bi-directional text: http://marijnhaverbeke.nl/blog/cursor-in-bidi-text.html

bsamadi commented 10 years ago

You might want to consider contacting this group to ask for support for implementing bidi text: http://www.qcri.org.qa/our-research/arabic-language-technologies

bsamadi commented 10 years ago

Since this is related to RTL support in LaTeX, I add it here. There is a Google Group called "Persian Computing". I posted our experiment on Sage Cloud. Here is a response from the developer of the XePersian LaTeX package:

Vafa Khalighi wrote: Interesting. Suggestions: I could not find an option to change the engine, so I had to go to the build button and type xelatex instead pdflatex in the window manually. Not sure if I missed something or the option to choose the engine does not exist. \xepersianversion gives me version 11 and something which is too old. Please update the TeX distribution on the server. Current version of xepersian is 13 and current version of bidi is 13.8 (which xepersian uses for bidirectional typesetting). Newer versions are better since some bugs get fixed or there could be improvements in performance. It may be too soon until simurgh[1] becomes quite stable but in due time, you can consider using that too since it will have more features than xepersian.

[1] The first experimental version of simurgh is now available on CTAN: http://ctan.org/pkg/simurgh

Please note that it may take few years until simurgh can be ready for production.

bsamadi commented 10 years ago

Automatically set the direction of paragraphs in RTL languages.

https://github.com/hasenj/bidiweb

bsamadi commented 9 years ago

Yet another guide about RTL support: http://www.i18nguy.com/markup/right-to-left.html

cben commented 9 years ago

For CodeMirror, setting dir=rtl was definitely not enough. It does too much by itself (drawing a cursor, motion etc) for that to work... A summer-of-code project improving CodeMirror bidi to allow RTL lines has just recently come to fruition: http://discuss.codemirror.net/t/two-new-experimental-branches-open-for-testing-mobile-and-direction/74 https://rawgit.com/codemirror/CodeMirror/direction/demo/bidi.html While not ready to be merged yet, and movement keys in RTL lines behave somewhat wrong, it finally laid the hard foundations that will make this doable.