Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

-writeHTMLString:withTerminatingNewline:

  • Loading branch information...
commit 19439d329417e9e218207a87e82dbce1316efeec 1 parent eca2e7b
@mikeabdullah mikeabdullah authored
Showing with 16 additions and 1 deletion.
  1. +2 −1  KSHTMLWriter.h
  2. +14 −0 KSHTMLWriter.m
View
3  KSHTMLWriter.h
@@ -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
View
14 KSHTMLWriter.m
@@ -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];
Please sign in to comment.
Something went wrong with that request. Please try again.