Fix Asciinema plugin
This commit is contained in:
parent
6522cd72d3
commit
18c0db6c4f
|
@ -312,15 +312,21 @@ plugins.factory('userPlugins', function() {
|
|||
/*
|
||||
* Asciinema plugin
|
||||
*/
|
||||
var asciinemaPlugin = new Plugin(function(message) {
|
||||
|
||||
var regexp = /^https?:\/\/(www\.)?asciinema.org\/a\/(\d+)/;
|
||||
var match = message.match(regexp);
|
||||
var asciinemaPlugin = new Plugin(urlPlugin(function(url) {
|
||||
var regexp = /^https?:\/\/(?:www\.)?asciinema.org\/a\/(\d+)/i;
|
||||
var match = url.match(regexp);
|
||||
if (match) {
|
||||
var id = match[3];
|
||||
return "<script type='text/javascript' src='https://asciinema.org/a/" + id + ".js' id='asciicast-" + id + "' async></script>";
|
||||
var id = match[1];
|
||||
return function() {
|
||||
var element = this.getElement();
|
||||
var scriptElem = document.createElement('script');
|
||||
scriptElem.src = 'https://asciinema.org/a/' + id + '.js';
|
||||
scriptElem.id = 'asciicast-' + id;
|
||||
scriptElem.async = true;
|
||||
element.appendChild(scriptElem);
|
||||
};
|
||||
}
|
||||
});
|
||||
}));
|
||||
asciinemaPlugin.name = "ascii cast";
|
||||
|
||||
var yrPlugin = new Plugin(
|
||||
|
|
Loading…
Reference in New Issue