module GithubToCanvasQuiz::Parser::Canvas::Helpers

Public Instance Methods

choose_text(text, html) click to toggle source
# File lib/github_to_canvas_quiz/parser/canvas/helpers.rb, line 7
def choose_text(text, html)
  html.empty? ? text : clean_html(html)
end
clean_html(html) click to toggle source
# File lib/github_to_canvas_quiz/parser/canvas/helpers.rb, line 11
def clean_html(html)
  html = remove_canvas_cruft(html)
  HTMLEntities.new.decode(html)
end
remove_canvas_cruft(html) click to toggle source
# File lib/github_to_canvas_quiz/parser/canvas/helpers.rb, line 16
def remove_canvas_cruft(html)
  nodes = Nokogiri::HTML5.fragment(html)
  nodes.css('.screenreader-only').remove
  cleaned_html = nodes.to_html
  cleaned_html.gsub(/\(?Links to an external site.\)?/, '')
end