GNOME Bugzilla – Bug 754877
LaTeX: no highlighting for RTL commands
Last modified: 2015-10-01 14:26:45 UTC
Created attachment 311137 [details] Screenshot Hey folks, I'm wondering if LaTeXilla could handel RTL commands properly and make them highlighted just like LTR commands. BTW, Nice work, keep on guys! :)
It's quite a corner case. Anyway if it's easily fixable, it's in GtkSourceView.
Can you provide a small LaTeX sample file in which the problem occur? It's easier for us to reproduce the problem and see if it is fixed with the latest version.
Created attachment 311148 [details] TeX file producing the error. Here's a working example of what I am talking about. If you want to compile it, use XeLaTeX: $ xelatex RTLhighlights
Thanks, I confirm the bug with the development version.
Created attachment 311172 [details] [review] The patch to fix the problem Added a RTLcommand context to the "latex.lang" file. It completely fixed the problem on my system. This part (\*[\ء-\ی]*) handles something called "nimfaseleh" in Persian language which makes it possible to use commands like: \متنلاتین
I didn't look at the latex.lang implementation, but it looks like a bug like: \\[a-zA-Z0-9]+ that should be changed as something like: \\\w+ or \\[[:alnum:]]+ to match any valid "word" or alphanumeric characters for a LaTeX command.
Review of attachment 311172 [details] [review]: Adding such a special case for just one language is not a great idea.
(In reply to Sébastien Wilmet from comment #7) > Review of attachment 311172 [details] [review] [review]: > > Adding such a special case for just one language is not a great idea. You're absolutely right. My suggestion for generic command's expression would be: \\\@?\w+(\w|)*\*? in which @ symbol only can appear in the beginning of a command and the part (\w|)* handles the Persian's "nimfaseleh". Also, we can ignore the "nimfaseleh" and use the following: \\\@?\w+\*? if it is OK, tell me to make the patch.
(In reply to iconoclast from comment #8) > \\\@?\w+(\w|)*\*? I don't understand the part (\w|), it looks wrong. Is there something missing after the | ? Or you need to escape the ) ? > the part > (\w|)* handles the Persian's "nimfaseleh". Also, we can ignore the > "nimfaseleh" and use the following: > > \\\@?\w+\*? Why the second regex doesn't handle the "nimfaseleh"?
There exists Unicode character <U+200C> after | symbol. In fact (\w|) is (\w|<U+200C>). I suppose it's a regex interface problem, I'm working on it. I think it's better to ignore the "nimfaseleh" thing for now. I'll make the patch soon.
Created attachment 311205 [details] [review] The new patch I had to use [[:alnum:]] instead of \w in order to properly dealing with characters like underline (_).
I don't know why this seems to be deserted, but if it is because of the regex problem I mentioned before, the regex this source is using, never going to support that. Anyhow, I think it's fine to go with only letters and numbers.
The following fix has been pushed: b8e67cc latex: fix RTL command bug
Created attachment 312488 [details] [review] latex: fix RTL command bug
I've modified the commit message, to include the bug URL at the end and add latex in the title.