From a8317743323f02e8a8a8f981620c3fe910b5102a Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Sun, 18 Sep 2022 02:19:57 +0900 Subject: [PATCH 1/2] refactor: drop `gist` tag --- lib/plugins/tag/gist.js | 17 ----------------- lib/plugins/tag/index.js | 2 -- test/fixtures/post_render.js | 26 -------------------------- test/scripts/hexo/post.js | 17 +---------------- test/scripts/tags/gist.js | 17 ----------------- test/scripts/tags/index.js | 1 - 6 files changed, 1 insertion(+), 79 deletions(-) delete mode 100644 lib/plugins/tag/gist.js delete mode 100644 test/scripts/tags/gist.js diff --git a/lib/plugins/tag/gist.js b/lib/plugins/tag/gist.js deleted file mode 100644 index f4a11fb2d1..0000000000 --- a/lib/plugins/tag/gist.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -/** -* Gist tag -* -* Syntax: -* {% gist gist_id [filename] %} -*/ - -function gistTag(args, content) { - const id = args.shift(); - const file = args.length ? `?file=${args[0]}` : ''; - - return ``; -} - -module.exports = gistTag; diff --git a/lib/plugins/tag/index.js b/lib/plugins/tag/index.js index 842a2d6f50..56c42b2d52 100644 --- a/lib/plugins/tag/index.js +++ b/lib/plugins/tag/index.js @@ -15,8 +15,6 @@ module.exports = ctx => { tag.register('code', code, true); tag.register('codeblock', code, true); - tag.register('gist', require('./gist')); - tag.register('iframe', require('./iframe')); const img = require('./img')(ctx); diff --git a/test/fixtures/post_render.js b/test/fixtures/post_render.js index d728191b60..5bd2ebb315 100644 --- a/test/fixtures/post_render.js +++ b/test/fixtures/post_render.js @@ -72,29 +72,3 @@ exports.expected_for_issue_3346 = [ '

quote content

\n', '' ].join(''); - -exports.content_for_issue_4317 = [ - '```sh', - 'echo "Hi"', - '', - '```', - '{% gist gist_id %}', - '', - '```sh', - 'echo "Hi"', - '```', - '', - '{% gist gist_id_2 %}', - '', - '```sh', - 'echo "Hi"', - '```' -].join('\n'); - -exports.content_for_issue_4460 = [ - '```html', - '', - '', - '', - '```' -].join('\n'); diff --git a/test/scripts/hexo/post.js b/test/scripts/hexo/post.js index ccedb78a82..6ed9ec0477 100644 --- a/test/scripts/hexo/post.js +++ b/test/scripts/hexo/post.js @@ -3,7 +3,7 @@ const { join } = require('path'); const moment = require('moment'); const { readFile, mkdirs, unlink, rmdir, writeFile, exists, stat, listDir } = require('hexo-fs'); -const { highlight, escapeHTML } = require('hexo-util'); +const { highlight } = require('hexo-util'); const { spy, useFakeTimers } = require('sinon'); const { parse: yfm } = require('hexo-front-matter'); const fixture = require('../../fixtures/post_render'); @@ -1205,21 +1205,6 @@ describe('Post', () => { data.content.trim().should.eql(`

${escapeSwigTag('{{ 1 + 1 }}')} 2

`); }); - // #4317 - it('render() - issue #4317', async () => { - const content = fixture.content_for_issue_4317; - hexo.config.highlight.enable = false; - - const data = await post.render(null, { - content, - engine: 'markdown' - }); - - data.content.trim().should.contains(`
${escapeHTML('echo "Hi"')}\n
`); - data.content.trim().should.contains(''); - data.content.trim().should.contains(''); - }); - // #3543 it('render() - issue #3543', async () => { // Adopted from #3459 diff --git a/test/scripts/tags/gist.js b/test/scripts/tags/gist.js deleted file mode 100644 index 5520e82aeb..0000000000 --- a/test/scripts/tags/gist.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -const cheerio = require('cheerio'); - -describe('gist', () => { - const gist = require('../../../lib/plugins/tag/gist'); - - it('id', () => { - const $ = cheerio.load(gist(['foo'])); - $('script').attr('src').should.eql('//gist.github.com/foo.js'); - }); - - it('file', () => { - const $ = cheerio.load(gist(['foo', 'bar'])); - $('script').attr('src').should.eql('//gist.github.com/foo.js?file=bar'); - }); -}); diff --git a/test/scripts/tags/index.js b/test/scripts/tags/index.js index 0c255037cb..250c18a777 100644 --- a/test/scripts/tags/index.js +++ b/test/scripts/tags/index.js @@ -6,7 +6,6 @@ describe('Tags', () => { require('./asset_path'); require('./blockquote'); require('./code'); - require('./gist'); require('./iframe'); require('./img'); require('./include_code'); From be620555fe11d3cc5d0df3a319f320d80bc5e8f1 Mon Sep 17 00:00:00 2001 From: yoshinorin Date: Wed, 28 Sep 2022 00:32:28 +0900 Subject: [PATCH 2/2] restore needed test fixture --- test/fixtures/post_render.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/fixtures/post_render.js b/test/fixtures/post_render.js index 5bd2ebb315..f9e7351b49 100644 --- a/test/fixtures/post_render.js +++ b/test/fixtures/post_render.js @@ -72,3 +72,11 @@ exports.expected_for_issue_3346 = [ '

quote content

\n', '' ].join(''); + +exports.content_for_issue_4460 = [ + '```html', + '', + '', + '', + '```' +].join('\n');