Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5 from ashfurrow/master
Browse files Browse the repository at this point in the history
Adds option to parse links.
  • Loading branch information
pietbrauer committed Feb 18, 2015
2 parents e5c835f + a8192cb commit 6b8def6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/XNGMarkdownParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef NS_ENUM (NSUInteger, XNGMarkdownParserHeader) {
@property (nonatomic, copy) NSString *boldItalicFontName; // Default: Helvetica-BoldOblique
@property (nonatomic, copy) NSString *codeFontName; // Default: Courier
@property (nonatomic, copy) NSString *linkFontName; // Default: paragraphFont
@property (nonatomic, assign) BOOL shouldParseLinks; // Default: YES

// common attributes that affect the whole string, can be overriden by the upper attributes
@property (nonatomic, strong) NSDictionary *topAttributes; // default: nil (do nothing)
Expand Down
4 changes: 3 additions & 1 deletion src/XNGMarkdownParser.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ - (id)init {
self.codeFontName = @"Courier";
self.linkFontName = self.paragraphFont.fontName;
self.topAttributes = nil;
self.shouldParseLinks = YES;

XNGMarkdownParserHeader header = XNGMarkdownParserHeader1;
for (CGFloat headerFontSize = 24; headerFontSize >= 14; headerFontSize -= 2, header++) {
Expand All @@ -74,6 +75,7 @@ - (id)copyWithZone:(NSZone *)zone {
parser.codeFontName = self.codeFontName;
parser.linkFontName = self.linkFontName;
parser.topAttributes = self.topAttributes;
parser.shouldParseLinks = self.shouldParseLinks;

for (XNGMarkdownParserHeader header = XNGMarkdownParserHeader1; header <= XNGMarkdownParserHeader6; ++header) {
[parser setFont:[self fontForHeader:header] forHeader:header];
Expand Down Expand Up @@ -128,7 +130,7 @@ - (NSAttributedString *)attributedStringFromMarkdownString:(NSString *)string {
const BOOL shouldAddLinks = (NSLinkAttributeName != nil);
#endif

if (shouldAddLinks) {
if (self.shouldParseLinks && shouldAddLinks) {
[self addLinksToAttributedString];
}

Expand Down

0 comments on commit 6b8def6

Please sign in to comment.