blob: 898373082cdb18a4c1b78e52f95a4c283e13290b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import iframe from require 'mmm.dom'
{
{
inp: 'URL -> youtube/video'
out: 'mmm/dom'
cost: -4
transform: (link) =>
id = link\match 'youtu%.be/([^/]+)'
id or= link\match 'youtube.com/watch.*[?&]v=([^&]+)'
id or= link\match 'youtube.com/[ev]/([^/]+)'
id or= link\match 'youtube.com/embed/([^/]+)'
assert id, "couldn't parse youtube URL: '#{link}'"
iframe {
width: 560
height: 315
border: 0
frameborder: 0
allowfullscreen: true
src: "//www.youtube.com/embed/#{id}"
}
}
}
|