CDMarkdownKit icon indicating copy to clipboard operation
CDMarkdownKit copied to clipboard

Links not rendering

Open sj1914 opened this issue 6 years ago • 8 comments

ℹ Please fill out this template when filing an issue. All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info.

Per our *CONTRIBUTING guidelines, we use GitHub for bugs and feature requests, not general support. Other issues should be opened on Stack Overflow with the tag cdmarkdownkit.

Please remove this line and everything above it before submitting.

What did you do?

Tried to parse links

What did you expect to happen?

I expect [Link](somelink.com) to render as Link with whatever styling i set

What happened instead?

The styling is not applied. Also if the link is the only thing being parsed it is not recognised as a link as the regex expects it to be prefixed with some character.

CDMarkdownKit Environment

CDMarkdownKit version: 1.2.1 Xcode version: 10.2 Swift version: 4.2 Platform(s) running CDMarkdownKit: iOS 12.1 iPhone XS macOS version running Xcode: 10.14.3, macOS Mojave

sj1914 avatar Apr 23 '19 14:04 sj1914

If you want to set the style of a link then you have to set UITextView.linkTextAttributes by yourself. This can't be set inside the markdown rendering because the UITextView handles links in its own way.

The Documentation says:

The default attributes specify blue text with a single underline and the pointing hand cursor.

katunch avatar Jul 23 '19 13:07 katunch

Hello! The same happens using UILabel. Any idea to solve this issue? Thanks

papfonseca avatar Apr 12 '22 13:04 papfonseca

I found a solution. It appear to be an iOS bug when we use NSAttributedString.Key.link. The workaround it to change from .link to .attachment here

    func addLink(_ link: URL,
                 toRange range: NSRange) {
        self.addAttribute(NSAttributedString.Key.attachment,
                          value: link,
                          range: range)
    }

papfonseca avatar Apr 12 '22 14:04 papfonseca

Hello, i have the same bug

if my string starts from link for example [google](https://google.com) that link won't be parsed but if i put something before for example text, it will parse as expected

sergeymild avatar Nov 15 '22 06:11 sergeymild

Thank you for your comments. I will try and look into this soon.

chrisdhaan avatar Dec 04 '22 08:12 chrisdhaan

2022-12-14 в 18 50 01

CDMarkdownKit Environment

CDMarkdownKit version: 2.5.1 (from swift package) Xcode version: Version 14.1 (14B47b) Swift version: last Platform(s) running CDMarkdownKit: iOS 16.1 iPhone 14 Pro macOS version running Xcode: 13.0.1 (22A400), macOS Ventura

ZaurNNov avatar Dec 14 '22 15:12 ZaurNNov

Hello, i have the same bug

if my string starts from link for example [google](https://google.com) that link won't be parsed but if i put something before for example text, it will parse as expected

Any updates about that bug?

sergeymild avatar Jan 04 '23 11:01 sergeymild