Last active
December 16, 2015 09:49
-
-
Save mps/5415670 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSMutableDictionary* attributes = [[NSMutableDictionary alloc]init]; | |
// p | |
UIFont *paragraphFont = [UIFont fontWithName:@"Helvetica" size:12.0]; | |
NSMutableParagraphStyle* pParagraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
pParagraphStyle.paragraphSpacing = 12; | |
pParagraphStyle.paragraphSpacingBefore = 12; | |
NSDictionary *pAttributes = @{ NSFontAttributeName : paragraphFont, NSParagraphStyleAttributeName : pParagraphStyle }; | |
[attributes setObject:pAttributes forKey:@(PARA)]; | |
// h1 | |
UIFont *h1Font = [UIFont fontWithName:@"Helvetica-Bold" size:28.0]; | |
UIColor *h12color = [UIColor colorWithHexString:@"#000000"]; | |
[attributes setObject:@{NSFontAttributeName : h1Font, NSForegroundColorAttributeName : h12color} forKey:@(H1)]; | |
// h2 | |
UIFont *h2Font = [UIFont fontWithName:@"Helvetica-Bold" size:24.0]; | |
[attributes setObject:@{NSFontAttributeName : h2Font, NSForegroundColorAttributeName : h12color} forKey:@(H2)]; | |
// h3 | |
UIFont *h3Font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0]; | |
UIColor *h345Color = [UIColor colorWithHexString:@"#333333"]; | |
[attributes setObject:@{NSFontAttributeName : h3Font, NSForegroundColorAttributeName : h345Color} forKey:@(H3)]; | |
// h4 | |
UIFont *h4Font = [UIFont fontWithName:@"Helvetica-Bold" size:16.0]; | |
[attributes setObject:@{NSFontAttributeName : h4Font, NSForegroundColorAttributeName : h345Color} forKey:@(H4)]; | |
// h5 | |
UIFont *h5Font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0]; | |
[attributes setObject:@{NSFontAttributeName : h5Font, NSForegroundColorAttributeName : h345Color} forKey:@(H5)]; | |
// h6 | |
UIFont *h6Font = [UIFont fontWithName:@"Helvetica-Bold" size:14.0]; | |
UIColor *h6Color = [UIColor colorWithHexString:@"#777777"]; | |
[attributes setObject:@{NSFontAttributeName : h6Font, NSForegroundColorAttributeName : h6Color} forKey:@(H6)]; | |
// em | |
UIFont *emFont = [UIFont fontWithName:@"Helvetica-Oblique" size:15.0]; | |
[attributes setObject:@{NSFontAttributeName : emFont} forKey:@(EMPH)]; | |
// strong | |
UIFont *strongFont = [UIFont fontWithName:@"Helvetica-Bold" size:15.0]; | |
[attributes setObject:@{NSFontAttributeName : strongFont} forKey:@(STRONG)]; | |
// ul | |
NSMutableParagraphStyle* listParagraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
listParagraphStyle.headIndent = 12.0; | |
[attributes setObject:@{NSFontAttributeName : paragraphFont, NSParagraphStyleAttributeName : listParagraphStyle} forKey:@(BULLETLIST)]; | |
// li | |
NSMutableParagraphStyle* listItemParagraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
listItemParagraphStyle.headIndent = 12.0; | |
[attributes setObject:@{NSFontAttributeName : paragraphFont, NSParagraphStyleAttributeName : listItemParagraphStyle} forKey:@(LISTITEM)]; | |
// a | |
UIColor *linkColor = [UIColor blueColor]; | |
[attributes setObject:@{NSForegroundColorAttributeName : linkColor} forKey:@(LINK)]; | |
// blockquote | |
NSMutableParagraphStyle* blockquoteParagraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
blockquoteParagraphStyle.headIndent = 12.0; | |
blockquoteParagraphStyle.tailIndent = 12.0; | |
blockquoteParagraphStyle.firstLineHeadIndent = 12.0; | |
[attributes setObject:@{NSFontAttributeName : [emFont fontWithSize:12.0], NSParagraphStyleAttributeName : blockquoteParagraphStyle} forKey:@(BLOCKQUOTE)]; | |
// verbatim (code) | |
NSMutableParagraphStyle* verbatimParagraphStyle = [[NSMutableParagraphStyle alloc]init]; | |
verbatimParagraphStyle.headIndent = 12.0; | |
verbatimParagraphStyle.firstLineHeadIndent = 12.0; | |
UIFont *verbatimFont = [UIFont fontWithName:@"Helvetica" size:12.0]; | |
[attributes setObject:@{NSFontAttributeName : verbatimFont, NSParagraphStyleAttributeName : verbatimParagraphStyle} forKey:@(VERBATIM)]; | |
NSString *randomText = @"@"<[email protected]>""; // insert failing text here. | |
// Error occurs in the next line. | |
NSMutableAttributedString* attr_out = markdown_to_attr_string(inputText,0,attributes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment