[texworks] Syntax highlighting rules for noweb files

Charlie Sharpsteen chuck at sharpsteen.net
Fri Oct 23 04:54:18 CEST 2009

Hello Everyone,
I've been playing around a little with custom syntax highlighting rules in
TeXworks using r482 on OS X 10.6. I've used TeXshop, and now TeXworks quite
heavily to edit and typeset Sweave files beacuse the integrated PDF viewers
keep me informed of the effects my embedded code chunks have on the final
reports. Sweave uses the noweb style to mix R code in with a LaTeX document.

The problem I've had with nearly every LaTeX editor is that the R code
inside the chunks is never processed using any sort of sane syntax
highlighting. Use of % signs is particularly troubling. Vim does a nice job
with highlighting Sweave code by applying rules for R syntax inside the code
chunks and rules for LaTeX syntax everywhere else. I started trying to
reproduce the same result by editing
~/Library/TeXworks/configureation/syntax-patterns.txt , the trick is to
write a regex that only matches strings that are enclosed by <<may contain
random text>>=  and @. To start with, I thought I would just try to
highlight the code chunk options-- the random text enclosed by << and >>=.

I have tried setting the following rule in syntax-patterns.txt:


purple N <<(.*?)>>=

But no dice. I am definitely no regex journeyman, I've studied the subject
several times and have always ended up with a glazed-over feeling. However,
I have had success using m/<<(.*?)>>=/ to produce the desired results in

Is what I am seeking to do possible? Am I blatantly abusing regexes in any

Thanks for any insights!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texworks/attachments/20091022/27cf043b/attachment.html>

More information about the texworks mailing list