texworks icon indicating copy to clipboard operation
texworks copied to clipboard

Limited flixibility in style definitions for syntax patterns

Open GoogleCodeExporter opened this issue 10 years ago • 3 comments

The current style definitions for syntax patterns as listed in
configurations/syntax-patterns.txt is limited to:
(1) applying regex one line at a time (like sed). Thus multi-line text
cannot be handled.
(2) usage of regex which can not handle nested delimiters. Thus if the
specified regex searches for [^}] and the _text_ itself has a closing
brace, }, then the intended style is lost.

Example:
Add the following definition in syntax-patterns.txt:
red         Y \\textcolor\s*\{red\}\s*\{[^}]*\}

Then this works as expected:
\textcolor{red}{This is in red}

But the following two don't:
(1)
\textcolor{red}{This should have been (line break here)
in red}

(2)
\textcolor{red}{This also should have been in red: $\{a,b\}$}

This issue is seen with svn r545 version of Tw on RedHat 5.4, but is
generic to any version of Tw till date and any OS.

See the entire thread initiated by this message:
http://tug.org/pipermail/texworks/2010q1/002130.html

Original issue reported on code.google.com by [email protected] on 20 Jan 2010 at 5:26

GoogleCodeExporter avatar Mar 14 '15 10:03 GoogleCodeExporter

Original comment by st.loeffler on 31 Jan 2010 at 10:08

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

GoogleCodeExporter avatar Mar 14 '15 10:03 GoogleCodeExporter

Hello,
I would like to propose extension to this and Issue 533: highlighting or 
emphasizing entire \begin{}-\end{} block, e.g.
\begin{equation}
\exp^{\imath\phi}=\cos\phi+\imath\sin\phi
\end{equation}
What I expect: the entire block would have background different from other text 
around.

Original comment by [email protected] on 21 Mar 2012 at 1:12

GoogleCodeExporter avatar Mar 14 '15 10:03 GoogleCodeExporter

(2) can actually be fixed to use
 red   Y    \\textcolor\s*\{red\}\s*\{(\\\}|[^}])*\}
instead of
red         Y \\textcolor\s*\{red\}\s*\{[^}]*\}
i.e., symbol "}" will not be treated at the end of expression only when it 
follows immediately after "\"

Original comment by [email protected] on 15 May 2012 at 4:41

GoogleCodeExporter avatar Mar 14 '15 10:03 GoogleCodeExporter