lib/reverse_adoc/converters/video.rb in reverse_adoc-0.3.7 vs lib/reverse_adoc/converters/video.rb in reverse_adoc-1.0.0

- old
+ new

@@ -1,34 +1,27 @@ module ReverseAdoc module Converters class Video < Base - def convert(node, state = {}) - autoplay = node['autoplay'] - loop_attr = node['loop'] - controls = node['controls'] - src = node['src'] - id = node['id'] - anchor = id ? "[[#{id}]]\n" : "" + def to_coradoc(node, _state = {}) + src = node["src"] + id = node["id"] title = extract_title(node) - title = ".#{title}\n" unless title.empty? - [anchor, title, "video::", src, "[", options(node), "]"].join("") + attributes = Coradoc::Element::AttributeList.new + options = options(node) + attributes.add_named("options", options) if options.any? + Coradoc::Element::Video.new(title, id: id, src: src, + attributes: attributes) end + def convert(node, state = {}) + Coradoc::Generator.gen_adoc(to_coradoc(node, state)) + end + def options(node) - autoplay = node['autoplay'] - loop_attr = node['loop'] - controls = node['controls'] - width = node['width'] - ret = "" - if autoplay || loop_attr || controls - out = [] - out << "autoplay" if autoplay - out << "loop" if loop_attr - out << "controls" if controls - out << "width=#{width}" if width - ret = %{options="#{out.join(',')}"} - end - ret + autoplay = node["autoplay"] + loop_attr = node["loop"] + controls = node["controls"] + [autoplay, loop_attr, controls].compact end end register :video, Video.new end