Skip to content

Commit

Permalink
Redone fixing Cocoanetics#156
Browse files Browse the repository at this point in the history
because it not properly deal with non-empty paragraph.
  • Loading branch information
odrobnik committed Mar 29, 2012
1 parent 7e7d5ec commit fe89a60
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 10 additions & 2 deletions Core/Source/NSAttributedString+DTCoreText.m
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,20 @@ - (NSString *)htmlString

NSArray *previousListStyles = nil;

// one empty paragraph at end we don't care about
for (int i=0; i<[paragraphs count]-1; i++)
for (int i=0; i<[paragraphs count]; i++)
{
NSString *oneParagraph = [paragraphs objectAtIndex:i];
NSRange paragraphRange = NSMakeRange(location, [oneParagraph length]);

// skip empty paragraph at the end
if (i==[paragraphs count]-1)
{
if (!paragraphRange.length)
{
continue;
}
}

BOOL needsToRemovePrefix = NO;

BOOL fontIsBlockLevel = NO;
Expand Down
5 changes: 3 additions & 2 deletions Demo/Resources/CurrentTest.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<p style="font-size:30px">some text 中文</p>
<p style="font-size:30px"><b>some text 中文</b></p>
<p style="font-family:'Times New Roman';font-size:20px;">Hello</p>
<p style="font-family:'Times New Roman';font-size:20px;"></p>
<p style="font-family:'Times New Roman';font-size:20px;">World</p>

0 comments on commit fe89a60

Please sign in to comment.