redcarpet_yt 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/redcarpet_yt.rb +8 -1
- data/redcarpet_yt.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dce6c9b261f147d9e01b94246db917b5b104e1e
|
4
|
+
data.tar.gz: 5b74a1e3f088a3af193fd93819e541108b749225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 070be3ae71e7723e8337dd9d992a71a3bd3d9cbf831a74bdd59921b6f8bde83084729c59de103f6548c2c6a1732c950080cc3e7e06387163c55ba8cefbea7e66
|
7
|
+
data.tar.gz: d1839308bb67e393755df209c132a87afb5e7e8f23a730320e75ee3d0a5bf99caaa87b95cbb5fdbd5c3d201eb1e4b477ce04304c678e337372f85223d464d2cb
|
data/lib/redcarpet_yt.rb
CHANGED
@@ -14,11 +14,18 @@ module Redcarpet
|
|
14
14
|
def image(link, title, content)
|
15
15
|
# Check if we have a YouTube video
|
16
16
|
if link.match /((http(s)?:\/\/)?)(www\.)?((youtube\.com\/)|(youtu.be\/))[\S]+/
|
17
|
-
|
17
|
+
id = get_youtube_video_id(link)
|
18
|
+
'<iframe width="420" height="315" src="//www.youtube.com/embed/'+id+'" frameborder="0" allowfullscreen></iframe>'
|
18
19
|
else
|
19
20
|
'<img src="'+link+'" title="'+title+'" alt="'+content+'">'
|
20
21
|
end
|
21
22
|
end
|
23
|
+
|
24
|
+
def get_youtube_video_id (url)
|
25
|
+
regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
26
|
+
match = url.match(regExp)
|
27
|
+
return match[2]
|
28
|
+
end
|
22
29
|
end
|
23
30
|
|
24
31
|
# XHTML Renderer
|
data/redcarpet_yt.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'redcarpet_yt'
|
4
|
-
s.version = '0.0.
|
4
|
+
s.version = '0.0.4'
|
5
5
|
s.summary = "Markdown that smells nice, now with YouTube embedding"
|
6
6
|
s.description = 'A fast, safe and extensible Markdown to (X)HTML parser, with YouTube embedding, based on Redcarpet'
|
7
7
|
s.date = '2016-03-31'
|