Top Level Namespace

Defined in:

Constant Summary

CACHE_TTL = 60 * 60

Method Summary

Method Detail

def append_section(sections : Array(NamedTuple(number: String, title: String, content: String)), toc : NamedTuple(id: String, tocnumber: String, toctext: String), parser : Myhtml::Parser, article : String) #

Pushes a section of content onto the sections array. Helper function for get_article_contents. Jumps to a section noted from the table of contents to begin parsing.


[View source]
def breakpoint?(node : Myhtml::Node) #

Returns true if it looks like the current section has ended or the next section has been reached.


[View source]
def get_article_contents(url : String | Nil = nil, type : ContentType | Nil = ContentType::ParsedHTML) #

Returns the article contents as an Array of NamedTuples from the article.


[View source]
def get_article_contents_cache(url : String | Nil = nil, type : ContentType | Nil = ContentType::ParsedHTML, cache : Redis::PooledClient | Nil = nil) #

Returns article contents from cache first if available.


[View source]
def get_article_name_from_parser(parser : Myhtml::Parser) #

Returns the article name as a String from the html parser.


[View source]
def get_article_name_from_url(url : String) #

Returns the article name as a String from the url.


[View source]
def get_base_url(url : String) #

Returns the base url from the passed url.


[View source]
def get_query_parameters(params) #

Returns the query parameter values.


[View source]
def ignore?(node : Myhtml::Node) #

Returns true if the node should be ignored for text appending.


[View source]
def is_mediawiki?(parser : Myhtml::Parser) #

Returns true if the body tag of the HTML contains the mediawiki class.


[View source]
def math_element?(node : Myhtml::Node | Nil) #

Returns the math element if found in the node, else nil.


[View source]
def remove_references(inner_text : String) #

Removes all the wikipedia source references within text.


[View source]
def replace_whitespaces(inner_text : String) #

Replaces some of the whitespace with a single space.


[View source]
def skip_section?(toctext : String) #

Returns true if the string matches a section to be skipped, else false.


[View source]