QTodoTxt
QTodoTxt copied to clipboard
Support for non-latin or language independent markup (2)
(Request from @damascene, taken from #171)
In RTL languages like Arabic, Hebrew, Persian and Urdu text will align to the left instead of the right but those languages are read from right to left.
For example:
(A) شراء حليب
شراء حليب
The first will be aligned to left and the second will be aligned to right in qtodo.
That looks ugly and is clearly a bug (also look at the position and order of the parenthesis). I think the problem is somewhere in HTML-output of https://github.com/QTodoTxt/QTodoTxt/blob/master/qtodotxt/lib/task_htmlizer.py. I'm not very experienced in RTL-languages, so any hints or contributions are welcome.
Thank you for splitting it. I would like to note that if priorities are set with numbers the alignment change will not happen (1) شراء حليب will still align to right as normal behavior but because of the (A) letter is before the RTL text then it will align to the left instead of the right.
This same behavior is in gedit and other softwares and this will happen when you but the "x" (complete) character too before the task
Since you are using HTML in the output, you can use the dir
attribute available in HTML elements. For instance <element dir="rtl"></element>
will the make the direction of what's inside element
is from right to left. If you prefer to do in CSS, you can CSS attribute direction
which also accepts values ltr
and rtl
.
Now, in case there is a mixed text (contains both LTR and RTL characters), you may want to use something that lets you decide which character has the strongest influence and should decide therefore the direction. Modern browsers like Firefox and Chrome use HTML attribute dir = "auto"
to employ their own algorithms to determine the direction in such cases. For more information, see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir.
Thanks for your hint. I will have a look.