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

into_offset_iter() does not give correct range for link references #430

Closed
dsherret opened this issue Feb 15, 2020 · 7 comments
Closed

into_offset_iter() does not give correct range for link references #430

dsherret opened this issue Feb 15, 2020 · 7 comments
Assignees
Labels

Comments

@dsherret
Copy link

dsherret commented Feb 15, 2020

For example, given the following markdown:

# H1
[testing](https://github.com)
[testing][Some reference]

[Some reference]: https://github.com

The events and ranges are like so:

Event: Start(Heading(1))
Range: 0..5
Event: Text(Borrowed("H1"))
Range: 2..4
Event: End(Heading(1))
Range: 0..5
Event: Start(Paragraph)
Range: 5..61
Event: Start(Link(Inline, Borrowed("https://github.com"), Borrowed("")))
Range: 5..34
Event: Text(Borrowed("testing"))
Range: 6..13
Event: End(Link(Inline, Borrowed("https://github.com"), Borrowed("")))
Range: 5..34
Event: SoftBreak
Range: 34..35
Event: Start(Link(Reference, Borrowed("https://github.com"), Borrowed("")))
Range: 35..36
Event: Text(Borrowed("testing"))
Range: 36..43
Event: End(Link(Reference, Borrowed("https://github.com"), Borrowed("")))
Range: 35..36

So for inline links it will give the full range of 5..34, which is correct. The reference link is incorrect though as it gives 35..36 instead of 35..60.

I can look into this issue. The only reason I need this though is because I am manually parsing out link reference text because it's not provided another way. Edit: Actually, I'm just going to work around this as I don't have time at the moment to fix it.

@marcusklaas
Copy link
Collaborator

Good catch, and thank you for reporting it. I shall investigate.

@marcusklaas marcusklaas self-assigned this Feb 15, 2020
@dsherret
Copy link
Author

dsherret commented Feb 15, 2020

Also, FootnoteReference does not have the full width:

Testing this[^1] out.

[^1]: Footnote.

Outputs:

Event: Start(Paragraph)
Range: 0..22
Event: Text(Borrowed("Testing this"))
Range: 0..12
Event: FootnoteReference(Borrowed("1"))
Range: 12..13                            <-- should be 12..16
Event: Text(Borrowed(" out."))
Range: 16..21
Event: End(Paragraph)
Range: 0..22
Event: Start(FootnoteDefinition(Borrowed("1")))
Range: 23..39
Event: Start(Paragraph)
Range: 29..39
Event: Text(Borrowed("Footnote."))
Range: 29..38
Event: End(Paragraph)
Range: 29..39
Event: End(FootnoteDefinition(Borrowed("1")))
Range: 23..39

@alerque
Copy link
Contributor

alerque commented May 20, 2020

This is related to #411, not only is the range misreported here, but some information is missing.

@dsherret
Copy link
Author

dsherret commented Jun 29, 2020

@marcusklaas could there be a release for this if possible? I'm trying to reliably parse out the link reference and it's hard without this. Thanks!

@marcusklaas
Copy link
Collaborator

Yes, I'll do a release containing this fix shortly. Planning one before the end of the week.

@marcusklaas
Copy link
Collaborator

It was released!

@dsherret
Copy link
Author

dsherret commented Jul 2, 2020

Thanks @marcusklaas! I just tested it out now and it's working well 🙂

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

No branches or pull requests

3 participants