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

Adds option to parse links. #5

Merged
merged 1 commit into from
Feb 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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