[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] ruby syntax highlighting patterns
From: |
John M. Gabriele |
Subject: |
Re: [Nano-devel] ruby syntax highlighting patterns |
Date: |
Mon, 22 May 2006 11:18:43 -0700 (PDT) |
--- David Lawrence Ramsey <address@hidden> wrote:
> John M. Gabriele wrote:
>
> <snip>
>
> > Here's some common-looking Ruby snippets which don't highlight
> > correctly with those patterns:
> >
> > title.gsub( /"/, """ )
>
> Thanks for the feedback. I've made a new version. See attached.
>
> The problem here is the unescaped quote, which is treated as part of a
> string.
Hm. I thought maybe putting the regex pattern before the string pattern (in the
.nanorc file) might fix that, but it didn't... How does nano do syntax
highlighting? Does it go line-by-line, applying each pattern on that line, one
at a time, in order? Hm.
> [snip]
>
> > return %{<a href="%s">%s</a>} % [ rval, rval.sub(/.+?:/, '') ]
>
> The problem here is the unescaped quote, which is treated as part of a
> string.
>
>
> > text += %{>#{link}</a>}
>
> The problem here is the unescaped }, which is treated as the end of the
> string as well as the end of the expression substitution.
Hm. Yeah, although the ruby syntax is technically correct, it would look neater
(to my eye anyway) if the programmer had written
text += ">#{link}</a>"
instead (which also would, incidentally, syntax highlight correctly here).
> The problems with the regexes here occur occasionally with the "nanorc"
> regex intended to highlight bad commands, and would occur with the
> "c-file" regexes if C accepted unescaped quotes inside strings.
> Unfortunately, I'm not sure how to fix them properly, but at least
> things should be better than they were.
Yes -- a number of those do look better than they were. Though, now, comments
that don't begin at column 1 aren't syntax highlighted. You might just change
color cyan "^#([^{].*)?$"
back to
color cyan "#([^{].*)?$"
and not worry for now about the case where you have a pound sign inside a
string, as with
foo = lambda {|char| "&#%03d;" % char}
(Note, here, the pound sign is not part of an expression substitution.)
---John
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com