[texworks] Regex for DTX mode

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Sep 26 16:12:36 CEST 2008


Will Robertson wrote:
> On 26/09/2008, at 10:17 PM, Joseph Wright wrote:
> 
>> I'm trying to get the regex system to give me something similar to "DTX
>> Mode" in WinEdt.  I note that I can't (1) make things bold or italic, or
>> (2) alter the background colour, both of which would be nice.
> 
> I'm not so fussed about #1 but #2 would be excellent :)

Yes, background is more of an issue for me too.  I'm thinking that this
allows combinations of properties, which I like the idea of.

> I hadn't looked yet at TeXworks regexing code for all this.
> Looks very promising!
> 
>> # Macrocode
>> darkolivegreen    N    ^%....\\(?:begin|end)\{macrocode\}
> 
>> I'd like to improve on the macrocode one: how do I specifiy exactly four
>> spaces?
> 
> I'm pretty confused by this regex engine. This is the best I can do:
> 
> ^%[\s]{4}\\(?:begin|end)\{macrocode\}
> 
> But that still matches four tabs. Why can't I write ( ){4} or (\ ){4} or
> even [\s^\t]{4} to match four spaces only?

As it was, it took me ages to get what I have.  The really obvious
(typing four spaces) seems to fail too!
-- 
Joseph Wright


More information about the texworks mailing list