No easy access to label for links that use reference links #411

Open
opened 2026-01-29 14:36:05 +00:00 by claunia · 2 comments
Owner

Originally created by @ErikSchierboom on GitHub (Nov 1, 2020).

When working with inline links, the behavior of the LabelSpan property seems to be inconsistent between inline links that use reference links and those that do not.

This is best demonstrated with an example.

Suppose we're parsing the following Markdown

[Link using reference][valid-file]
[Link without reference](/valid-file-link.md)

[valid-file]: ./valid-file-link.md

using the following code:

var pipeline = MarkdownPipelineBuilder().UsePreciseSourceLocation().Build();
var markdownDocument = Markdown.Parse(markdown, pipeline);

Then if I use the Span, LabelSpan and UrlSpan properties to output the corresponding Markdown in the document, I get the following:

First link (using the reference link):

  • Span: "[Link using reference][valid-file]"
  • LabelSpan: "valid-file"
  • UrlSpan: "./valid-file-link.md"

Second link (not using the reference link):

  • Span: "[Link without reference](/valid-file-link.md)"
  • LabelSpan: "Link without reference"
  • UrlSpan: "/valid-file-link.md"

I would have expected the LabelSpan property of the first link to return Link using reference, not valid-file.

Am I doing something wrong or is this expected behavior?

Originally created by @ErikSchierboom on GitHub (Nov 1, 2020). When working with inline links, the behavior of the `LabelSpan` property seems to be inconsistent between inline links that use reference links and those that do not. This is best demonstrated with an example. Suppose we're parsing the following Markdown ```markdown [Link using reference][valid-file] [Link without reference](/valid-file-link.md) [valid-file]: ./valid-file-link.md ``` using the following code: ```csharp var pipeline = MarkdownPipelineBuilder().UsePreciseSourceLocation().Build(); var markdownDocument = Markdown.Parse(markdown, pipeline); ``` Then if I use the Span, LabelSpan and UrlSpan properties to output the corresponding Markdown in the document, I get the following: First link (using the reference link): - Span: `"[Link using reference][valid-file]"` - LabelSpan: `"valid-file"` - UrlSpan: `"./valid-file-link.md"` Second link (not using the reference link): - Span: `"[Link without reference](/valid-file-link.md)"` - LabelSpan: `"Link without reference"` - UrlSpan: `"/valid-file-link.md"` I would have expected the `LabelSpan` property of the first link to return `Link using reference`, not `valid-file`. Am I doing something wrong or is this expected behavior?
claunia added the bugPR Welcome! labels 2026-01-29 14:36:05 +00:00
Author
Owner

@MihaZupan commented on GitHub (Nov 1, 2020):

The behavior looks wrong here. We're also not setting the Label for [foo](bar) case.

@MihaZupan commented on GitHub (Nov 1, 2020): The behavior looks wrong here. We're also not setting the `Label` for `[foo](bar)` case.
Author
Owner

@ErikSchierboom commented on GitHub (Nov 9, 2020):

@MihaZupan I've opened PR #488 to fix this issue. Is there anything I should be doing to get the PR reviewed?

@ErikSchierboom commented on GitHub (Nov 9, 2020): @MihaZupan I've opened PR #488 to fix this issue. Is there anything I should be doing to get the PR reviewed?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#411