class CS50::SpoilerBlock

Public Class Methods

new(tag_name, text, tokens) click to toggle source
Calls superclass method
# File lib/jekyll-theme-cs50.rb, line 55
def initialize(tag_name, text, tokens)
  super
  @text = (text.length > 0) ? CGI.escapeHTML(text.strip().gsub(/\A"|"\Z/, "").gsub(/\A"|"\Z/, "")) : "Spoiler"
end

Public Instance Methods

render(context) click to toggle source

stackoverflow.com/q/19169849/5156190 developer.mozilla.org/en-US/docs/Web/HTML/Element/button (re phrasing, but not interactive, content)

Calls superclass method
# File lib/jekyll-theme-cs50.rb, line 62
    def render(context)
      site = context.registers[:site]
      converter = site.find_converter_instance(::Jekyll::Converters::Markdown)
      summary = Sanitize.fragment(converter.convert(@text), :elements => ["b", "code", "em", "i", "img", "span", "strong", "sub", "sup"])
      details = converter.convert(super(context))
      <<~EOT
        <details>
            <summary>#{summary}</summary>
            #{details}
        </details>
      EOT
    end