class RDoc::Generator::Darkfish
def excerpt(content)
def excerpt(content) text = case content when RDoc::Comment content.text when RDoc::Markup::Document # This case is for page files that are not markdown nor rdoc # We convert them to markdown for now as it's easier to extract the text formatter = RDoc::Markup::ToMarkdown.new formatter.start_accepting formatter.accept_document(content) formatter.end_accepting else content end # Match from a capital letter to the first period, discarding any links, so # that we don't end up matching badges in the README first_paragraph_match = text.match(/[A-Z][^\.:\/]+\./) return text[0...150].gsub(/\n/, " ").squeeze(" ") unless first_paragraph_match extracted_text = first_paragraph_match[0] second_paragraph = first_paragraph_match.post_match.match(/[A-Z][^\.:\/]+\./) extracted_text << " " << second_paragraph[0] if second_paragraph extracted_text[0...150].gsub(/\n/, " ").squeeze(" ") end