Created
March 15, 2016 14:12
-
-
Save karlwhite/d5d7b70bd8676edb01c0 to your computer and use it in GitHub Desktop.
This file contains 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
// Fix table-cells | |
NSArray *cells = [document nodesMatchingSelector:@"td"]; | |
for (HTMLElement *cell in cells) { | |
NSString *align = [[cell attributes] objectForKey:@"align"]; | |
// Replace center aligned cells with a centered span | |
if ( align && [align isEqualToString:@"center"] ) { | |
NSString *newContent = [[cell serializedFragment] stringByReplacingOccurrencesOfString:[cell innerHTML] withString:[NSString stringWithFormat:@"<span style=\"text-align:center\">%@</span>", [cell innerHTML]]]; | |
htmlString = [htmlString stringByReplacingOccurrencesOfString:[cell serializedFragment] withString:newContent]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment