texworks icon indicating copy to clipboard operation
texworks copied to clipboard

When I use '\verb|%|', TeXworks think left words as comments.

Open Foair opened this issue 8 years ago • 4 comments

Steps to reproduce the problem:

  1. Input these: \verb|#| \quad \verb|$| \quad \verb|%| \quad \verb|^| \quad \verb|&| \quad \verb|_| \quad \verb|{| \quad \verb|}| \quad \verb|~| \quad \verb|\|
  2. %| \quad \verb|^| \quad \verb|&| \quad \verb|_| \quad \verb|{| \quad \verb|}| \quad \verb|~| \quad \verb|\| gets red.

Expected output: | \quad \verb|^| \quad \verb|&| \quad \verb|_| \quad \verb|{| \quad \verb|}| \quad \verb|~| \quad \verb|\| should be looked like normal, not in red color.

Actual output: | \quad \verb|^| \quad \verb|&| \quad \verb|_| \quad \verb|{| \quad \verb|}| \quad \verb|~| \quad \verb|\| dispalys as comment's style.

TeXworks version: 0.6.1 TeXworks obtained from: TeX Live 2016 Operating system: Windows 10

Please provide any additional information below: I think TeXworks think % as a symbol of comments, although I used \verb. English is not well, sorry.

Foair avatar Feb 17 '17 02:02 Foair

You'll see I've made a proposal here: it's not 100% ideal but does more-or-less work. The regex engine we have available doesn't support \K or backrefs (that I can find), which means we can't colour just part of a string ...

josephwright avatar Aug 20 '17 16:08 josephwright

BTW, https://www.debuggex.com/r/fhyAZ-TY---MZj2w shows what I mean

josephwright avatar Aug 20 '17 17:08 josephwright

The regex suffers from the fact that we can't do lazy matching, so two \verb in the same line will end up 'cross-contaminating'. Also see the awkwardness supporting \verb*.

josephwright avatar Aug 20 '17 17:08 josephwright

Probably the 'ideal' with a PCRE would be \\verb\*?\K([^A-Za-z@])(?:.+?)\1 or \\verb\*?\K([^A-Za-z@])[^\1]+?\1 (both give the same result): https://www.debuggex.com/r/Jm36-6Xs44sNfm_G.

josephwright avatar Aug 20 '17 17:08 josephwright