Skip to content

Commit

Permalink
-writeHTMLString:withTerminatingNewline:
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeabdullah committed Jun 28, 2012
1 parent eca2e7b commit 19439d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion KSHTMLWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ 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;
// Terminating newline character will be added or removed if needed, as according to terminatingNewline argument
- (void)writeHTMLString:(NSString *)html withTerminatingNewline:(BOOL)terminatingNewline;


#pragma mark General
Expand Down
14 changes: 14 additions & 0 deletions KSHTMLWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ - (BOOL)hasCurrentAttributes;

#pragma mark HTML Fragments

- (void)writeHTMLString:(NSString *)html withTerminatingNewline:(BOOL)terminatingNewline;
{
if (terminatingNewline)
{
if (![html hasSuffix:@"\n"]) html = [html stringByAppendingString:@"\n"];
}
else
{
if ([html hasSuffix:@"\n"]) html = [html substringToIndex:[html length] - 1];
}

[self writeHTMLString:html];
}

- (void)writeHTMLString:(NSString *)html;
{
NSUInteger indent = [self indentationLevel];
Expand Down

0 comments on commit 19439d3

Please sign in to comment.