[texworks] syntax-patterns.txt

Paul A Norman paul.a.norman at gmail.com
Wed Jun 8 06:05:45 CEST 2011


One small thing that I have find useful is to make my footnotes grey
out in the editor, makes them interfere less with the text when skim
reading for editing, and also helps me conversely spot where they are.

Under my latex section in syntax-patterns.txt



gray Y \\footnote\{.+\}

Also as I sometimes move the \end{document} up through the document
when troubleshooting any starnge errors (normally caused through
pasting in something from a 'strange' character set) ...

# LaTeX \begin or \end {document}

red    N    \\(?:begin|end)\{document\}

Any one else done anything like these or improved upon anything else?


On 4 June 2011 11:27, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Thanks very much Stefan,
> Paul
> On 3 June 2011 22:52, Stefan Löffler <st.loeffler at gmail.com> wrote:
>> 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