Perfect. Using this new flushCallback I was able to move the hyphenate code to an external file separate from the main code making things easier for the future. I was also able to separate out the paragraph spacing option I did to the same block. Good architecture.

Things are way more organized now that the parsing is with libxml2.

-- Guy

Sent from my Mac. 



On Jan 27, 2012, at 17:04 , Oliver Drobnik wrote:

> Ok, I added a property to pass your own block to. I made it a block as opposed to a delegate callback because this is more efficient as the block gets executed on the string building GCD queue.
> 
> example:
> 
> 	DTHTMLAttributedStringBuilder	*stringBuilder = [[DTHTMLAttributedStringBuilder alloc] initWithHTML:data options:options documentAttributes:dict];
> 	
> 	[stringBuilder setWillFlushCallback:^(DTHTMLElement *element) { NSLog(@"%@", element.tagName); } ];
> 	
> 	[stringBuilder buildString];
> 	
> 	return [stringBuilder generatedAttributedString];
> 
> 
> Am Jan 27, 2012 um 3:45 PM schrieb gshaviv:
> 
>> I would need the entire DTHTMLElement. I do look at the current style,
>> hyphenation doesn't look good on left justified text, but is essential
>> to fully justified text. Going the delegate way would be good as I
>> wouldn't need even to override the parser creation or subclass it,
>> though subclassing it enables no overhead when there is no delegate (
>> though having a null delegate probably doesn't add any significant
>> overhead).
>> 
>> Guy
>> 
>> On 27 בינו 2012, at 16:39, Oliver Drobnik
>> <reply@reply.github.com>
>> wrote:
>> 
>>> Right now it only passes the string inside the tag. If you need more information about the currently processed tag then we can change that into a block or delegate method that passes the current DTHTMLElement with the current text in the .text property.
>>> 
>>> But I figured you might want to use hyphenation regardless of the text alignment, so I kept it as that for the time being.
>>> 
>>> I just want you to be able to have the faster master as your base to save you some work on having to adjust my code all the time.
>>> 
>>> cheers
>>> Oliver
>>> 
>>> 
>>> Am Jan 27, 2012 um 3:32 PM schrieb gshaviv:
>>> 
>>>> Gee, thanks. Sounds cool. I'll take a look at it.
>>>> 
>>>> Guy
>>>> 
>>>> I understand quickly when things are explained to me slowly...
>>>> 
>>>> 
>>>> 
>>>> On Jan 27, 2012, at 16:29 , Oliver Drobnik wrote:
>>>> 
>>>>> I merged the parse blocks branch now back into master and "just for you" I implemented a method that you could override in a DTHTMLAttributedStringBuilder subclass: -(void)flushCurrentTagContent:(NSString *)tagContent
>>>>> 
>>>>> this gives you a possibility to run the hyphenation on tagContent and then call super. This flushing occurs every time a tag begins or ends and aggregates tag contents until either of these. Therefore this also works if you have HTML entities inside of words.
>>>>> 
>>>>> 0d2a8b463a5555b3a9dc8b6a9e0777ad4d58b4e6
>>>>> 
>>>>> ---
>>>>> Reply to this email directly or view it on GitHub:
>>>>> https://github.com/gshaviv/DTCoreText/commit/6e8ae6cd34b67a2a72f906508b0cd7b59fb176fa#commitcomment-908230
>>>> 
>>>> ---
>>>> Reply to this email directly or view it on GitHub:
>>>> https://github.com/gshaviv/DTCoreText/commit/6e8ae6cd34b67a2a72f906508b0cd7b59fb176fa#commitcomment-908235
>>> 
>>> ---
>>> Reply to this email directly or view it on GitHub:
>>> https://github.com/gshaviv/DTCoreText/commit/6e8ae6cd34b67a2a72f906508b0cd7b59fb176fa#commitcomment-908255
>> 
>> --- 
>> Reply to this email directly or view it on GitHub:
>> https://github.com/gshaviv/DTCoreText/commit/6e8ae6cd34b67a2a72f906508b0cd7b59fb176fa#commitcomment-908277
> 
> --- 
> Reply to this email directly or view it on GitHub:
> https://github.com/gshaviv/DTCoreText/commit/6e8ae6cd34b67a2a72f906508b0cd7b59fb176fa#commitcomment-908370