ractivejs/ractive — pull request #1276 by Rich-Harris (2014-09-28 20:57:08+00:00)
Title: include character position alongside line/column when parsing with includeLinePositions

Am trying to wrap my head around sourcemaps today, for various reasons. (If anyone else out there besides me is totally flummoxed by the whole business, I've tried to explain the `mappings` property of a sourcemap JSON object in human-speak [here](https://github.com/Rich-Harris/vlq/tree/master/sourcemaps), along with [vlq.js](https://github.com/Rich-Harris/vlq), a utility for encoding/decoding the VLQs that `mappings` is composed of. Hopefully it will save someone else from experiencing the same overwhelming confusion that I did).

Anyway, I'm currently trying to get sourcemaps working with Ractive components, and I've discovered that storing the character position of each token while parsing (in addition to line/column number) is useful for that purpose:

```js
Ractive.parse( '

Hello world!

', { includeLinePositions: true });
// {v:1,t:[{t:7,e:'h1',f:['Hello world!'],p:[1,1,0]}]}
```

Note the `p:[1,1,0]` - that means line 1, column 1, character 0. Lines and column numbers are still one-based, because that's what you typically want when debugging, but the character index is zero-based, because that's what you want if you're slicing up the original string template. Previously it would have just been `p:[1,1]`.

Hopefully this is non-controversial - it shouldn't break anything for anyone, but just in case, does anyone have any objections to merging this in?