/// <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> private 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>(); }
/// <summary> /// Initializes a new instance of NReadabilityTranscoder. Allows setting reading options. /// </summary> /// <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(ReadingStyle readingStyle, ReadingMargin readingMargin, ReadingSize readingSize) : this(false, false, false, readingStyle, readingMargin, readingSize) { }
private string GetReadingStyleClass(ReadingStyle readingStyle) { return GetUserStyleClass("style", readingStyle.ToString()); }
/// <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> /// <param name="articleElementHints">Hints for sites with difficult to find article bodies, in form of a dictionary of a regex matching the url of the content and the selector for the element containing the article</param> public NReadabilityTranscoder( bool dontStripUnlikelys, bool dontNormalizeSpacesInTextContent, bool dontWeightClasses, ReadingStyle readingStyle, ReadingMargin readingMargin, ReadingSize readingSize, IDictionary<Regex, string> articleElementHints) : this(dontStripUnlikelys, dontNormalizeSpacesInTextContent, dontWeightClasses, readingStyle, readingMargin, readingSize) { if (articleElementHints != null) { foreach (var kvp in articleElementHints) { _articleContentElementHints[kvp.Key] = kvp.Value; } } }