On Mon, 8 Jun 2009 08:17:27 -0700 (PDT) Ben Fritz <"fritzophre...@gmail.com"@MISSING_DOMAIN> wrote:
BF> On Jun 5, 5:36 pm, Vadim Zeitlin <vz-...@zeitlins.org> wrote:
BF> > Hello,
BF> >
BF> > I'm trying to enable spell checking for the contents of some tags in a
BF> > (custom dialect of) XML, e.g. I have something like this:
BF> >
BF> > <?xml version="1.0"?>
BF> > <foo>
BF> > <bar>notatext</bar>
BF> > <text>Some text I'd like to spell check</text>
BF> > </foo>
BF> >
BF> > and would like spelling mistakes be highlighted inside <text> but not
BF> > inside <bar> (and not anywhere else, so e.g. "syn spell toplevel" is not a
BF> > solution).
...
BF> But, I suspect this will work better with the syntax pattern offsets
BF> rather than the regex patterns for doing the same.
Hello and thanks for your answer!
I knew I forgot something in my original message: I did try the offsets
approach too but without frank success. First of all, I thought that I
needed to use region start/end (rs/re), i.e. do this:
syn region xmlString start="<text>"rs=s+6 end="</text>"re=e-7 \
contains=xmlEntity,@Spell
But it didn't work at all and the entire line containing <text> was
highlighted as string. So I read the documentation more carefully and
discovered the part between the parentheses:
This can be used to change the highlighted part, and to change the
text area included in the match or region (which only matters when
trying to match other items)
So I tried the same thing with hs/he. This does highlight the string itself
properly but it removes highlight from <text> tag and matching closing tag
entirely which looks a bit ugly.
Remembering the "matters when trying to match other items" part I tried
with both hs and rs but this didn't change anything compared to just using
hs, i.e. <text> is still not matched as xmlTagName any more. Just to be
complete, I've also tried using svn match but this behaves in the same way:
I can make highlighting the tag contents work but at the expense of
correctly highlighting the tag itself. And combining ms and hs still
doesn't do anything differently from just using hs AFAICS.
So I'm still stuck with
(a) Perfect but extremely slow solution using just zero width matches
(b) Good in practice but rather ugly and still very slow solution using
zero-width match followed by a capital letter
(c) Simple but not good looking solution using pattern offsets
And the most annoying thing remains that "\zs" seems to exist to do exactly
what I want -- but doesn't work for some reason. And it's not due to using
zero width for both start and end as it still doesn't work if you do
something like
syn region xmlString start="<text>\zsSome" end="check\ze</text>"
neither (with the example above). But as soon as you remove \zs it starts
working (\ze does work as expected).
Would anybody have any idea about why is it so?
Thanks again,
VZ
|
|
application_pgp-signature_part
< 1K
Download
|