From b770791b7941f39704f4a25e0eb552fc1557ff72 Mon Sep 17 00:00:00 2001
From: SukkaW <isukkaw@gmail.com>
Date: Thu, 5 Mar 2020 17:35:28 +0800
Subject: [PATCH] refactor(tag): remove unnecessary code block escape

- '{' & '}' are already escaped in backtick code filter
---
 lib/extend/tag.js | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/lib/extend/tag.js b/lib/extend/tag.js
index 883fdb5f2f..1ea58b94e5 100644
--- a/lib/extend/tag.js
+++ b/lib/extend/tag.js
@@ -4,8 +4,6 @@ const stripIndent = require('strip-indent');
 const { cyan } = require('chalk');
 const nunjucks = require('nunjucks');
 const Promise = require('bluebird');
-const placeholder = '\uFFFC';
-const rPlaceholder = /(?:<|&lt;)!--\uFFFC(\d+)--(?:>|&gt;)/g;
 
 class NunjucksTag {
   constructor(name, fn) {
@@ -228,15 +226,12 @@ class Tag {
       options = {};
     }
 
-    const cache = [];
-
-    const escapeContent = str => `<!--${placeholder}${cache.push(str) - 1}-->`;
-
-    str = str.replace(/<pre><code.*>[\s\S]*?<\/code><\/pre>/gm, escapeContent);
+    str = str.replace(/<pre.*?><code.*?>[\s\S]*?<\/code><\/pre>/gm, str => {
+      return '<!--hexoPostRenderEscape:' + str + ':hexoPostRenderEscape-->';
+    });
 
     return Promise.fromCallback(cb => { this.env.renderString(str, options, cb); })
-      .catch(err => Promise.reject(formatNunjucksError(err, str)))
-      .then(result => result.replace(rPlaceholder, (_, index) => cache[index]));
+      .catch(err => Promise.reject(formatNunjucksError(err, str)));
   }
 }