Skip to content

Commit

Permalink
Updated SgmlDomBuilder so that it respects significant whitespaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-stoj committed May 29, 2013
1 parent aa51285 commit 8872e22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -36,3 +36,4 @@
/Src/NReadability/NReadability.6.1.ReSharper.user
/Src/NReadability/NReadability.sln.DotSettings.user
*.suo
Src/NReadability/NReadability.sln.DotSettings
14 changes: 13 additions & 1 deletion Src/NReadability/NReadability.Tests/SgmlDomBuilderTests.cs
@@ -1,4 +1,5 @@
using System.Xml.Linq;
using System;
using System.Xml.Linq;
using NUnit.Framework;

namespace NReadability.Tests
Expand Down Expand Up @@ -54,6 +55,17 @@ public void Builder_handles_invalid_entity_references()
Assert.DoesNotThrow(() => _sgmlDomSerializer.SerializeDocument(document));
}

[Test]
public void Builder_respects_significant_whitespaces()
{
XDocument document =
_sgmlDomBuilder.BuildDocument("<a>Link1</a> <a>Link2</a>");

string html = _sgmlDomSerializer.SerializeDocument(document);

Assert.IsTrue(html.Contains("<a>Link1</a> <a>Link2</a>"));
}

#endregion
}
}
2 changes: 1 addition & 1 deletion Src/NReadability/NReadability/SgmlDomBuilder.cs
Expand Up @@ -96,7 +96,7 @@ private static XDocument LoadDocument(string htmlContent)
{
sgmlReader.CaseFolding = CaseFolding.ToLower;
sgmlReader.DocType = "HTML";
sgmlReader.WhitespaceHandling = WhitespaceHandling.None;
sgmlReader.WhitespaceHandling = WhitespaceHandling.Significant;

using (var sr = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(htmlContent))))
{
Expand Down

0 comments on commit 8872e22

Please sign in to comment.