From b04caec3915979cd4d943886100e97f85df77c7c Mon Sep 17 00:00:00 2001 From: Andre Stackhouse Date: Mon, 30 Mar 2020 09:41:34 -0700 Subject: [PATCH 1/2] Add optional custom markupformatter parameter --- PreMailer.Net/PreMailer.Net/PreMailer.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/PreMailer.Net/PreMailer.Net/PreMailer.cs b/PreMailer.Net/PreMailer.Net/PreMailer.cs index df7d4265..6a6b0135 100644 --- a/PreMailer.Net/PreMailer.Net/PreMailer.cs +++ b/PreMailer.Net/PreMailer.Net/PreMailer.cs @@ -74,9 +74,9 @@ public PreMailer(Stream stream, Uri baseUri = null) /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false) + public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) { - return new PreMailer(html).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments); + return new PreMailer(html).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } /// @@ -89,9 +89,9 @@ public static InlineResult MoveCssInline(string html, bool removeStyleElements = /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false) + public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) { - return new PreMailer(stream).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments); + return new PreMailer(stream).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } /// @@ -106,9 +106,9 @@ public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false) + public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) { - return new PreMailer(html, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments); + return new PreMailer(html, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } /// @@ -123,9 +123,9 @@ public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeSt /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false) + public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) { - return new PreMailer(stream, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments); + return new PreMailer(stream, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } /// @@ -137,7 +137,7 @@ public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool remove /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false) + public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) { // Store the variables used for inlining the CSS _removeStyleElements = removeStyleElements; @@ -179,7 +179,7 @@ public InlineResult MoveCssInline(bool removeStyleElements = false, string ignor } } - IMarkupFormatter markupFormatter = GetMarkupFormatterForDocType(); + IMarkupFormatter markupFormatter = customFormatter ?? GetMarkupFormatterForDocType(); using (var sw = new StringWriter()) { From 9ac3fc61bd39c2cc480867632d4f522ca0ec8f8f Mon Sep 17 00:00:00 2001 From: Andre Stackhouse Date: Mon, 30 Mar 2020 10:37:11 -0700 Subject: [PATCH 2/2] Remove duplicate param, update to proper param --- PreMailer.Net/PreMailer.Net/PreMailer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PreMailer.Net/PreMailer.Net/PreMailer.cs b/PreMailer.Net/PreMailer.Net/PreMailer.cs index 6a6b0135..032281a3 100644 --- a/PreMailer.Net/PreMailer.Net/PreMailer.cs +++ b/PreMailer.Net/PreMailer.Net/PreMailer.cs @@ -74,7 +74,7 @@ public PreMailer(Stream stream, Uri baseUri = null) /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) + public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null) { return new PreMailer(html).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } @@ -89,7 +89,7 @@ public static InlineResult MoveCssInline(string html, bool removeStyleElements = /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) + public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null) { return new PreMailer(stream).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } @@ -106,7 +106,7 @@ public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) + public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null) { return new PreMailer(html, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } @@ -123,7 +123,7 @@ public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeSt /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) + public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null) { return new PreMailer(stream, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter); } @@ -137,7 +137,7 @@ public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool remove /// True to strip ID and class attributes /// True to remove comments, false to leave them intact /// Returns the html input, with styles moved to inline attributes. - public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, bool removeComments = false) + public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null) { // Store the variables used for inlining the CSS _removeStyleElements = removeStyleElements;