After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754877 - LaTeX: no highlighting for RTL commands
LaTeX: no highlighting for RTL commands
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
3.17.x
Other Linux
: Normal minor
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2015-09-11 11:54 UTC by iconoclast
Modified: 2015-10-01 14:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot (17.23 KB, image/png)
2015-09-11 11:54 UTC, iconoclast
  Details
TeX file producing the error. (226 bytes, text/plain)
2015-09-11 14:16 UTC, iconoclast
  Details
The patch to fix the problem (1.26 KB, patch)
2015-09-11 18:27 UTC, iconoclast
needs-work Details | Review
The new patch (764 bytes, patch)
2015-09-12 11:19 UTC, iconoclast
committed Details | Review
latex: fix RTL command bug (814 bytes, patch)
2015-10-01 14:24 UTC, Sébastien Wilmet
committed Details | Review

Description iconoclast 2015-09-11 11:54:07 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! :)
Comment 1 Sébastien Wilmet 2015-09-11 13:21:44 UTC
It's quite a corner case. Anyway if it's easily fixable, it's in GtkSourceView.
Comment 2 Sébastien Wilmet 2015-09-11 13:23:19 UTC
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.
Comment 3 iconoclast 2015-09-11 14:16:00 UTC
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
Comment 4 Sébastien Wilmet 2015-09-11 15:17:53 UTC
Thanks, I confirm the bug with the development version.
Comment 5 iconoclast 2015-09-11 18:27:24 UTC
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:
\متن‌لاتین
Comment 6 Sébastien Wilmet 2015-09-11 18:55:56 UTC
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.
Comment 7 Sébastien Wilmet 2015-09-11 18:58:38 UTC
Review of attachment 311172 [details] [review]:

Adding such a special case for just one language is not a great idea.
Comment 8 iconoclast 2015-09-11 19:44:46 UTC
(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.
Comment 9 Sébastien Wilmet 2015-09-12 10:19:46 UTC
(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"?
Comment 10 iconoclast 2015-09-12 10:36:31 UTC
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.
Comment 11 iconoclast 2015-09-12 11:19:45 UTC
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 (_).
Comment 12 iconoclast 2015-09-30 23:02:37 UTC
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.
Comment 13 Sébastien Wilmet 2015-10-01 14:23:57 UTC
The following fix has been pushed:
b8e67cc latex: fix RTL command bug
Comment 14 Sébastien Wilmet 2015-10-01 14:24:07 UTC
Created attachment 312488 [details] [review]
latex: fix RTL command bug
Comment 15 Sébastien Wilmet 2015-10-01 14:26:45 UTC
I've modified the commit message, to include the bug URL at the end and add latex in the title.