Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Can now ditch -openTag:writeInline:

  • Loading branch information...
commit c8bc317460408b2863c9810bf2fd4942251a27bd 1 parent 5136d54
Mike Abdullah mikeabdullah authored
Showing with 27 additions and 31 deletions.
  1. +2 −2 KSHTMLWriter.m
  2. +0 −1  KSXMLWriter.h
  3. +25 −28 KSXMLWriter.m
4 KSHTMLWriter.m
View
@@ -291,7 +291,7 @@ - (BOOL)canWriteElementInline:(NSString *)tagName;
#pragma mark Element Primitives
-- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
+- (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline; // for more control
{
// Add in any pre-written classes
if ([_classNames count])
@@ -301,7 +301,7 @@ - (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
[self addAttribute:@"class" value:class];
}
- [super openTag:element writeInline:writeInline];
+ [super startElement:elementName writeInline:writeInline];
}
- (void)closeEmptyElementTag; // /> OR > depending on -isXHTML
1  KSXMLWriter.h
View
@@ -86,7 +86,6 @@
#pragma mark Element Primitives
-- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
- (void)closeEmptyElementTag;
53 KSXMLWriter.m
View
@@ -105,7 +105,31 @@ - (void)startElement:(NSString *)elementName;
- (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline;
{
- [self openTag:elementName writeInline:writeInline];
+ // Can only write suitable tags inline if containing element also allows it
+ if (!writeInline)
+ {
+ [self startNewline];
+ [self stopWritingInline];
+ }
+
+ elementName = [elementName lowercaseString]; // writes coming from the DOM are uppercase
+ [self writeString:@"<"];
+ [self writeString:elementName];
+
+ // Must do this AFTER writing the string so subclasses can take early action in a -writeString: override
+ [self pushElement:elementName];
+
+
+ // Write attributes
+ for (int i = 0; i < [_attributes count]; i+=2)
+ {
+ NSString *attribute = [_attributes objectAtIndex:i];
+ NSString *value = [_attributes objectAtIndex:i+1];
+ [self writeAttribute:attribute value:value];
+ }
+ [_attributes removeAllObjects];
+
+
[self didStartElement];
}
@@ -252,33 +276,6 @@ - (void)popElement;
#pragma mark Element Primitives
-- (void)openTag:(NSString *)element writeInline:(BOOL)writeInline;
-{
- // Can only write suitable tags inline if containing element also allows it
- if (!writeInline)
- {
- [self startNewline];
- [self stopWritingInline];
- }
-
- element = [element lowercaseString]; // writes coming from the DOM are uppercase
- [self writeString:@"<"];
- [self writeString:element];
-
- // Must do this AFTER writing the string so subclasses can take early action in a -writeString: override
- [self pushElement:element];
-
-
- // Write attributes
- for (int i = 0; i < [_attributes count]; i+=2)
- {
- NSString *attribute = [_attributes objectAtIndex:i];
- NSString *value = [_attributes objectAtIndex:i+1];
- [self writeAttribute:attribute value:value];
- }
- [_attributes removeAllObjects];
-}
-
- (void)writeAttribute:(NSString *)attribute
value:(NSString *)value;
{
Please sign in to comment.
Something went wrong with that request. Please try again.