nevir/groc — pull request #104 by sjorek (2013-08-28 10:43:11+00:00)
Title: Fix: faulty detection of email-adresses as doctags

In preparation of multi-line block-comments support for CoffeScripts I discovered that sometimes email-adresses are treated as *@doctags*, because the related regular-expression `TAG_REGEX = /@(\w+)(?:\s+(.*))?/` in *lib/utils.coffee* simply matches the *@domain.tld*-part of email-adresses.

My (dumb) solution to this problem modifies the regular-expression (and it's match-result usage), so it cares about the @-preceding character:

# @ preceded by the start of line or a space-character and followed by word characters …
TAG_REGEX = /(^|\s)@(\w+)(?:\s+(.*))?/

Hence I make the assumption, that *@doctags* are always preceded by space or placed at the beginning of line.

Alternatively we could assume that *@doctags* never contain a dot and modify the regular expression accordingly:

# @ followed by at least one word character, which in turn is not followed by a dot plus word-characters.
TAG_REGEX = /@(\w++(?!\.\w))(?:\s+(.*))?/

The latter solution is untested and just a source of inspiration. I'd prefer the first one (= this patch) and appreciate any feedback.

Cheers,
Stephan