From bb2863e22eab94a70e2e317c649d980c53bbaaa7 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sat, 5 Oct 2019 18:31:11 +0100 Subject: add `video` directive --- lib/WebCoso/ReST.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/WebCoso/ReST.pm b/lib/WebCoso/ReST.pm index 9cc4242..5f7f922 100644 --- a/lib/WebCoso/ReST.pm +++ b/lib/WebCoso/ReST.pm @@ -8,6 +8,8 @@ use Text::Restructured::Writer::LibXML; use Log::Log4perl ':easy'; use Encode; +Text::Restructured::Directive::handle_directive( video => \&rst_video); + sub new { my ($class,%opts)=@_; @@ -37,4 +39,20 @@ sub new { bless $self,$class; } +sub rst_video { + my($parser, $name, $parent, $source, $lineno, $dtext, $lit) = @_; + my $dhash = Text::Restructured::Directive::parse_directive($parser, $dtext, $lit, $source, $lineno); + my $options = $dhash->{options}; + my @extra_attrs = (qw(loop type)); + # a video is like an image + my $dom = Text::Restructured::Directive::image(@_,@extra_attrs); + $dom->tag('video'); + for my $attr (@extra_attrs) { + if ($options->{$attr}) { + $dom->{attr}{$attr} = $options->{$attr}; + } + } + return $dom; +} + 1; -- cgit v1.2.3