|
@@ -139,7 +139,10 @@ If that is not set, then the system default will be used.
|
|
|
public var paragraphSpacing : CGFloat = 0.0
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+@objc open class LinkStyles : BasicStyles {
|
|
|
+ public var underlineStyle: NSUnderlineStyle = .single
|
|
|
+ public lazy var underlineColor: UIColor = self.color
|
|
|
+}
|
|
|
|
|
|
/// A class that takes a [Markdown](https://daringfireball.net/projects/markdown/) string or file and returns an NSAttributedString with the applied styles. Supports Dynamic Type.
|
|
|
@objc open class SwiftyMarkdown: NSObject {
|
|
@@ -226,7 +229,7 @@ If that is not set, then the system default will be used.
|
|
|
open var blockquotes = LineStyles()
|
|
|
|
|
|
/// The styles to apply to any links found in the Markdown
|
|
|
- open var link = BasicStyles()
|
|
|
+ open var link = LinkStyles()
|
|
|
|
|
|
/// The styles to apply to any bold text found in the Markdown
|
|
|
open var bold = BasicStyles()
|
|
@@ -562,15 +565,16 @@ extension SwiftyMarkdown {
|
|
|
attributes[.foregroundColor] = self.bold.color
|
|
|
}
|
|
|
|
|
|
- if let linkIdx = styles.firstIndex(of: .link), linkIdx < token.metadataStrings.count {
|
|
|
- attributes[.foregroundColor] = self.link.color
|
|
|
- attributes[.font] = self.font(for: line, characterOverride: .link)
|
|
|
- attributes[.link] = token.metadataStrings[linkIdx] as AnyObject
|
|
|
-
|
|
|
- if underlineLinks {
|
|
|
- attributes[.underlineStyle] = NSUnderlineStyle.single.rawValue as AnyObject
|
|
|
- }
|
|
|
- }
|
|
|
+ if let linkIdx = styles.firstIndex(of: .link), linkIdx < token.metadataStrings.count {
|
|
|
+ attributes[.foregroundColor] = self.link.color
|
|
|
+ attributes[.font] = self.font(for: line, characterOverride: .link)
|
|
|
+ attributes[.link] = token.metadataStrings[linkIdx] as AnyObject
|
|
|
+
|
|
|
+ if underlineLinks {
|
|
|
+ attributes[.underlineStyle] = self.link.underlineStyle.rawValue as AnyObject
|
|
|
+ attributes[.underlineColor] = self.link.underlineColor
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if styles.contains(.strikethrough) {
|
|
|
attributes[.font] = self.font(for: line, characterOverride: .strikethrough)
|