public static void SetInnerHtml(this XElement element, string html) { if (element == null) { throw new ArgumentNullException("element"); } if (html == null) { throw new ArgumentNullException("html"); } element.RemoveAll(); var tmpElement = new SgmlDomBuilder().BuildDocument(html); if (tmpElement.Root == null) { return; } foreach (var node in tmpElement.Root.Nodes()) { element.Add(node); } }
/// <summary> /// Initializes a new instance of NReadabilityTranscoder. Allows setting all options. /// </summary> /// <param name="dontStripUnlikelys">Determines whether elements that are unlikely to be a part of main content will be removed.</param> /// <param name="dontNormalizeSpacesInTextContent">Determines whether spaces in InnerText properties of elements will be normalized automatically (eg. whether double spaces will be replaced with single spaces).</param> /// <param name="dontWeightClasses">Determines whether 'weight-class' algorithm will be used when cleaning content.</param> /// <param name="readingStyle">Styling for the extracted article.</param> /// <param name="readingMargin">Margin for the extracted article.</param> /// <param name="readingSize">Font size for the extracted article.</param> public NReadabilityTranscoder( bool dontStripUnlikelys, bool dontNormalizeSpacesInTextContent, bool dontWeightClasses, ReadingStyle readingStyle, ReadingMargin readingMargin, ReadingSize readingSize) { _dontStripUnlikelys = dontStripUnlikelys; _dontNormalizeSpacesInTextContent = dontNormalizeSpacesInTextContent; _dontWeightClasses = dontWeightClasses; _readingStyle = readingStyle; _readingMargin = readingMargin; _readingSize = readingSize; _sgmlDomBuilder = new SgmlDomBuilder(); _sgmlDomSerializer = new SgmlDomSerializer(); _elementsScores = new Dictionary<XElement, float>(); }