class Jekyll::Asciinema::AsciicastTag
Implements a Liquid tag for embedding Asciicasts.
Public Instance Methods
render(_context)
click to toggle source
# File lib/jekyll/asciinema/asciicast_tag.rb, line 9 def render(_context) if (tag_contents = parse_tag(@markup.strip)) asciicast_id = tag_contents[0] render_tag(asciicast_id) else raise ArgumentError, <<-ERR_MSG.gsub(/^ {12}/, '') Syntax error in tag 'asciicast' while parsing the following markup: #{@markup} Valid syntax: {% asciicast 123456 %} ERR_MSG end end
Private Instance Methods
parse_tag(input)
click to toggle source
# File lib/jekyll/asciinema/asciicast_tag.rb, line 27 def parse_tag(input) matched = input.match(/\A\s*'?(\w+)'?\s*\Z/) [matched[1].strip] if matched && matched.length >= 2 end
render_tag(asciicast_id)
click to toggle source
# File lib/jekyll/asciinema/asciicast_tag.rb, line 32 def render_tag(asciicast_id) %(<script src="https://asciinema.org/a/#{asciicast_id}.js" id="asciicast-#{asciicast_id}" async="async"></script>) end