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

sourcepos not correct #3

Closed
zjuasmn opened this issue Jan 26, 2015 · 1 comment
Closed

sourcepos not correct #3

zjuasmn opened this issue Jan 26, 2015 · 1 comment

Comments

@zjuasmn
Copy link

zjuasmn commented Jan 26, 2015

sourcepos attribute in AST is not correct when parser run for more than 1 time:

     var reader = new commonmark.Parser();
     var writer = new commonmark.HtmlRenderer({sourcepos:true});
     console.log(writer.render(reader.parse("Hello *world*")));
     console.log(writer.render(reader.parse("Hello *world*")));

Now the result is

    <p data-sourcepos="1:1-1:13">Hello <em>world</em></p>
    <p data-sourcepos="2:1-1:13">Hello <em>world</em></p>

And I wonder why should the sourcepos be 1-based instead of 0-based?

@jgm jgm closed this as completed in 33dbd5a Jan 26, 2015
@jgm
Copy link
Member

jgm commented Jan 26, 2015

Thanks for the report. I believe this is now fixed.

BTW, should the sourcepos be 1-based instead of 0-based?

The current code thinks of the left-most column as 1 and the
first line as 1. This is fairly intuitive, I think. My
text editor counts lines and columns the same way. I'd
consider an argument for another approach, though.

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