You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a bunch of links that AttributedMarkdown is to parse, such as [Github](http://github.com), is there any mechanism for linking the formatted text that just becomes "GitHub", to the URL it's linked to?
Basically, I'm building a system allowing you to tap on the formatted text to open the corresponding URL, but I'm not sure how to get this URL once the text has been formatted.
Are there any recommendations for doing so?
(Apologies if this isn't actually an "issue", so to speak.)
The text was updated successfully, but these errors were encountered:
I was having this same problem, and figured it out just now. When AttributedMarkdown parses your links, it adds a custom attribute to the attributed string with the key attributedMarkdownURL, who's corresponding value is an NSURL containing the URL for your link.
I ended up enumerating the attributes on the string after it was parsed, and replaced the attributedMarkdownURL attributes with NSLinkAttributes, so that UITextViews can appropriately handle the links.
var attributedString : NSMutableAttributedString = markdown_to_attr_string( markdown, 0, _attributes )
attributedString.enumerateAttribute( "attributedMarkdownURL", inRange: NSRange(location: 0,length: attributedString.length), options: NSAttributedStringEnumerationOptions.allZeros) { (attributeValue, range, stop) -> Void in
if attributeValue != nil {
attributedString.addAttribute( NSLinkAttributeName, value: attributeValue!, range: range )
}
}
I know this is an old question, but I hope this helps you, and anyone else with this issue!
-Andrew
If I have a bunch of links that AttributedMarkdown is to parse, such as
[Github](http://github.com)
, is there any mechanism for linking the formatted text that just becomes "GitHub", to the URL it's linked to?Basically, I'm building a system allowing you to tap on the formatted text to open the corresponding URL, but I'm not sure how to get this URL once the text has been formatted.
Are there any recommendations for doing so?
(Apologies if this isn't actually an "issue", so to speak.)
The text was updated successfully, but these errors were encountered: