Skip to content

Commit

Permalink
Allow backtick code block in "blockquote" tag plugin (hexojs#2318).
Browse files Browse the repository at this point in the history
When backtick code block(s) exist as contents of a "blockquote" tag plugin,
each code block is translated to a string "undefined" in HTML (Issue hexojs#2318).

In analyzing markdown source text, while the replacement of these elements
with placeholders are nesting, recoveries from placeholders are executed
only once.  So I modify to repeat the recovery process until all
placeholders are recovered.
  • Loading branch information
Seaoak committed Dec 18, 2016
1 parent 1da7ad5 commit 34b1fd7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,19 @@ Post.prototype.render = function(source, data, callback) {

function tagFilter(content) {
// Replace cache data with real contents
content = content.replace(rPlaceholder, function() {
return cache[arguments[1]];
});
var isMatching;
do {
isMatching = false;
content = content.replace(rPlaceholder, function(substr, p1) {
var index = parseInt(p1);
if (! cache[index]) throw new Error('Unexpected placeholder!');
var ans = cache[index];
cache[index] = undefined;
isMatching = true;
return ans;
});
} while (isMatching);
if (cache.some(function(e, i, a) { return e !== undefined })) throw new Error('Unmatched placeholder remains!');

// Render with Nunjucks
data.content = content;
Expand Down

0 comments on commit 34b1fd7

Please sign in to comment.