GNOME Bugzilla – Bug 128223
Latex: \$ and \% are not escaped
Last modified: 2005-02-07 16:53:13 UTC
Using GEdit on a LaTeX file, the commands \$ and \% are not escaped. eg: it treats \$ as $ (start of inline math mode) and waits for another $ or \$ before re-starting normal syntax colouring. Same for \%. Using version 0.7
Created attachment 21936 [details] Example screenshot 54k png
*** Bug 140992 has been marked as a duplicate of this bug. ***
*** Bug 157362 has been marked as a duplicate of this bug. ***
It does not seem possible to create a good latex syntax file. I found no specification of what is possible to specify on a syntax file, but I looked all examples and it seems that escaped characters can't be represented. The dollar, for instance is treated as block comment, which is defined by a starting regex and an ending regex. To avoid escaped dollar signs, one could use the regex [^\\]\$ as starting regex, but then the character before the dollar would also be marked as comment. It seems to me this could be solved if keywords were matched before comments. This way, the keyword \$ could be defined, preventing the $ from being matched as the begining of a comment.
*** Bug 164644 has been marked as a duplicate of this bug. ***
Forgive my naive incompetence and my latex ignorance, but why cannot we have the following line as in C and many other .lang files? <escape-char>\</escape-char>
Well, using the "escape-char" seems to actually work! Paolo found the answer! It seems that all we have to do is to put the "<escape-char>\</escape-char>" in latex.lang file... I'm sorry for stating that "it does not seem possible to create a good latex syntax file".
(This is Debian bug <http://bugs.debian.org/280235>.)
Adding <escape-char>\</escape-char> seems to work for me. I'm going to commit it. Fixed in CVS HEAD.