[texworks] Regex challenges

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Apr 10 15:01:24 CEST 2009

Hello all,

I'm trying to improve my set of regex expressions for writing DTX files.
 There are a couple I'm stuck on: suggestions welcome.

1) The standard pattern for matching control sequences is
\\(?:[A-Za-z@]+|.) This behaves OK unless I follow the sequence by a '
character. If I do, anything following the last @ is not coloured but
stays black.  If I extend the match sequence for LaTeX3-like code
\\(?:[A-Za-z at _:]+|.) then anything after the last non-letter (@, :, _)
is not coloured.  Is my expression defective or is this the matching system?

2) In a DTX, comments in the explanation part start ^^A. This is easy to
match with \^\^A, but that matches even in the code blocks.  Ideally,
I'd like:
  - If the line start %, comment = ^^A
  - If the line starts without %, comment = %
but only colouring from the start of the comment, not the start of the
line.  Is this doable at all?

Thanks in advance for any clues.
Joseph Wright

More information about the texworks mailing list