Closed TomKremer closed 5 years ago
Yes, it would be great if a href
links would be converted to NSAttributedString.Key.link
. Then I could use the attributed string output in a standard UITextView, too.
@futuretap You can use tuner for this use case
let a = Style("a")
let test = "<a href=\"https://github.com/psharanda/Atributika\">link</a>".style(tags: a, tuner: { style, tag in
if tag.name == a.name {
if let link = tag.attributes["href"] {
return style.link(URL(string: link)!)
}
}
return style
}).attributedString
@TomKremer Unfortunately your use case is out of scope, because Atributika is designed to know nothing about tags meaning.
I would suggest to just hardcode required logic in your app. In click handler of AttributedLabel you get detection, then check if it is overlapped with detection with higher priority and handle it in case of that (so prefer href detection over hashtag one)
Many thanks for your feedback, will try your suggestion!
Came across this issue having implemented my own tuner for transforming href
into link
style.
Does seem strange to me this isn't implicit.
Use case is for handling NSAttributedString.Key.link
in a UITextView
without using AttributedLabel
.
Do wonder if it might be worth including an example tuner in README.
Hello,
first let me thank you for your amazing work! It's saving me a ton of work!
I got an issue with hashtag detection type with the following use-case:
<a href="somedomain.tld/path/etc">#NoTwitterHashtag</a>
Your code detects a hashtag, which works fine but I think if a href is available, it should be considered as a normal link type?
Best, Tom.