为org-mode增加video link导出html video tag
org导出html的一个难点就是内嵌视频,基本上需要通过内嵌html的方式来插入视频,像下面这样:
#+begin_export html <video class="wp-video-shortcode" width="640" height="360" preload="metadata" controls="controls"><source type="video/mp4" src="./Baby唱小金鱼.mp4" /></video> #+end_export
但是这种方式太繁琐了,不如直接自定义一个video link,在导出成html时帮我自动生成video tag片段.如下所示:
(defun org-video-link-export (path desc backend) (let ((ext (file-name-extension path))) (cond ((eq 'html backend) (format "<video preload='metadata' controls='controls'><source type='video/%s' src='%s' /></video>" ext path)) ;; fall-through case for everything else (t path)))) (org-link-set-parameters "video" :export 'org-video-link-export) (org-export-string-as "video:xxx.mp4" 'html t)
<p> <video preload='metadata' controls='controls'><source type='video/mp4' src='xxx.mp4' /></video></p>