Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source maps #29

Open
jgm opened this issue Apr 24, 2015 · 2 comments
Open

Source maps #29

jgm opened this issue Apr 24, 2015 · 2 comments

Comments

@jgm
Copy link
Member

jgm commented Apr 24, 2015

See commonmark/commonmark-spec#57, especially @zdne's comment.

Instead of starting and ending line and column for each element, we need to associate each element with a possibly non-contiguous range of positions in the source.

This is because CommonMark inline elements can be broken by indicators of block structure:

> *emphasized
> text*

Here the second > should not be considered part of the emphasized text, even though it occurs after the start of the emphasized text and before the end.

@jgm
Copy link
Member Author

jgm commented Apr 24, 2015

Note that this common format for source maps isn't useful for us here, because it correlates a textual original source with a textual generated source. We need to correlate positions in the original textual source with elements in the AST.

Something like:

sourcemap = [ [1, 3, 6], [2, 3, 5] ]

to indicate that the node occupies columns 3-6 of line 1 and columns 3-5 of line 2.

@puzrin
Copy link
Contributor

puzrin commented Apr 28, 2015

I guess, you need this package https://github.com/mozilla/source-map . It's used everywhere to build soursemap data and includes support for incremental (nested) builds with flatten at the end. Don't know about other languages.

Though, that will significantly decrease speed and will require to rewrite regex replacements because those break positions. IMHO, it's better to rewrite parser first to be modular/pluggable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants