Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Does anyone have a syntax pattern for TeXworks’s syntax-patterns.txt that will correctly highlight Expl3 code? I.e., something that will recognize that the entirety of \cs_new:Npn is a command sequence—although highlighting the :Npn suffix differently might not be a bad idea.

share|improve this question
    
nice idea (even though texworks wouldn't be my first choice when writing code :-) ) –  Frank Mittelbach Aug 3 '12 at 20:40

1 Answer 1

up vote 6 down vote accepted

I use a colour scheme based loosely on that from WinEdt's DTX submode (I used to use WinEdt). This is for editing .dtx files, and nowadays includes support for l3docstrip's @@ convention:

[LaTeX DTX]

# comments
red        Y    \^\^A.*

# Guards
orange         N    %<(?:[A-Za-z0-9!\|]+|.)>
limegreen      N    %<\*(?:[A-Za-z0-9!\|]+|.)>
crimson        N    %</(?:[A-Za-z0-9!\|]+|.)>
darkviolet     N    %<@@=(?:[A-Za-z]+|.)>

# special characters
darkred        N    \^\^\^\^\^[0-9a-z]{5}
darkred        N    \^\^\^\^[0-9a-z]{4}
darkred        N    \^\^\^[0-9a-z]{3}
darkred        N    \^\^[0-9a-z]{2}
darkred        N    [$#^_{}&]
gray        N    ^%%.*
gray        N    ^%

# Macrocode
green        N    \\(?:begin|end)\{macrocode\}

# LaTeX environments
darkgreen    N    \\(?:begin|end)\s*\{[^}]*\}

# control sequences
blue        N    \\(?:[A-Za-z@:_]+|.)

The key line here is the last one, which does the highlighting request. Of course, this is just a case of getting the regular expression right (if only this were easy!).

share|improve this answer
    
I’d been using a version of this (without the @@-highlighting) based on an earlier answer of yours, and didn’t realize it already covered expl3. Thank you! –  J. C. Salomon Aug 5 '12 at 4:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.