Method: Documentation::SearchResult#excerpt_for

Defined in:
lib/documentation/search_result.rb

#excerpt_for(page) ⇒ Object

Return the highlight string for a given page



33
34
35
36
37
38
39
# File 'lib/documentation/search_result.rb', line 33

def excerpt_for(page)
  if @raw_results[page.id] && hl = @raw_results[page.id][:highlights]
    ERB::Util.html_escape((hl.join("..."))).gsub('{{{', "<mark>").gsub("}}}", "</mark>").html_safe
  else
    page.content[0,255].gsub(/[\n\r]/, '') + "..."
  end
end