Comparing version 1.10.0 to 1.11.0
@@ -76,2 +76,5 @@ var Mehdown; | ||
// Imgur GIFV: http://imgur.com/blog/2014/10/09/introducing-gifv/ | ||
text = text.replace(/<a href="https?:\/\/(?:i\.)?(?:imgur\.com\/)(\w+)\.gifv">https?:\/\/(?:i\.)?(?:imgur\.com\/)(\w+)\.gifv<\/a>/gi, Mehdown.imgurGifv('$1')); | ||
// SoundCloud | ||
@@ -158,3 +161,3 @@ text = text.replace(/<a href="(https?:\/\/(?:soundcloud.com|snd.sc)\/.*)">https?:\/\/(?:soundcloud.com|snd.sc)\/.*<\/a>/gi, Mehdown.soundcloud); | ||
text = toSlug(text.replace(/<.*?>/g, '')); | ||
if (suffix) { | ||
@@ -164,3 +167,3 @@ suffix = toSlug(suffix); | ||
} | ||
return header.replace(/<h\d/, '$& id="' + text + '"'); | ||
@@ -174,2 +177,11 @@ }; | ||
Mehdown.imgurGifv = function(id) { | ||
var html = '<div class="imgur-gifv"><video autoplay loop muted>'; | ||
html += '<source type="video/webm" src="https://i.imgur.com/' + id + '.webm" />'; | ||
html += '<source type="video/mp4" src="https://i.imgur.com/' + id + '.mp4" />'; | ||
html += '</video></div>'; | ||
return html; | ||
}; | ||
Mehdown.soundcloud = function(match, url) { | ||
@@ -176,0 +188,0 @@ return '<iframe class="soundcloud" frameborder="0" src="https://w.soundcloud.com/player/?visual=true&url=' + encodeURIComponent(url) + '"></iframe>'; |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "1.10.0" | ||
"version": "1.11.0" | ||
} |
@@ -66,3 +66,3 @@ var assert = require('assert'); | ||
}); | ||
it('appends suffix to id', function() { | ||
@@ -77,3 +77,3 @@ var text = mehdown.parse('<h1>What is meh</h1>', { suffix: '012fed' }); | ||
}); | ||
it('handle header text with multiple spaces', function() { | ||
@@ -83,3 +83,3 @@ var text = mehdown.parse('<h1>What. is ! meh ?</h1>', { suffix: '0. 1! 2?f. . e! !d? ?' }); | ||
}); | ||
it('handle suffix with non alpha-numeric characters', function() { | ||
@@ -189,2 +189,9 @@ var text = mehdown.parse('<h1>a- -b?c</h1>', { suffix: '!@#$%^&*()=+`~,./;\'<>?:"[]{}|' }); | ||
describe('Imgur GIFV', function() { | ||
it('http://i.imgur.com/zvATqgs.gifv', function() { | ||
var text = mehdown.parse('<p><a href="http://i.imgur.com/zvATqgs.gifv">http://i.imgur.com/zvATqgs.gifv</a></p>'); | ||
assert.equal(text, '<p><div class="imgur-gifv"><video autoplay loop muted><source type="video/webm" src="https://i.imgur.com/zvATqgs.webm" /><source type="video/mp4" src="https://i.imgur.com/zvATqgs.mp4" /></video></div></p>'); | ||
}); | ||
}); | ||
describe('SoundCloud URLs', function() { | ||
@@ -191,0 +198,0 @@ it('https://soundcloud.com/shawnmichaelmiller/santa-claus-is-coming-to-town', function() { |
38385
394