diff --git a/lib/plugins/tag/index.js b/lib/plugins/tag/index.js index 842a2d6f50..02f83bb470 100644 --- a/lib/plugins/tag/index.js +++ b/lib/plugins/tag/index.js @@ -29,8 +29,6 @@ module.exports = ctx => { tag.register('include_code', includeCode, {async: true}); tag.register('include-code', includeCode, {async: true}); - tag.register('jsfiddle', require('./jsfiddle')); - const link = require('./link'); tag.register('a', link); diff --git a/lib/plugins/tag/jsfiddle.js b/lib/plugins/tag/jsfiddle.js deleted file mode 100644 index bb101d6696..0000000000 --- a/lib/plugins/tag/jsfiddle.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -const { htmlTag } = require('hexo-util'); - -/** -* jsFiddle tag -* -* Syntax: -* {% jsfiddle shorttag [tabs] [skin] [height] [width] %} -*/ - -function jsfiddleTag(args) { - const id = args[0]; - const tabs = args[1] && args[1] !== 'default' ? args[1] : 'js,resources,html,css,result'; - const skin = args[2] && args[2] !== 'default' ? args[2] : 'light'; - const width = args[3] && args[3] !== 'default' ? args[3] : '100%'; - const height = args[4] && args[4] !== 'default' ? args[4] : '300'; - const src = `https://jsfiddle.net/${id}/embedded/${tabs}/${skin}`; - - const attrs = { - scrolling: 'no', - width, - height, - src, - frameborder: '0', - loading: 'lazy', - allowfullscreen: true - }; - - return htmlTag('iframe', attrs, ''); -} - -module.exports = jsfiddleTag; diff --git a/test/scripts/tags/index.js b/test/scripts/tags/index.js index 0c255037cb..1aaf2a23be 100644 --- a/test/scripts/tags/index.js +++ b/test/scripts/tags/index.js @@ -10,7 +10,6 @@ describe('Tags', () => { require('./iframe'); require('./img'); require('./include_code'); - require('./jsfiddle'); require('./link'); require('./post_link'); require('./post_path'); diff --git a/test/scripts/tags/jsfiddle.js b/test/scripts/tags/jsfiddle.js deleted file mode 100644 index 9ca63a368c..0000000000 --- a/test/scripts/tags/jsfiddle.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -const cheerio = require('cheerio'); - -describe('jsfiddle', () => { - const jsfiddle = require('../../../lib/plugins/tag/jsfiddle'); - - it('id', () => { - const $ = cheerio.load(jsfiddle(['foo'])); - - $('iframe').attr('src').should.eql('https://jsfiddle.net/foo/embedded/js,resources,html,css,result/light'); - }); - - it('tabs', () => { - let $ = cheerio.load(jsfiddle(['foo', 'default'])); - - $('iframe').attr('src').should.eql('https://jsfiddle.net/foo/embedded/js,resources,html,css,result/light'); - - $ = cheerio.load(jsfiddle(['foo', 'html,css'])); - - $('iframe').attr('src').should.eql('https://jsfiddle.net/foo/embedded/html,css/light'); - }); - - it('skin', () => { - let $ = cheerio.load(jsfiddle(['foo', 'default', 'default'])); - - $('iframe').attr('src').should.eql('https://jsfiddle.net/foo/embedded/js,resources,html,css,result/light'); - - $ = cheerio.load(jsfiddle(['foo', 'default', 'dark'])); - - $('iframe').attr('src').should.eql('https://jsfiddle.net/foo/embedded/js,resources,html,css,result/dark'); - }); - - it('width', () => { - let $ = cheerio.load(jsfiddle(['foo', 'default', 'default', 'default'])); - - $('iframe').attr('width').should.eql('100%'); - - $ = cheerio.load(jsfiddle(['foo', 'default', 'default', '500'])); - - $('iframe').attr('width').should.eql('500'); - }); - - it('height', () => { - let $ = cheerio.load(jsfiddle(['foo', 'default', 'default', 'default', 'default'])); - - $('iframe').attr('height').should.eql('300'); - - $ = cheerio.load(jsfiddle(['foo', 'default', 'default', 'default', '500'])); - - $('iframe').attr('height').should.eql('500'); - }); -});