Skip to content

Commit

Permalink
test(escapeTag): dont drop uncomplete tags
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Jan 14, 2024
1 parent dfe0d03 commit 8fd34c9
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/scripts/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const escapeSwigTag = str => str.replace(/{/g, '{').replace(/}/g, '}')
describe('Post', () => {
const Hexo = require('../../../dist/hexo');
const hexo = new Hexo(join(__dirname, 'post_test'));
require('../../../lib/plugins/highlight/')(hexo);
require('../../../dist/plugins/highlight/')(hexo);
const { post } = hexo;
const now = Date.now();
let clock;
Expand Down Expand Up @@ -1369,4 +1369,31 @@ describe('Post', () => {

hexo.config.syntax_highlighter = 'highlight.js';
});

// https://github.com/hexojs/hexo/issues/5301
it('render() - dont escape uncomplete tags', async () => {
const content = 'dont drop `{% }` 11111 `{# }` 22222 `{{ }` 33333';

const data = await post.render(null, {
content,
engine: 'markdown'
});

data.content.should.contains('11111');
data.content.should.contains('22222');
data.content.should.contains('33333');
data.content.should.not.contains('`'); // `
});

it('render() - uncomplete tags throw error', async () => {
const content = 'nunjucks should thorw {# } error';

try {
await post.render(null, {
content,
engine: 'markdown'
});
should.fail();
} catch (err) {}
});
});

0 comments on commit 8fd34c9

Please sign in to comment.