class

Readability::Document

Inherits Reference / Object

Constants

ELEMENT_SCORES = {"div" => 5.0, "blockquote" => 3.0, "form" => -3.0, "th" => -5.0}
PARSE_OPTS = (XML::HTMLParserOptions::NODEFDTD | XML::HTMLParserOptions::NOIMPLIED) | XML::HTMLParserOptions::NOBLANKS
REGEXES = {:unlikelyCandidatesRe => /combx|comment|community|disqus|extra|foot|footer|header|menu|remark|rss|shoutbox|sidebar|sponsor|ad-break|agegate|pagination|pager|popup|search/i, :okMaybeItsACandidateRe => /and|article|body|column|main|shadow/i, :positiveRe => /article|body|content|entry|hentry|main|page|pagination|post|text|blog|story/i, :negativeRe => /combx|comment|com-|contact|foot|footer|footnote|masthead|media|meta|outbrain|promo|related|scroll|shoutbox|sidebar|sponsor|shopping|tags|tool|widget/i, :divToPElementsRe => /<(a|blockquote|dl|div|img|ol|p|pre|table|ul)/i, :replaceBrsRe => /(?<content>.*)(<br[^>]*>[ \n\r\t]*){2,}/i, :replaceFontsRe => /<(\/?)font[^>]*>/i, :trimRe => /^\s+|\s+$/, :normalizeRe => /\s{2,}/, :killBreaksRe => /(<br\s*\/?>(\s|&nbsp;?)*){1,}/, :videoRe => /http:\/\/(www\.)?(youtube|vimeo)\.com/i}
SAVE_OPTS = (XML::SaveOptions::NO_DECL | XML::SaveOptions::AS_HTML) | XML::SaveOptions::NO_EMPTY

Constructors

new(input : String, options : Readability::Options = Options.new)
Source

Class methods

css_query_to_xpath(query : String) : String

Transform the css query into an xpath query https://github.com/madeindjs/Crystagiri/blob/master/src/crystagiri/html.cr

Source
html_from_input(input, options = XML::HTMLParserOptions::NODEFDTD)
Source

Instance methods

author

Look through the @html document looking for the author Precedence Information here on the wiki: (TODO: attach wiki URL if it is accepted) Returns nil if no author is detected

Source
best_candidate_has_image
Source
best_candidate_has_image=(best_candidate_has_image : Bool)
Source
class_weight(e)
Source
clean_conditionally(node, candidates, selector)
Source
content(remove_unlikely_candidates = :default)
Source
debug(str)
Source
get_article(candidates, best_candidate)
Source
handle_exclusions!(whitelist, blacklist)
Source
html
Source
html=(html : XML::Node)
Source
meta_image
Source
options
Source
options=(options : Readability::Options)
Source
prepare_candidates

This method only touches @html instance variable

Source
remove_unlikely_candidates!
Source
sanitize(node, candidates = {} of Any => Any)
Source
score_node(elem)
Source
score_paragraphs(min_text_length : Int32) : Hash(XML::Node, Readability::NodeScore)
Source
select_best_candidate(candidates)
Source
title
Source
transform_misused_divs_into_paragraphs!
Source