Class: CS50::SpoilerBlock
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- CS50::SpoilerBlock
- Defined in:
- lib/jekyll-theme-cs50.rb
Instance Method Summary collapse
-
#initialize(tag_name, text, tokens) ⇒ SpoilerBlock
constructor
A new instance of SpoilerBlock.
-
#render(context) ⇒ Object
stackoverflow.com/q/19169849/5156190 developer.mozilla.org/en-US/docs/Web/HTML/Element/button (re phrasing, but not interactive, content).
Constructor Details
#initialize(tag_name, text, tokens) ⇒ SpoilerBlock
Returns a new instance of SpoilerBlock.
55 56 57 58 |
# 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 |
Instance Method Details
#render(context) ⇒ Object
stackoverflow.com/q/19169849/5156190 developer.mozilla.org/en-US/docs/Web/HTML/Element/button (re phrasing, but not interactive, content)
62 63 64 65 66 67 68 69 70 71 72 73 |
# 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 |