Permalink
Browse files

Support for own element class.

  • Loading branch information...
1 parent 3d06a89 commit 31affae621a32f80570e887966af59c67373447f Christian Beer committed Jun 14, 2012
Showing with 12 additions and 7 deletions.
  1. +9 −4 Core/Source/DTHTMLAttributedStringBuilder.m
  2. +1 −1 Core/Source/DTHTMLElement.h
  3. +2 −2 Core/Source/DTHTMLElement.m
View
13 Core/Source/DTHTMLAttributedStringBuilder.m
@@ -221,6 +221,11 @@ - (void) setupStringBuilder
}
}
+- (Class) htmlElementClass
+{
+ return [DTHTMLElement class];
+}
+
- (BOOL) parseData:(NSData*)data
{
// only with valid data
@@ -229,7 +234,7 @@ - (BOOL) parseData:(NSData*)data
return NO;
}
- DTHTMLElement *defaultTag = [[DTHTMLElement alloc] init];
+ DTHTMLElement *defaultTag = [[[self htmlElementClass] alloc] init];
defaultTag.fontDescriptor = defaultFontDescriptor;
defaultTag.paragraphStyle = defaultParagraphStyle;
defaultTag.textScale = textScale;
@@ -450,7 +455,7 @@ - (void)_registerTagStartHandlers
NSString *cleanString = [[currentTag attributeForKey:@"href"] stringByReplacingOccurrencesOfString:@"\n" withString:@""];
cleanString = [cleanString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- NSURL *link = [NSURL URLWithString:cleanString];
+/* NSURL *link = [NSURL URLWithString:cleanString];
// deal with relative URL
if (![link scheme])
@@ -471,9 +476,9 @@ - (void)_registerTagStartHandlers
{
link = baseURL;
}
- }
+ }*/
- currentTag.link = link;
+ currentTag.link = cleanString;
};
[_tagStartHandlers setObject:[aBlock copy] forKey:@"a"];
View
2 Core/Source/DTHTMLElement.h
@@ -42,7 +42,7 @@ typedef enum
@property (nonatomic, copy) DTCoreTextFontDescriptor *fontDescriptor;
@property (nonatomic, copy) DTCoreTextParagraphStyle *paragraphStyle;
@property (nonatomic, strong) DTTextAttachment *textAttachment;
-@property (nonatomic, copy) NSURL *link;
+@property (nonatomic, copy) NSString *link;
@property (nonatomic, strong) DTColor *textColor;
@property (nonatomic, strong) DTColor *backgroundColor;
@property (nonatomic, copy) NSString *tagName;
View
4 Core/Source/DTHTMLElement.m
@@ -25,7 +25,7 @@ @implementation DTHTMLElement
DTCoreTextParagraphStyle *paragraphStyle;
DTTextAttachment *_textAttachment;
DTTextAttachmentVerticalAlignment _textAttachmentAlignment;
- NSURL *link;
+ NSString *link;
DTColor *_textColor;
DTColor *backgroundColor;
@@ -879,7 +879,7 @@ - (DTCSSListStyle *)calculatedListStyle
- (id)copyWithZone:(NSZone *)zone
{
- DTHTMLElement *newObject = [[DTHTMLElement allocWithZone:zone] init];
+ DTHTMLElement *newObject = [[[self class] allocWithZone:zone] init];
newObject.fontDescriptor = self.fontDescriptor; // copy
newObject.paragraphStyle = self.paragraphStyle; // copy

0 comments on commit 31affae

Please sign in to comment.