Down icon indicating copy to clipboard operation
Down copied to clipboard

DownStylerConfiguration not working for link in UILabel

Open AbhijeetCherungottil opened this issue 2 years ago • 2 comments

Please help prevent duplicate issues before submitting a new one:

  • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

Report

What did you do?

  let configuration = DownStylerConfiguration()
   let fonts = StaticFontCollection(heading1: UIFont.preferredFont(forTextStyle: .largeTitle), heading2:     UIFont.preferredFont(forTextStyle: .title1), heading3: UIFont.preferredFont(forTextStyle: .title2), heading4: UIFont.preferredFont(forTextStyle: .title3), heading5: UIFont.preferredFont(forTextStyle: .headline), heading6: UIFont.preferredFont(forTextStyle: .subheadline), body: UIFont.preferredFont(forTextStyle: .body), code: UIFont.preferredFont(forTextStyle: .body), listItemPrefix: UIFont.preferredFont(forTextStyle: .body))
    let colors = StaticColorCollection(heading1:  .black, heading2: .black, heading3:  .black, heading4: .black, heading5:  .black, heading6: .black, body: .black, code: .black, link: DownColor.systemPink, quote:.darkGray, quoteStripe: .darkGray, thematicBreak: .init(white: 0.9, alpha: 1), listItemPrefix: .lightGray, codeBlockBackground: .green)
    let paragraphStyles = configuration.paragraphStyles
    let quoteStripeOptions = configuration.quoteStripeOptions
    let thematicBreakOptions = configuration.thematicBreakOptions
    let codeBlockOptions = configuration.codeBlockOptions
    let itemParagraphStyler = ListItemOptions()
  guard let markdownAttributedString = try? down.toAttributedString(.smartUnsafe, styler: DownStyler(configuration: .init(fonts: fonts, colors: colors, paragraphStyles: paragraphStyles, listItemOptions: itemParagraphStyler, quoteStripeOptions: quoteStripeOptions, thematicBreakOptions: thematicBreakOptions, codeBlockOptions: codeBlockOptions) ))else { return NSAttributedString(string: self) }
  return markdownAttributedString

What did you expect to happen?

  • Link with pink color

What happened instead?

  • Link with default tint color

AbhijeetCherungottil avatar Jun 04 '22 02:06 AbhijeetCherungottil

The same error, link shows always blue

sergeymild avatar Nov 15 '22 04:11 sergeymild

The same error, link shows always blue

I am not 100% sure, but when UILabel has an NSLink, no matter what we do, the compiler converts the link on runtime. I'm not sure if it can be fixed because it's a UILabel default behaviour.

AbhijeetCherungottil avatar Nov 15 '22 05:11 AbhijeetCherungottil