Skip to content

Commit b8d293b

Browse files
committed
Merge pull request #102 from milkshakesoftware/doctype-issue
Preserve original DOCTYPE Closes #38 Closes #97 Closes #101
2 parents f69419f + d416080 commit b8d293b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

PreMailer.Net/PreMailer.Net.Tests/PreMailerTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,15 @@ @keyframes mymove {
418418

419419
Assert.IsTrue(premailedOutput.Html.Contains("<div class=\"test\" style=\"background-color: #f1f1f1\""));
420420
}
421+
422+
[TestMethod]
423+
public void MoveCSSInline_PreservesDocType()
424+
{
425+
string input = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body></body></html>";
426+
427+
var premailedOutput = PreMailer.MoveCssInline(input, false);
428+
429+
Assert.IsTrue(premailedOutput.Html.StartsWith("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">"));
430+
}
421431
}
422432
}

PreMailer.Net/PreMailer.Net/PreMailer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public InlineResult MoveCssInline(bool removeStyleElements = false, string ignor
119119
}
120120
}
121121

122-
var html = _document.DocumentElement.OuterHtml;
122+
var html = _document.ToHtml();
123+
123124
return new InlineResult(html, _warnings);
124125
}
125126

0 commit comments

Comments
 (0)