[texworks] TeXWorks LaTeX syntax highlighting

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Nov 24 08:12:23 CET 2010


On 24/11/2010 01:33, Vafa Khalighi wrote:
> Texmaker has no problem highlighting Persian control sequences. See attached
> image. It exactly uses what I described before.

As TeXworks uses a regex approach to highlighting, the best plan seems 
to be to change the regex. The syntax-patterns.txt file contains:

   # control sequences
   blue		N	\\(?:[A-Za-z@]+|.)

which of course is therefore hard-coded for the 26 English letters only. 
I guess a better formulation would be

   # control sequences
   blue		N	\\(?:[\w@]+|.)

which seems to work with Persian in my very limited test. This of course 
depends on what the Qt system decides is a 'letter'. One problem with 
that is tha the regex engine counts '_' as it is used in a lot of 
programming languages as part of function names. I guess this is a small 
price to pay for a better approach to highlighting.

(I see that TeXmaker highlights '#1' as part of the name so it's not 
perfect either.)
-- 
Joseph Wright


More information about the texworks mailing list