Hello Everyone,<div><br></div><div>I&#39;ve been playing around a little with custom syntax highlighting rules in TeXworks using r482 on OS X 10.6. I&#39;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.</div>
<div><br></div><div>The problem I&#39;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 &lt;&lt;may contain random text&gt;&gt;=  and @. To start with, I thought I would just try to highlight the code chunk options-- the random text enclosed by &lt;&lt; and &gt;&gt;=.</div>
<div><br></div><div>I have tried setting the following rule in syntax-patterns.txt:</div><div><br></div><div>[Sweave]</div><div><br></div><div>purple N &lt;&lt;(.*?)&gt;&gt;=</div><div><br></div><div><br></div><div>But no dice. I am definitely no regex journeyman, I&#39;ve studied the subject several times and have always ended up with a glazed-over feeling. However, I have had success using m/&lt;&lt;(.*?)&gt;&gt;=/ to produce the desired results in Perl. </div>
<div><br></div><div>Is what I am seeking to do possible? Am I blatantly abusing regexes in any way?</div><div><br></div><div>Thanks for any insights!</div><div><br></div><div>-Charlie</div>