Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## #667 Syntax highlight of newverb not ignoring | text inside bars |

None
open
nobody
1
2014-03-16
2014-03-16
Nelso G. Jost
No

When defining a newverb command, like so:

% inline code citation. Usage: \cc|...|
\usepackage{newverbs}
\newverbcommand{\cc}{\color{red}}{}


text inside bars, like in \cc|$|, are not ignored. In the example, it will highlight the rest of document as open inline math mode. This is a very nice editor, by the way. Hopefully this is an easy fix... 1 Attachments ## Discussion • Tim Hoffmann 2014-03-16 This is not easy to fix, because is is not possible to register custom verbatim commands in the editor. I've now impelemeted a workaround (hg 4317 (db61535d96de)). You can put % !TXS fix-highlight:close-$


at the end of the line to stop the wrong math highlighting. At least, the following lines are ok then.

Will be included in TXS > 2.7.0 (2.7.0 already in the build for release).

Last edit: Tim Hoffmann 2014-03-16
Attachments

• Nelso G. Jost
2014-03-16

Just to confirm: it is not possible to tell the lexer or highlighter to treat text inside vertical bars within the pattern \whateverword|text| as inline verbatim?

Regarding the workaround, could it be a simpler expression, like %$ or else? For now I've been using \cc|text| normally if text does not have a $, and {\mycolor \verb|text|} otherwise.

• Tim Hoffmann
2014-03-17

It is possible to mark the pattern \whateverword|text| as verbatim in the language definition. But

1. I don't want to do it for arbitrary whateverword. It's wrong for most and pretending that it has special meaning could mislead users. I'd rather miss something in the detection than generate positive false matches. If you have chosen to use \cc, at least you know it's user-defined and a LaTeX editor will never be able to generate 100% correct highlighting, because you can redefine everything.

2. This highlighting is statically defined and cannot be changed at runtime. (Well it can but it's more effort to implement and computationally more expensive). So dynamically limiting whateverword is not easily possible. Moreover, we currently have no means of knowning or infering that the first argument in \newverbcommand is to be interpreted like \verb.

3. \verb is really nasty because you can use almost any character as delimiter. So you might use \verb+text+. You can imagine what would happen if we would highlight \whateverword<arbitrarychar>text<arbitrarychar> as verbatim without limiting it to whateverwords that really have that meaning. Consider e.g.
a\quad+\quad b\quad+\quad c.

Concerning %$, you are right. I was a bit over-explicit. I will change it as suggested. • Nelso G. Jost 2014-03-17 Well, thankyou for the quick responsiveness!! I think I got it! Also noted that the rule for \verb is present for \lstinline|text|. I only choose verbatin over \texttt because I didn't wanted to keep scaping lots of$, %, >. And colorized verbatim are good for presentations.

• Tim Hoffmann
2014-03-16

Ticket moved from /p/texstudio/bugs/926/

Moved to feature requests because a workaround is available and a proper fix needs support of custom verbatim definitions.

Last edit: Tim Hoffmann 2014-03-16