DTHTMLElement Class Reference
Inherits from | DTHTMLParserNode : NSObject |
Declared in | DTHTMLElement.h |
Overview
Class to represent a element (aka “tag”) in a HTML document. Structure information - like parent or children - is inherited from its superclass DTHTMLParserNode.
Tasks
Creating HTML Elements
Creating Attributed Strings
Getting Element Information
-
fontDescriptor
property -
paragraphStyle
property -
textAttachment
property -
link
property -
anchorName
property -
textColor
property -
backgroundColor
property -
backgroundStrokeColor
property -
backgroundStrokeWidth
property -
backgroundCornerRadius
property -
letterSpacing
property -
beforeContent
property -
shadows
property -
underlineStyle
property -
strikeOut
property -
superscriptStyle
property -
headerLevel
property -
displayStyle
property -
floatStyle
property -
isColorInherited
property -
preserveNewlines
property -
fontVariant
property -
currentTextSize
property -
textScale
property -
size
property -
margins
property -
padding
property -
containsAppleConvertedSpace
property -
shouldProcessCustomHTMLAttributes
property
Working with HTML Attributes
-
– attributeForKey:
-
– inheritAttributesFromElement:
-
– interpretAttributes
-
+ attributesToIgnoreForCustomAttributesAttribute
-
CSSClassNamesToIgnoreForCustomAttributes
property
Working with CSS Styles
HTML Node Hierarchy
Output State (Internal)
-
didOutput
property -
– needsOutput
Properties
CSSClassNamesToIgnoreForCustomAttributes
The CSS class names that are not to be added to the “class” custom attribute in the DTCustomAttributesAttribute key. Those are usually the class names
@property (nonatomic, strong) NSSet *CSSClassNamesToIgnoreForCustomAttributes
Declared In
DTHTMLElement.h
anchorName
Anchor name, used by hyperlinks, of the receiver that can be used to scroll to.
@property (nonatomic, copy) NSString *anchorName
Declared In
DTHTMLElement.h
backgroundColor
Background color of text in the receiver
@property (nonatomic, strong) DTColor *backgroundColor
Declared In
DTHTMLElement.h
backgroundCornerRadius
Background stroke width in the receiver
@property (nonatomic, assign) CGFloat backgroundCornerRadius
Declared In
DTHTMLElement.h
backgroundStrokeColor
Background stroke color in the receiver
@property (nonatomic, strong) DTColor *backgroundStrokeColor
Declared In
DTHTMLElement.h
backgroundStrokeWidth
Background stroke width in the receiver
@property (nonatomic, assign) CGFloat backgroundStrokeWidth
Declared In
DTHTMLElement.h
beforeContent
Additional text to be inserted before the text content of the receiver
@property (nonatomic, copy) NSString *beforeContent
Declared In
DTHTMLElement.h
containsAppleConvertedSpace
Specifies that whitespace contained in the receiver’s text has been converted with Apple’s algorithm.
@property (nonatomic, assign) BOOL containsAppleConvertedSpace
Declared In
DTHTMLElement.h
currentTextSize
The current unscaled font size (used when inheriting font size). You’re probably looking for fontDescriptor.pointSize.
@property (nonatomic, assign) CGFloat currentTextSize
Declared In
DTHTMLElement.h
didOutput
Internal state during string building to mark the receiver als having been flushed
@property (nonatomic, assign) BOOL didOutput
Declared In
DTHTMLElement.h
displayStyle
The display style of the receiver.
@property (nonatomic, assign) DTHTMLElementDisplayStyle displayStyle
Declared In
DTHTMLElement.h
floatStyle
Whether the receiver is marked as float. While floating is not currently supported this can be used to add additional paragraph breaks.
@property (nonatomic, readonly) DTHTMLElementFloatStyle floatStyle
Declared In
DTHTMLElement.h
fontDescriptor
Font Descriptor describing the font state of the receiver
@property (nonatomic, copy) DTCoreTextFontDescriptor *fontDescriptor
Declared In
DTHTMLElement.h
fontVariant
The current font variant of the receiver, normal or small caps.
@property (nonatomic, assign) DTHTMLElementFontVariant fontVariant
Declared In
DTHTMLElement.h
headerLevel
The header level of the receiver, or 0 if it is not a header
@property (nonatomic, assign) NSInteger headerLevel
Declared In
DTHTMLElement.h
letterSpacing
The custom letter spacing of the receiver, default is 0px
@property (nonatomic, assign) CGFloat letterSpacing
Declared In
DTHTMLElement.h
link
Hyperlink URL of the receiver, or nil
if there is no hyperlink
@property (nonatomic, copy) NSURL *link
Declared In
DTHTMLElement.h
margins
The value of the CSS margins. Margin support is incomplete.
@property (nonatomic, assign) DTEdgeInsets margins
Declared In
DTHTMLElement.h
padding
The value of the CSS padding. Padding are added to DTTextBlock instances for block-level elements.
@property (nonatomic, assign) DTEdgeInsets padding
Declared In
DTHTMLElement.h
paragraphStyle
Paragraph Style describing the paragraph state of the receiver
@property (nonatomic, copy) DTCoreTextParagraphStyle *paragraphStyle
Declared In
DTHTMLElement.h
preserveNewlines
Specifies that whitespace and new lines should be preserved. Default is to compress white space.
@property (nonatomic, assign) BOOL preserveNewlines
Declared In
DTHTMLElement.h
shadows
Array of shadows attached to the text contents of the receiver
@property (nonatomic, copy) NSArray *shadows
Declared In
DTHTMLElement.h
shouldProcessCustomHTMLAttributes
Prevents adding custom HTML attributes to output
@property (nonatomic, assign) BOOL shouldProcessCustomHTMLAttributes
Declared In
DTHTMLElement.h
size
The size of the receiver, either from width/height attributes or width/hight styles.
@property (nonatomic, assign) CGSize size
Declared In
DTHTMLElement.h
strikeOut
The strike-out style of the receiver
@property (nonatomic, assign) BOOL strikeOut
Declared In
DTHTMLElement.h
superscriptStyle
The superscript style of the receiver or 0 if it does not have superscript text.
@property (nonatomic, assign) NSInteger superscriptStyle
Declared In
DTHTMLElement.h
textAttachment
Text Attachment of the receiver, or nil
if there is no attachment
@property (nonatomic, strong) DTTextAttachment *textAttachment
Declared In
DTHTMLElement.h
textColor
Foreground text color of the receiver
@property (nonatomic, strong) DTColor *textColor
Declared In
DTHTMLElement.h
Class Methods
attributesToIgnoreForCustomAttributesAttribute
The HTML attributes that should be attached to the generated attributed string. Typically all attributes that were processed by interpretAttributes are in this list. All other attributes get added to the generated attributed string with the DTCustomAttributesAttribute key.
+ (NSSet *)attributesToIgnoreForCustomAttributesAttribute
Declared In
DTHTMLElement.h
elementWithName:attributes:options:
Designed initializer, creates the appropriate element sub type
+ (DTHTMLElement *)elementWithName:(NSString *)name attributes:(NSDictionary *)attributes options:(NSDictionary *)options
Parameters
- name
The element name
- attributes
The attributes dictionary of the tag
- options
The parsing options dictionary
Return Value
the initialized element
Declared In
DTHTMLElement.h
Instance Methods
applyStyleDictionary:
Applies the style information contained in a styles dictionary to the receiver
- (void)applyStyleDictionary:(NSDictionary *)styles
Parameters
- styles
A style dictionary
Declared In
DTHTMLElement.h
attributeForKey:
Retrieves an attribute with a given key
- (NSString *)attributeForKey:(NSString *)key
Parameters
- key
The attribute name to retrieve
Return Value
the attribute string
Declared In
DTHTMLElement.h
attributedString
Creates an NSAttributedString
that represents the receiver including all its children. This method is typically overwritten in subclasses of
- (NSAttributedString *)attributedString
Return Value
An attributed string that also contains the children
Declared In
DTHTMLElement.h
attributesForAttributedStringRepresentation
The dictionary of Core Text attributes for creating an NSAttributedString
representation for the receiver
- (NSDictionary *)attributesForAttributedStringRepresentation
Return Value
The dictionary of attributes
Declared In
DTHTMLElement.h
inheritAttributesFromElement:
Copies and inherits relevant attributes from the given parent element
- (void)inheritAttributesFromElement:(DTHTMLElement *)element
Parameters
- element
The element to inherit attributes from
Declared In
DTHTMLElement.h
interpretAttributes
Interprets the tag attributes for e.g. writing direction. Usually you would call this after inheritAttributesFromElement:.
- (void)interpretAttributes
Declared In
DTHTMLElement.h
listStyle
Creates a DTCSSListStyle to match the CSS styles
- (DTCSSListStyle *)listStyle
Declared In
DTHTMLElement.h