swiftlang/swift-markdown

Link titles not supported?

Closed this issue · 4 comments

Example 481 of the commonmark spec shows the use of a title in a link:

[link](/uri "title")

however I don't see the title property in the Link documentation

When I test, it seems as though the title is discarded:

let document = Document(parsing: "[link](/uri \"title\")")
print(document.debugDescription())

Outputs:

Document
└─ Paragraph
   └─ Link destination: "/uri"
      └─ Text "link"

Title is supported for Images:

let document2 = Document(parsing: "![foo](/url \"title\")")
print(document2.debugDescription())

Outputs the title:

Document
└─ Paragraph
   └─ Image source: "/url" title: "title"
      └─ Text "foo"

Is this a version thing?

Thanks,
Damian

I think this is a bug in swift-markdown. It looks like it doesn't read the link title from cmark:

https://github.com/apple/swift-markdown/blob/87c9e60b73174643f1f0bdfd81d41ce379defde0/Sources/Markdown/Parser/CommonMarkConverter.swift#L445-L454

There are a couple other places where this happens (table column alignments and ordered-list starting indices, for example), so this is probably an oversight from the original implementation.

jurex commented

hey guys, any progress with this issue? Would love to see it fixed. Thanks!

hey guys, any progress with this issue? Would love to see it fixed. Thanks!

I've opened a potential fix for it. If someone can help review it, it can be merged into main soon and might be cherry-picked to land on release/5.9.

Hello @DamianMehers, this feature is merged into main today. You may have a try on it and any feedback is greatly appreciated. I believe we can have it landed on the release of Swift 5.10.