Skip to content

Commit 1f5eab1

Browse files
Merge pull request #198 from CaptainStack/master
Add optional custom markupformatter parameter
2 parents 89510bf + 9ac3fc6 commit 1f5eab1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

PreMailer.Net/PreMailer.Net/PreMailer.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ public PreMailer(Stream stream, Uri baseUri = null)
7474
/// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
7575
/// <param name="removeComments">True to remove comments, false to leave them intact</param>
7676
/// <returns>Returns the html input, with styles moved to inline attributes.</returns>
77-
public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false)
77+
public static InlineResult MoveCssInline(string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null)
7878
{
79-
return new PreMailer(html).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments);
79+
return new PreMailer(html).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter);
8080
}
8181

8282
/// <summary>
@@ -89,9 +89,9 @@ public static InlineResult MoveCssInline(string html, bool removeStyleElements =
8989
/// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
9090
/// <param name="removeComments">True to remove comments, false to leave them intact</param>
9191
/// <returns>Returns the html input, with styles moved to inline attributes.</returns>
92-
public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false)
92+
public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null)
9393
{
94-
return new PreMailer(stream).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments);
94+
return new PreMailer(stream).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter);
9595
}
9696

9797
/// <summary>
@@ -106,9 +106,9 @@ public static InlineResult MoveCssInline(Stream stream, bool removeStyleElements
106106
/// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
107107
/// <param name="removeComments">True to remove comments, false to leave them intact</param>
108108
/// <returns>Returns the html input, with styles moved to inline attributes.</returns>
109-
public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false)
109+
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)
110110
{
111-
return new PreMailer(html, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments);
111+
return new PreMailer(html, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter);
112112
}
113113

114114
/// <summary>
@@ -123,9 +123,9 @@ public static InlineResult MoveCssInline(Uri baseUri, string html, bool removeSt
123123
/// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
124124
/// <param name="removeComments">True to remove comments, false to leave them intact</param>
125125
/// <returns>Returns the html input, with styles moved to inline attributes.</returns>
126-
public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false)
126+
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)
127127
{
128-
return new PreMailer(stream, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments);
128+
return new PreMailer(stream, baseUri).MoveCssInline(removeStyleElements, ignoreElements, css, stripIdAndClassAttributes, removeComments, customFormatter);
129129
}
130130

131131
/// <summary>
@@ -137,7 +137,7 @@ public static InlineResult MoveCssInline(Uri baseUri, Stream stream, bool remove
137137
/// <param name="stripIdAndClassAttributes">True to strip ID and class attributes</param>
138138
/// <param name="removeComments">True to remove comments, false to leave them intact</param>
139139
/// <returns>Returns the html input, with styles moved to inline attributes.</returns>
140-
public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false)
140+
public InlineResult MoveCssInline(bool removeStyleElements = false, string ignoreElements = null, string css = null, bool stripIdAndClassAttributes = false, bool removeComments = false, IMarkupFormatter customFormatter = null)
141141
{
142142
// Store the variables used for inlining the CSS
143143
_removeStyleElements = removeStyleElements;
@@ -179,7 +179,7 @@ public InlineResult MoveCssInline(bool removeStyleElements = false, string ignor
179179
}
180180
}
181181

182-
IMarkupFormatter markupFormatter = GetMarkupFormatterForDocType();
182+
IMarkupFormatter markupFormatter = customFormatter ?? GetMarkupFormatterForDocType();
183183

184184
using (var sw = new StringWriter())
185185
{

0 commit comments

Comments
 (0)