We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For this i have created a custom class by conforming to protocol MarkDownCommonElement, the match method is not being called at all.
class MarkdownCustomStrikethrough: MarkdownCommonElement { fileprivate static let regex = "(?<=\S)(~~)(?=\S)(.+?)(?<=\S)(\1)"
open var font: MarkdownFont? open var color: MarkdownColor? public var attributes: [NSAttributedString.Key: AnyObject] = [.strikethroughStyle: NSNumber(value: NSUnderlineStyle.single.rawValue)] open var regex: String { return MarkdownCustomStrikethrough.regex } public init(font: MarkdownFont? = nil, color: MarkdownColor? = nil) { self.font = font self.color = color print("MarkdownCustomStrikethrough init called") } func regularExpression() throws -> NSRegularExpression { print("MarkdownCustomStrikethrough regularExpression called") return try NSRegularExpression(pattern: regex, options: []) } func addAttributes(_ attributedString: NSMutableAttributedString, range: NSRange) { attributedString.addAttributes(attributes, range: range) if let font = font { attributedString.addAttribute(.font, value: font, range: range) } if let color = color { attributedString.addAttribute(.foregroundColor, value: color, range: range) } } func match(_ match: NSTextCheckingResult, attributedString: NSMutableAttributedString) { // deleting trailing markdown attributedString.deleteCharacters(in: match.range(at: 4)) // formatting string (may alter the length) addAttributes(attributedString, range: match.range(at: 3)) // deleting leading markdown attributedString.deleteCharacters(in: match.range(at: 2)) }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
For this i have created a custom class by conforming to protocol MarkDownCommonElement, the match method is not being called at all.
class MarkdownCustomStrikethrough: MarkdownCommonElement {
fileprivate static let regex = "(?<=\S)(~~)(?=\S)(.+?)(?<=\S)(\1)"
}
The text was updated successfully, but these errors were encountered: