Skip to content

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

Closed

Description

@dsherret

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.

Activity

  1. marcusklaas commented on Feb 15, 2020

    @marcusklaas
    Collaborator

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

  2. self-assigned this
    on Feb 15, 2020
  3. dsherret commented on Feb 15, 2020

    @dsherret
    Author

    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
    
  4. alerque commented on May 20, 2020

    @alerque
    Contributor

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

  5. dsherret commented on Jun 29, 2020

    @dsherret
    Author

    @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!

  6. marcusklaas commented on Jul 2, 2020

    @marcusklaas
    Collaborator

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

  7. marcusklaas commented on Jul 2, 2020

    @marcusklaas
    Collaborator

    It was released!

  8. dsherret commented on Jul 2, 2020

    @dsherret
    Author

    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions