cherry-muse 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28888,17 +28888,13 @@
28888
28888
  }, {
28889
28889
  key: "$highlightCodeBlock",
28890
28890
  value: function $highlightCodeBlock(code, lang, clazz) {
28891
- var language = lang;
28892
- var cacheCode = prismCore.highlight(unescapeHTMLSpecialChar(code), prismCore.languages[language], language);
28891
+ var language = lang; // 直接使用原始代码,不做 unescapeHTMLSpecialChar,避免破坏代码完整性
28892
+
28893
+ var cacheCode = prismCore.highlight(code, prismCore.languages[language], language);
28893
28894
  cacheCode = this.renderLineNumber(cacheCode);
28894
28895
  cacheCode = this.wrapCode(cacheCode, language);
28895
- var cherry = this.$engine.$cherry; // 查找指定id
28896
-
28897
- setTimeout$1(function () {
28898
- console.log(clazz, cherry.wrapperDom.querySelectorAll(clazz), document.querySelectorAll(clazz));
28899
- }, 20000);
28900
-
28901
- this.$waitElement(clazz, 0, function (elements) {
28896
+ var cherry = this.$engine.$cherry;
28897
+ this.$waitElement(cherry.wrapperDom, clazz, 0, function (elements) {
28902
28898
  forEach$5(elements).call(elements, function (codeBlock) {
28903
28899
  codeBlock.innerHTML = cacheCode;
28904
28900
  });
@@ -28906,22 +28902,24 @@
28906
28902
  }
28907
28903
  }, {
28908
28904
  key: "$waitElement",
28909
- value: function $waitElement(clazz, times, cb) {
28910
- var that = this;
28905
+ value: function $waitElement(container, clazz, times, cb) {
28906
+ var _this2 = this;
28911
28907
 
28912
28908
  if (times > 100) {
28913
28909
  var _context21;
28914
28910
 
28915
- console.warn(concat$1(_context21 = "times ".concat(times, " milliseconds, clazz ")).call(_context21, clazz, " not found"));
28911
+ console.warn(concat$1(_context21 = "".concat(clazz, " not found after ")).call(_context21, times, " retries"));
28916
28912
  return;
28917
28913
  }
28918
28914
 
28919
- if (document.querySelectorAll(clazz).length === 0) {
28915
+ var elements = container.querySelectorAll(clazz);
28916
+
28917
+ if (elements.length === 0) {
28920
28918
  setTimeout$1(function () {
28921
- that.$waitElement(clazz, times + 1, cb);
28919
+ _this2.$waitElement(container, clazz, times + 1, cb);
28922
28920
  }, 500);
28923
28921
  } else {
28924
- cb(document.querySelectorAll(clazz));
28922
+ cb(elements);
28925
28923
  }
28926
28924
  }
28927
28925
  /**
@@ -28946,7 +28944,7 @@
28946
28944
  }, {
28947
28945
  key: "$getIndentCodeBlock",
28948
28946
  value: function $getIndentCodeBlock(str) {
28949
- var _this2 = this;
28947
+ var _this3 = this;
28950
28948
 
28951
28949
  if (!this.indentedCodeBlock) {
28952
28950
  return str;
@@ -28957,12 +28955,12 @@
28957
28955
 
28958
28956
  var lineCount = (match.match(/\n/g) || []).length;
28959
28957
 
28960
- var sign = _this2.$engine.md5(match);
28958
+ var sign = _this3.$engine.md5(match);
28961
28959
 
28962
28960
  var html = concat$1(_context22 = concat$1(_context23 = "<pre data-sign=\"".concat(sign, "\" data-lines=\"")).call(_context23, lineCount, "\"><code>")).call(_context22, escapeHTMLSpecialChar(code.replace(/\n( {4}|\t)/g, '\n')), "</code></pre>"); // return this.getCacheWithSpace(this.pushCache(html), match, true);
28963
28961
 
28964
28962
 
28965
- return prependLineFeedForParagraph(match, _this2.pushCache(html, sign, lineCount));
28963
+ return prependLineFeedForParagraph(match, _this3.pushCache(html, sign, lineCount));
28966
28964
  });
28967
28965
  }
28968
28966
  /**
@@ -29035,7 +29033,7 @@
29035
29033
  }, {
29036
29034
  key: "beforeMakeHtml",
29037
29035
  value: function beforeMakeHtml(str, sentenceMakeFunc, markdownParams) {
29038
- var _this3 = this;
29036
+ var _this4 = this;
29039
29037
 
29040
29038
  var $str = str;
29041
29039
 
@@ -29063,21 +29061,21 @@
29063
29061
 
29064
29062
  var $code = code;
29065
29063
 
29066
- var _this3$computeLines = _this3.computeLines(match, leadingContent, code),
29067
- sign = _this3$computeLines.sign,
29068
- lines = _this3$computeLines.lines; // 从缓存中获取html
29064
+ var _this4$computeLines = _this4.computeLines(match, leadingContent, code),
29065
+ sign = _this4$computeLines.sign,
29066
+ lines = _this4$computeLines.lines; // 从缓存中获取html
29069
29067
 
29070
29068
 
29071
- var cacheCode = _this3.$codeCache(sign);
29069
+ var cacheCode = _this4.$codeCache(sign);
29072
29070
 
29073
29071
  if (cacheCode && cacheCode !== '') {
29074
29072
  // 别忘了把 ">"(引用块)加回来
29075
- var _result = _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
29073
+ var _result = _this4.getCacheWithSpace(_this4.pushCache(cacheCode, sign, lines), match);
29076
29074
 
29077
29075
  return addBlockQuoteSignToResult(_result);
29078
29076
  }
29079
29077
 
29080
- $code = _this3.$recoverCodeInIndent($code);
29078
+ $code = _this4.$recoverCodeInIndent($code);
29081
29079
  $code = $code.replace(/~D/g, '$');
29082
29080
  $code = $code.replace(/~T/g, '~');
29083
29081
  /** 处理缩进 - start: 当首行反引号前存在多个空格缩进时,代码内容要相应去除相同数量的空格 */
@@ -29102,7 +29100,7 @@
29102
29100
  var $lang = trim$2(lang).call(lang); // 如果是公式关键字,则直接返回
29103
29101
 
29104
29102
 
29105
- if (/^(math|katex|latex)$/i.test($lang) && !_this3.isInternalCustomLangCovered($lang)) {
29103
+ if (/^(math|katex|latex)$/i.test($lang) && !_this4.isInternalCustomLangCovered($lang)) {
29106
29104
  var _context25;
29107
29105
 
29108
29106
  var prefix = match.match(/^\s*/g); // ~D为经编辑器中间转义后的$,code结尾包含结束```前的所有换行符,所以不需要补换行
@@ -29111,27 +29109,27 @@
29111
29109
  } // 自定义语言渲染,可覆盖内置的自定义语言逻辑
29112
29110
 
29113
29111
 
29114
- if (indexOf(_context26 = _this3.customLang).call(_context26, $lang.toLowerCase()) !== -1) {
29115
- cacheCode = _this3.parseCustomLanguage($lang, $code, {
29112
+ if (indexOf(_context26 = _this4.customLang).call(_context26, $lang.toLowerCase()) !== -1) {
29113
+ cacheCode = _this4.parseCustomLanguage($lang, $code, {
29116
29114
  lines: lines,
29117
29115
  sign: sign
29118
29116
  });
29119
29117
 
29120
29118
  if (cacheCode && cacheCode !== '') {
29121
- _this3.$codeCache(sign, cacheCode);
29119
+ _this4.$codeCache(sign, cacheCode);
29122
29120
 
29123
- return _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
29121
+ return _this4.getCacheWithSpace(_this4.pushCache(cacheCode, sign, lines), match);
29124
29122
  } // 渲染出错则按正常code进行渲染
29125
29123
 
29126
29124
  } // $code = this.$replaceSpecialChar($code);
29127
29125
 
29128
29126
 
29129
29127
  $code = $code.replace(/~X/g, '\\`');
29130
- cacheCode = _this3.renderCodeBlock($code, $lang, sign, lines);
29128
+ cacheCode = _this4.renderCodeBlock($code, $lang, sign, lines);
29131
29129
  cacheCode = cacheCode.replace(/\\/g, '\\\\');
29132
- cacheCode = _this3.$codeCache(sign, cacheCode);
29130
+ cacheCode = _this4.$codeCache(sign, cacheCode);
29133
29131
 
29134
- var result = _this3.getCacheWithSpace(_this3.pushCache(cacheCode, sign, lines), match);
29132
+ var result = _this4.getCacheWithSpace(_this4.pushCache(cacheCode, sign, lines), match);
29135
29133
 
29136
29134
  return addBlockQuoteSignToResult(result);
29137
29135
  }); // 表格里处理行内代码,让一个td里的行内代码语法生效,让跨td的行内代码语法失效
@@ -29140,7 +29138,7 @@
29140
29138
  var _context27;
29141
29139
 
29142
29140
  return map$7(_context27 = whole.split('|')).call(_context27, function (oneTd) {
29143
- return _this3.makeInlineCode(oneTd);
29141
+ return _this4.makeInlineCode(oneTd);
29144
29142
  }).join('|').replace(/`/g, '\\`');
29145
29143
  }); // 为了避免InlineCode被HtmlBlock转义,需要在这里提前缓存
29146
29144
  // InlineBlock只需要在afterMakeHtml还原即可
@@ -29153,7 +29151,7 @@
29153
29151
  }, {
29154
29152
  key: "makeInlineCode",
29155
29153
  value: function makeInlineCode(str) {
29156
- var _this4 = this;
29154
+ var _this5 = this;
29157
29155
 
29158
29156
  var $str = str;
29159
29157
 
@@ -29165,11 +29163,11 @@
29165
29163
  }
29166
29164
 
29167
29165
  var $code = code.replace(/~~not~inlineCode/g, '\\`');
29168
- $code = _this4.$replaceSpecialChar($code);
29166
+ $code = _this5.$replaceSpecialChar($code);
29169
29167
  $code = $code.replace(/\\/g, '\\\\');
29170
29168
  var html = "<code>".concat(escapeHTMLSpecialChar($code), "</code>");
29171
29169
 
29172
- var sign = _this4.$engine.md5(html);
29170
+ var sign = _this5.$engine.md5(html);
29173
29171
 
29174
29172
  CodeBlock.inlineCodeCache[sign] = html;
29175
29173
  return "~~CODE".concat(sign, "$");
@@ -68582,7 +68580,7 @@
68582
68580
  });
68583
68581
  }
68584
68582
 
68585
- var VERSION = "1.0.0-fc945743";
68583
+ var VERSION = "1.0.2-62696535";
68586
68584
  var CherryStatic = /*#__PURE__*/function () {
68587
68585
  // for type check only
68588
68586
  // TODO: fix this error