LeaVerou/prism — pull request #329 by zeitgeist87 (2014-08-12 16:51:06+00:00)
Title: Add support for lookahead

Hi,

I hate to bother you with yet another probably not so well though out feature request of mine, but I think this one could be really really useful. I just got the idea this afternoon and I just hat to try to implement it right away ;)

This patch adds support for the `lookahead` flag, which works exactly
like `lookbehind` only from the other side. When set to `true`, the last
capturing group in the regex pattern is discarded when matching this
token.

This feature can be extremely useful when matching encloseing tags like
script or style tags. Currently one has to work around the lack of a
`lookahead` flag, by using the `inside` option and repeating everything
from the layer above.

Using `lookahead` is much more natural and readable for example:

```js
if (Prism.languages.markup) {
Prism.languages.insertBefore('markup', 'tag', {
'script': {
pattern: /(<\/script>)/ig,
lookbehind: true,
lookahead: true,
inside: Prism.languages.javascript
}
});
}
```

There are lots of other places where this could be useful:

```js
'function': {
pattern: /[a-z0-9_]+(\()/ig,
lookahead: true
},
```