Skip to content

Commit

Permalink
MarkdownCommonElements must now start with a whitespace or a string t…
Browse files Browse the repository at this point in the history
…o avoid changing URLs
  • Loading branch information
ivanbruel committed Aug 1, 2016
1 parent 4ff46e3 commit 94f0767
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion MarkdownKit/Classes/Elements/MarkdownBold.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

public class MarkdownBold: MarkdownCommonElement {

private static let regex = "(\\*\\*|__)(.+?)(\\1)"
private static let regex = "(\\s+|^)(\\*\\*|__)(.+?)(\\2)"

public var font: UIFont?
public var color: UIColor?
Expand Down
4 changes: 2 additions & 2 deletions MarkdownKit/Classes/Elements/MarkdownCode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import UIKit

public class MarkdownCode: MarkdownCommonElement {

private static let regex = "(`+)(\\s*.*?[^`]\\s*)(\\1)(?!`)"
private static let regex = "(\\s+|^)(`+)(\\s*.*?[^`]\\s*)(\\1)(?!`)"

public var font: UIFont?
public var color: UIColor?

Expand Down
2 changes: 1 addition & 1 deletion MarkdownKit/Classes/Elements/MarkdownItalic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

public class MarkdownItalic: MarkdownCommonElement {

private static let regex = "(\\*|_)(.+?)(\\1)"
private static let regex = "(\\s+|^)(\\*|_)(.+?)(\\2)"

public var font: UIFont?
public var color: UIColor?
Expand Down
6 changes: 3 additions & 3 deletions MarkdownKit/Classes/Protocols/MarkdownCommonElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public extension MarkdownCommonElement {

func match(match: NSTextCheckingResult, attributedString: NSMutableAttributedString) {
// deleting trailing markdown
attributedString.deleteCharactersInRange(match.rangeAtIndex(3))
attributedString.deleteCharactersInRange(match.rangeAtIndex(4))
// formatting string (may alter the length)
addAttributes(attributedString, range: match.rangeAtIndex(2))
addAttributes(attributedString, range: match.rangeAtIndex(3))
// deleting leading markdown
attributedString.deleteCharactersInRange(match.rangeAtIndex(1))
attributedString.deleteCharactersInRange(match.rangeAtIndex(2))
}
}

0 comments on commit 94f0767

Please sign in to comment.