[texworks] syntax-patterns.txt
Stefan Löffler
st.loeffler at gmail.com
Fri Jun 3 12:52:07 CEST 2011
Hi,
On 2011-06-03 04:48, Paul A Norman wrote:
> Just wanted to check a couple of things please - got into a mind maze
> with this stuff.
Yeah, that can happen terribly easily with regexps ;).
> With syntax-patterns.txt which dialect of regular expressions is being
> used please?
The Qt dialect (http://doc.trolltech.com/4.7/qregexp.html#details). In
fact, the string given in syntax-patterns.txt is simply wrapped into a
QRegExp object (see src/TeXHighlighter.cpp at 226).
> In that dialect does .* mean anything many times?
Yes, anything zero or more times (one or more would be .+). The
quantifiers are also greedy (they match as much as they possibly can).
> Can () be used to choose which part of an expression is colourised?
> For e.g.
>
> skyblue N .*\{(http[s]://.*)}
>
> -- Would colour only the actual address?
No, not at the moment, unfortunately. It should be possible to use
look-ahead assertions to match a string only if it followed by a certain
string (without including the second in the match), but look-behind
assertions are not supported, unfortunately.
In principle, colorizing the captured text could probably be added to
the code, but it would have drawbacks for people who are lazy and just
write, e.g., "(W|w)arning" instead of "(?:W|w)arning".
BTW: You probably want something like "\{(https?://[^}]*)\}".
HTH
Stefan
More information about the texworks
mailing list