"Label" property of LinkInline never used? #143

Closed
opened 2026-01-29 14:28:36 +00:00 by claunia · 4 comments
Owner

Originally created by @GordonApplepie on GitHub (Oct 17, 2017).

I am trying to add some extension to the link label to force some alterations.

for example:
Download me for [example:Android](http://google.com)

These things I would expect:

  1. "Label" property would be set
  2. An alteration of the "Label" property would change the outcome {altered_label}

But none of this is happening.

Originally created by @GordonApplepie on GitHub (Oct 17, 2017). I am trying to add some extension to the link label to force some alterations. for example: `Download me for [example:Android](http://google.com)` These things I would expect: 1. "Label" property would be set 2. An alteration of the "Label" property would change the outcome <a>{altered_label}</a> But none of this is happening.
claunia added the question label 2026-01-29 14:28:36 +00:00
Author
Owner

@xoofx commented on GitHub (Oct 17, 2017):

Yeah, it is probably confusing I agree, but it comes actually from the markdown specs (but the C# doc should better explain this, indeed). If you look at the specs for links, there are two kinds of links:

  • inline links: The one you posted above ([example:Android](http://google.com))
  • reference links: A link that reference a link definition elsewhere in the document

The label is an information only valid for reference links. Typically in the following reference link example:

[Test][my_label]

[my_label]: http://github.com

Here the label will be my_label.

For the inline link [example:Android](http://google.com), the information example:Android is called the link text in the specs and it will be stored as a child of the LinkInline element. Why? Because you can have formatting inside this text (like emphasis, code...etc.), so you don't get just a text node but you could have also formatting elements there.

In the LinkInlineRenderer, you can verify here that the content of the link (its text) is rendered using the children.

Hope it makes sense.

@xoofx commented on GitHub (Oct 17, 2017): Yeah, it is probably confusing I agree, but it comes actually from the markdown specs (but the C# doc should better explain this, indeed). If you look at the [specs for links](http://spec.commonmark.org/0.28/#links), there are two kinds of links: - inline links: The one you posted above (`[example:Android](http://google.com)`) - reference links: A link that reference a link definition elsewhere in the document The label is an information only valid for reference links. Typically in the following reference link example: ```md [Test][my_label] [my_label]: http://github.com ``` Here the label will be `my_label`. For the inline link `[example:Android](http://google.com)`, the information `example:Android` is called the `link text` in the specs and it will be stored as a child of the `LinkInline` element. Why? Because you can have formatting inside this text (like emphasis, code...etc.), so you don't get just a text node but you could have also formatting elements there. In the LinkInlineRenderer, you can verify [here](https://github.com/lunet-io/markdig/blob/7bd00d115f82c86be6ab2295fb79df5c9f500939/src/Markdig/Renderers/Html/Inlines/LinkInlineRenderer.cs#L68) that the content of the link (its text) is rendered using the children. Hope it makes sense.
Author
Owner

@GordonApplepie commented on GitHub (Oct 17, 2017):

Since there is an LinkReferenceDefinition class the class property "Label" is not really used, is it?
We already suspected that this is due to the fact that there could be other markup in the link.

@GordonApplepie commented on GitHub (Oct 17, 2017): Since there is an LinkReferenceDefinition class the class property "Label" is not really used, is it? We already suspected that this is due to the fact that there could be other markup in the link.
Author
Owner

@xoofx commented on GitHub (Oct 17, 2017):

Since there is an LinkReferenceDefinition class the class property "Label" is not really used, is it?

In the example I gave above, the Label should have the "my_label" string and the Reference (LinkReferenceDefinition) set. It is indeed a duplicate of what you could get from Reference, but the LabelSpan is on the contrary link side (and not definition side).

@xoofx commented on GitHub (Oct 17, 2017): > Since there is an LinkReferenceDefinition class the class property "Label" is not really used, is it? In the example I gave above, the Label should have the "my_label" string and the Reference (LinkReferenceDefinition) set. It is indeed a duplicate of what you could get from Reference, but the `LabelSpan` is on the contrary link side (and not definition side).
Author
Owner

@GordonApplepie commented on GitHub (Oct 17, 2017):

understand, thx

@GordonApplepie commented on GitHub (Oct 17, 2017): understand, thx
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#143