Permalink
Browse files

Account for indentation level in -writeHTMLString:

  • Loading branch information...
1 parent 12b9584 commit 6bfd659387e614964e557e82d3c679a155351c0f @mikeabdullah mikeabdullah committed Jun 1, 2012
Showing with 11 additions and 0 deletions.
  1. +1 −0 KSHTMLWriter.h
  2. +10 −0 KSHTMLWriter.m
View
@@ -71,6 +71,7 @@ extern NSString *KSHTMLWriterDocTypeHTML_5;
#pragma mark HTML Fragments
+// Any newlines in the HTML will be adjusted to account for current indentation level, but that's all
- (void)writeHTMLString:(NSString *)html;
- (void)writeHTMLFormat:(NSString *)format , ...;
View
@@ -162,6 +162,16 @@ - (BOOL)hasCurrentAttributes;
- (void)writeHTMLString:(NSString *)html;
{
+ NSUInteger indent = [self indentationLevel];
+ if (indent)
+ {
+ NSString *indentedNewline = [@"\n" stringByPaddingToLength:indent + 1
+ withString:@"\t"
+ startingAtIndex:0];
+
+ html = [html stringByReplacingOccurrencesOfString:@"\n" withString:indentedNewline];
+ }
+
[self writeString:html];
}

0 comments on commit 6bfd659

Please sign in to comment.