Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Merge pull request #101 from lirc572/master
Browse files Browse the repository at this point in the history
add markdown support for color quotes and fix code block for {% raw %}
  • Loading branch information
ppoffice authored May 10, 2019
2 parents 29ea81e + d8b7fc0 commit 469db43
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions scripts/99_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,26 @@
*/
hexo.extend.tag.register('colorquote', function (args, content) {
var type = args[0];
return '<blockquote class="colorquote ' + type + '">' + content + '</blockquote>';
}, {ends: true});
return '<blockquote class="colorquote ' + type + '">' + hexo.render.renderSync({text: content, engine: 'markdown'}) + '</blockquote>';
}, {ends: true});

const rEscapeContent = /<escape(?:[^>]*)>([\s\S]*?)<\/escape>/g;
const placeholder = '\uFFFD';
const rPlaceholder = /(?:<|&lt;)\!--\uFFFD(\d+)--(?:>|&gt;)/g;
const cache = [];
function escapeContent(str) {
return '<!--' + placeholder + (cache.push(str) - 1) + '-->';
}
hexo.extend.filter.register('before_post_render', function(data) {
data.content = data.content.replace(rEscapeContent, function(match, content) {
return escapeContent(content);
});
return data;
});

hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(rPlaceholder, function() {
return cache[arguments[1]];
});
return data;
});

0 comments on commit 469db43

Please # to comment.