class BookLab::SML::Rules::Video
Public Class Methods
match?(node)
click to toggle source
# File lib/booklab/sml/rules/video.rb, line 5 def self.match?(node) tag_name(node) == "video" end
to_html(node, opts = {})
click to toggle source
# File lib/booklab/sml/rules/video.rb, line 9 def self.to_html(node, opts = {}) attrs = attributes(node) return "" if attrs[:src].blank? width = attrs[:width] if width == 0 || width.blank? width = "100%" end video_attrs = html_attrs( width: width ) out = <<~HTML <video controls preload="no"#{video_attrs}> <source src="#{attrs[:src]}" type="#{attrs[:type]}"> </video> HTML out end