Skip to content

Commit

Permalink
Added an HtmlToHtml.FilterComments property to remove comments
Browse files Browse the repository at this point in the history
Fixes issue #271
  • Loading branch information
jstedfast committed Oct 14, 2016
1 parent 88bade7 commit c2cc42d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions MimeKit/Text/HtmlToHtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public override TextFormat OutputFormat {
get { return TextFormat.Html; }
}

/// <summary>
/// Get or set whether or not the converter should remove HTML comments from the output.
/// </summary>
/// <remarks>
/// Gets or sets whether or not the converter should remove HTML comments from the output.
/// </remarks>
/// <value><c>true</c> if the converter should remove comments; otherwise, <c>false</c>.</value>
public bool FilterComments {
get; set;
}

/// <summary>
/// Get or set whether or not executable scripts should be stripped from the output.
/// </summary>
Expand Down Expand Up @@ -284,6 +295,10 @@ public override void Convert (TextReader reader, TextWriter writer)
if (!SuppressContent (stack))
htmlWriter.WriteToken (token);
break;
case HtmlTokenKind.Comment:
if (!FilterComments)
htmlWriter.WriteToken (token);
break;
case HtmlTokenKind.Tag:
var tag = (HtmlTagToken) token;

Expand Down

0 comments on commit c2cc42d

Please sign in to comment.