[texworks] Regex for DTX mode
Jonathan Kew
jonathan at jfkew.plus.com
Fri Sep 26 16:35:08 CEST 2008
On 26 Sep 2008, at 3:12 PM, Joseph Wright wrote:
> 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.
So something like "green,bold,bg:yellow"?
I don't want to go too far with this... different fonts, etc... but
maybe something more than just text color would be possible.
Note that the current implementation, at least, applies the first
match it finds and then skips to the end of the matched text; do you
feel there's a need to layer multiple styles on top of each other,
rather than this "exclusive" model?
>
>
>> 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!
It would, because it's using whitespace to separate the fields in the
configuration file!
I suppose I should change that, if you're wanting to be able to put
explicit spaces (as opposed to general whitespace, \s) into patterns.
I was trying to do something rather minimalist.... perhaps too much so!
How about requiring <TAB>s to separate the fields? Then space would be
allowed in patterns, and you can still use the \t escape sequence if
you need an actual tab there. (That's actually what I did first, then
I switched to using any whitespace as the separator; apparently a bad
move.)
JK
More information about the texworks
mailing list