don't remove a[name] tags when they contain text.

This commit is contained in:
2014-02-09 17:57:32 +01:00
parent f4190ecbcd
commit c0b4635865
2 changed files with 37 additions and 2 deletions
@@ -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. */