bmoliveira / MarkdownKit

A simple and customizable Markdown Parser for Swift
MIT License
783 stars 136 forks source link

Readme is outdated #114

Open gerchicov-vg opened 3 months ago

gerchicov-vg commented 3 months ago

Just added this chunk of code and tried to run:

class MarkdownSubreddit: MarkdownLink {

  private static let regex = "(^|\\s|\\W)(/?r/(\\w+)/?)"

  override var regex: String {
    return MarkdownSubreddit.regex
  }

  override func match(match: NSTextCheckingResult,
                             attributedString: NSMutableAttributedString) {
    let subredditName = attributedString.attributedSubstringFromRange(match.rangeAtIndex(3)).string
    let linkURLString = "http://reddit.com/r/\(subredditName)"
    formatText(attributedString, range: match.range, link: linkURLString)
    addAttributes(attributedString, range: match.range, link: linkURLString)
  }

}

Errors:

Argument labels for method 'match(match:attributedString:)' do not match those of overridden method 'match(_:attributedString:)'
'attributedSubstringFromRange' has been renamed to 'attributedSubstring(from:)'
'rangeAtIndex' has been renamed to 'range(at:)'