don't remove a[name] tags when they contain text.
This commit is contained in:
@@ -139,7 +139,9 @@ namespace ReadSharp.Ports.NReadability
|
||||
{
|
||||
{ new Regex("^https?://(www|mobile)\\.theverge.com", RegexOptions.IgnoreCase), ".entry-body" },
|
||||
{ new Regex("^https?://(www|blog)\\.bufferapp.com", RegexOptions.IgnoreCase), ".post" },
|
||||
{ new Regex("^https?://(www.)?polygon.com", RegexOptions.IgnoreCase), ".body" }
|
||||
{ new Regex("^https?://(www.)?polygon.com", RegexOptions.IgnoreCase), ".body" },
|
||||
{ new Regex("^https?://(www.)?gizmodo.com", RegexOptions.IgnoreCase), ".post-container" },
|
||||
{ new Regex("^https?://(www.)?it-scoop.com", RegexOptions.IgnoreCase), ".entry-content" }
|
||||
};
|
||||
|
||||
#endregion
|
||||
@@ -790,7 +792,22 @@ namespace ReadSharp.Ports.NReadability
|
||||
rootElement.GetElementsByTagName("a")
|
||||
.Where(aElement => aElement.Attribute("name") != null && aElement.Attribute("href") == null);
|
||||
|
||||
elementsToRemove.AddRange(anchorElements);
|
||||
var elementsToBeReplaced = new List<XElement>();
|
||||
|
||||
foreach (XElement element in anchorElements)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(element.Value))
|
||||
{
|
||||
elementsToBeReplaced.Add(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
elementsToRemove.Add(element);
|
||||
}
|
||||
}
|
||||
|
||||
elementsToBeReplaced.ForEach(element => element.ReplaceWith(element.Value));
|
||||
|
||||
RemoveElements(elementsToRemove);
|
||||
|
||||
/* Turn all double br's into p's and all font's into span's. */
|
||||
|
||||
@@ -129,9 +129,14 @@ namespace ReadSharp.Tests
|
||||
[Fact]
|
||||
public async Task TestDifferentCharsets()
|
||||
{
|
||||
// chinese?
|
||||
string expectedTitle = "优艺客-专注互联网品牌建设-原韩雪冬网页设计工作室(公司站)";
|
||||
Article result = await reader.Read(new Uri("http://www.uelike.com"));
|
||||
Assert.Equal(result.Title, expectedTitle);
|
||||
|
||||
// arabic
|
||||
result = await reader.Read(new Uri("http://www.it-scoop.com/2014/01/internet-of-things-google-nest/"));
|
||||
Assert.NotEmpty(result.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -140,6 +145,9 @@ namespace ReadSharp.Tests
|
||||
Article result = await reader.Read(new Uri("http://wpcentral.com.feedsportal.com/c/33999/f/616880/s/35a02b5e/sc/15/l/0L0Swpcentral0N0Cgameloft0Ediscusses0Etheir0Enew0Egame0Ebrothers0Earms0E30Esons0Ewar0Eceslive/story01.htm"));
|
||||
Assert.NotEmpty(result.Content);
|
||||
|
||||
result = await reader.Read(new Uri("http://www.fastcoexist.com/3016005/futurist-forum/10-creative-ideas-for-thriving-cities-of-the-future"));
|
||||
Assert.Contains("1: 311", result.Content);
|
||||
|
||||
result = await reader.Read(new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx"));
|
||||
Assert.NotEmpty(result.Content);
|
||||
|
||||
@@ -166,5 +174,15 @@ namespace ReadSharp.Tests
|
||||
result = await reader.Read(new Uri("http://blog.bufferapp.com/connections-in-the-brain-understanding-creativity-and-intelligenceconnections"));
|
||||
Assert.Contains("The Tweet resulted in over 1,000 retweets", result.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AreMultipageArticlesWorking()
|
||||
{
|
||||
Article result = await reader.Read(new Uri("http://www.pcwelt.de/ratgeber/Acht_Tipps_fuer_die_sichere_Cloud-Google_Drive__Microsoft_Skydrive__Teamdrive-8205869.html?redirect=1"));
|
||||
Assert.NotNull(result.NextPage);
|
||||
|
||||
result = await reader.Read(new Uri("http://arstechnica.com/apple/2014/01/two-steps-forward-a-review-of-the-2013-mac-pro/"));
|
||||
Assert.NotNull(result.NextPage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user