Skip to content

Commit

Permalink
Fixed parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanheilner committed Sep 4, 2018
1 parent 09d3793 commit 05f162e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions TSMarkdownParser/TSMarkdownParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,22 @@ - (void)addEnclosedParsingWithPattern:(NSString *)pattern formattingBlock:(TSMar
NSRegularExpression *parsing = [NSRegularExpression regularExpressionWithPattern:pattern options:(NSRegularExpressionOptions)0 error:nil];
[self addParsingRuleWithRegularExpression:parsing block:^(NSTextCheckingResult *match, NSMutableAttributedString *attributedString) {
// deleting trailing markdown
[attributedString deleteCharactersInRange:[match rangeAtIndex:3]];
// formatting string (may alter the length)
formattingBlock(attributedString, [match rangeAtIndex:2]);
// deleting leading markdown
[attributedString deleteCharactersInRange:[match rangeAtIndex:1]];
NSRange match3 = [match rangeAtIndex:3];
if (match3.location != NSNotFound) {
[attributedString deleteCharactersInRange:match3];
}

NSRange match2 = [match rangeAtIndex:2];
if (match2.location != NSNotFound) {
// formatting string (may alter the length)
formattingBlock(attributedString, match2);
}

NSRange match1 = [match rangeAtIndex:1];
if (match1.location != NSNotFound) {
// deleting leading markdown
[attributedString deleteCharactersInRange:match1];
}
}];
}

Expand Down

0 comments on commit 05f162e

Please sign in to comment.