Skip to content

Commit

Permalink
Implemented subscript/superscript support in htmlString.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Sep 6, 2012
1 parent ba229fe commit 29e2c6f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Core/Source/NSAttributedString+DTCoreText.m
Expand Up @@ -686,6 +686,34 @@ - (NSString *)htmlString
}
}

NSNumber *superscript = [attributes objectForKey:(id)kCTSuperscriptAttributeName];
if (superscript)
{
NSInteger style = [superscript integerValue];

switch (style)
{
case 1:
{
fontStyle = [fontStyle stringByAppendingString:@"vertical-align:super;"];
break;
}

case -1:
{
fontStyle = [fontStyle stringByAppendingString:@"vertical-align:sub;"];
break;
}

default:
{
// all other are baseline because we don't support anything else for text
fontStyle = [fontStyle stringByAppendingString:@"vertical-align:baseline;"];

break;
}
}
}

NSURL *url = [attributes objectForKey:DTLinkAttribute];

Expand Down Expand Up @@ -738,6 +766,8 @@ - (NSString *)htmlString
while ([closingStyles count]);
}

NSLog(@"%@", retString);

return retString;
}

Expand Down

0 comments on commit 29e2c6f

Please sign in to comment.