cherry-muse 1.0.4 → 1.0.5
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.
- package/dist/cherry-markdown.core.js +1 -1
- package/dist/cherry-markdown.engine.core.esm.js +1 -1
- package/dist/cherry-markdown.engine.core.js +1 -1
- package/dist/cherry-markdown.esm.js +1 -1
- package/dist/cherry-markdown.js +118 -18
- package/dist/cherry-markdown.js.map +1 -1
- package/dist/cherry-markdown.min.js +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/src/core/hooks/Blockquote.js +82 -12
- package/src/core/hooks/CodeBlock.js +21 -2
- package/src/core/hooks/List.js +1 -1
- package/examples/scripts/pinyin/README.md +0 -53
- package/tools/README.md +0 -3
package/dist/cherry-markdown.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document);
|
|
1
3
|
(function (global, factory) {
|
|
2
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
5
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
@@ -28864,6 +28866,9 @@
|
|
|
28864
28866
|
if (prismCore.languages[lang]) {
|
|
28865
28867
|
cacheCode = prismCore.highlight(cacheCode, prismCore.languages[lang], lang);
|
|
28866
28868
|
cacheCode = this.renderLineNumber(cacheCode);
|
|
28869
|
+
} else if (lang === 'text') {
|
|
28870
|
+
cacheCode = escapeHTMLSpecialChar(cacheCode);
|
|
28871
|
+
cacheCode = this.renderLineNumber(cacheCode);
|
|
28867
28872
|
} else {
|
|
28868
28873
|
cacheCode = escapeHTMLSpecialChar(cacheCode);
|
|
28869
28874
|
prismCore.plugins.autoloader.loadLanguages([lang], function () {
|
|
@@ -28890,7 +28895,14 @@
|
|
|
28890
28895
|
value: function $highlightCodeBlock(code, lang, clazz) {
|
|
28891
28896
|
var language = lang; // 直接使用原始代码,不做 unescapeHTMLSpecialChar,避免破坏代码完整性
|
|
28892
28897
|
|
|
28893
|
-
var cacheCode
|
|
28898
|
+
var cacheCode;
|
|
28899
|
+
|
|
28900
|
+
if (prismCore.languages[language]) {
|
|
28901
|
+
cacheCode = prismCore.highlight(code, prismCore.languages[language], language);
|
|
28902
|
+
} else {
|
|
28903
|
+
cacheCode = escapeHTMLSpecialChar(code);
|
|
28904
|
+
}
|
|
28905
|
+
|
|
28894
28906
|
cacheCode = this.renderLineNumber(cacheCode);
|
|
28895
28907
|
cacheCode = this.wrapCode(cacheCode, language);
|
|
28896
28908
|
var cherry = this.$engine.$cherry;
|
|
@@ -29124,10 +29136,21 @@
|
|
|
29124
29136
|
} // $code = this.$replaceSpecialChar($code);
|
|
29125
29137
|
|
|
29126
29138
|
|
|
29127
|
-
$code = $code.replace(/~X/g, '\\`');
|
|
29139
|
+
$code = $code.replace(/~X/g, '\\`'); // 判断是否需要异步渲染,如果需要异步渲染则不缓存
|
|
29140
|
+
|
|
29141
|
+
var effectiveLang = $lang;
|
|
29142
|
+
|
|
29143
|
+
if (!includes(supportLanguages).call(supportLanguages, effectiveLang)) {
|
|
29144
|
+
effectiveLang = 'text';
|
|
29145
|
+
}
|
|
29146
|
+
|
|
29147
|
+
var isAsync = !_this4.customHighlighter && !prismCore.languages[effectiveLang] && effectiveLang !== 'text';
|
|
29128
29148
|
cacheCode = _this4.renderCodeBlock($code, $lang, sign, lines);
|
|
29129
29149
|
cacheCode = cacheCode.replace(/\\/g, '\\\\');
|
|
29130
|
-
|
|
29150
|
+
|
|
29151
|
+
if (!isAsync) {
|
|
29152
|
+
cacheCode = _this4.$codeCache(sign, cacheCode);
|
|
29153
|
+
}
|
|
29131
29154
|
|
|
29132
29155
|
var result = _this4.getCacheWithSpace(_this4.pushCache(cacheCode, sign, lines), match);
|
|
29133
29156
|
|
|
@@ -32359,7 +32382,7 @@
|
|
|
32359
32382
|
var ret = {
|
|
32360
32383
|
begin: '(?:^|\n)(\n*)(([ ]{0,3}([*+-]|\\d+[.]|[a-z]\\.|[I一二三四五六七八九十]+\\.)[ \\t]+)',
|
|
32361
32384
|
content: '([^\\r]+?)',
|
|
32362
|
-
end: '(~0|\\n{2,}(?=\\S)(?![ \\t]*(?:[*+-]|\\d+[.]|[a-z]\\.|[I一二三四五六七八九十]+\\.)[ \\t]+)))'
|
|
32385
|
+
end: '(~0|(?=\\n[ \\t]*(?::::|\\+\\+))|\\n{2,}(?=\\S)(?![ \\t]*(?:[*+-]|\\d+[.]|[a-z]\\.|[I一二三四五六七八九十]+\\.)[ \\t]+)))'
|
|
32363
32386
|
};
|
|
32364
32387
|
ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'gm');
|
|
32365
32388
|
return ret;
|
|
@@ -32402,12 +32425,51 @@
|
|
|
32402
32425
|
}
|
|
32403
32426
|
|
|
32404
32427
|
_createClass(Blockquote, [{
|
|
32428
|
+
key: "getAlertInfo",
|
|
32429
|
+
value: function getAlertInfo(line) {
|
|
32430
|
+
var match = line.match(/^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i);
|
|
32431
|
+
|
|
32432
|
+
if (match) {
|
|
32433
|
+
return {
|
|
32434
|
+
type: match[1].toUpperCase(),
|
|
32435
|
+
remaining: line.replace(/^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/i, '')
|
|
32436
|
+
};
|
|
32437
|
+
}
|
|
32438
|
+
|
|
32439
|
+
return null;
|
|
32440
|
+
}
|
|
32441
|
+
}, {
|
|
32442
|
+
key: "getPanelClass",
|
|
32443
|
+
value: function getPanelClass(type) {
|
|
32444
|
+
var map = {
|
|
32445
|
+
NOTE: 'note',
|
|
32446
|
+
TIP: 'tip',
|
|
32447
|
+
IMPORTANT: 'important',
|
|
32448
|
+
WARNING: 'warning',
|
|
32449
|
+
CAUTION: 'danger'
|
|
32450
|
+
};
|
|
32451
|
+
var t = map[type] || 'note';
|
|
32452
|
+
return "cherry-panel cherry-panel__".concat(t);
|
|
32453
|
+
}
|
|
32454
|
+
}, {
|
|
32455
|
+
key: "getPanelTitle",
|
|
32456
|
+
value: function getPanelTitle(type) {
|
|
32457
|
+
var map = {
|
|
32458
|
+
NOTE: 'Note',
|
|
32459
|
+
TIP: 'Tip',
|
|
32460
|
+
IMPORTANT: 'Important',
|
|
32461
|
+
WARNING: 'Warning',
|
|
32462
|
+
CAUTION: 'Caution'
|
|
32463
|
+
};
|
|
32464
|
+
return map[type] || type;
|
|
32465
|
+
}
|
|
32466
|
+
}, {
|
|
32405
32467
|
key: "handleMatch",
|
|
32406
32468
|
value: function handleMatch(str, sentenceMakeFunc) {
|
|
32407
32469
|
var _this = this;
|
|
32408
32470
|
|
|
32409
32471
|
return str.replace(this.RULE.reg, function (match, lines, content) {
|
|
32410
|
-
var _context, _context2
|
|
32472
|
+
var _context, _context2;
|
|
32411
32473
|
|
|
32412
32474
|
var _sentenceMakeFunc = sentenceMakeFunc(content),
|
|
32413
32475
|
contentSign = _sentenceMakeFunc.sign,
|
|
@@ -32424,10 +32486,14 @@
|
|
|
32424
32486
|
var contentLines = parsedHtml.split('\n');
|
|
32425
32487
|
var replaceReg = /^[>\s]+/;
|
|
32426
32488
|
var countReg = />/g;
|
|
32427
|
-
var lastLevel =
|
|
32428
|
-
var
|
|
32489
|
+
var lastLevel = 0;
|
|
32490
|
+
var handledHtml = '';
|
|
32491
|
+
var tagStack = [];
|
|
32492
|
+
|
|
32493
|
+
var rootAttrs = concat$1(_context = concat$1(_context2 = " data-sign=\"".concat(sign, "_")).call(_context2, lineCount, "\" data-lines=\"")).call(_context, lineCount, "\"");
|
|
32429
32494
|
|
|
32430
|
-
var
|
|
32495
|
+
var isRoot = true;
|
|
32496
|
+
var skipNextBr = false;
|
|
32431
32497
|
|
|
32432
32498
|
for (var i = 0; contentLines[i]; i++) {
|
|
32433
32499
|
if (i !== 0) {
|
|
@@ -32442,29 +32508,60 @@
|
|
|
32442
32508
|
/* eslint-disable no-loop-func */
|
|
32443
32509
|
|
|
32444
32510
|
|
|
32511
|
+
var currentLevel = 0;
|
|
32445
32512
|
var $line = contentLines[i].replace(replaceReg, function (leadSymbol) {
|
|
32446
32513
|
var leadSymbols = leadSymbol.match(countReg); // 本行引用嵌套层级比上层要多
|
|
32447
32514
|
|
|
32448
32515
|
if (leadSymbols && leadSymbols.length > lastLevel) {
|
|
32449
|
-
|
|
32516
|
+
currentLevel = leadSymbols.length;
|
|
32450
32517
|
} else {
|
|
32451
32518
|
// 否则保持当前缩进层级
|
|
32452
|
-
|
|
32519
|
+
currentLevel = lastLevel;
|
|
32453
32520
|
}
|
|
32454
32521
|
|
|
32455
32522
|
return '';
|
|
32456
32523
|
}); // 同层级,且不为首行时补充一个换行
|
|
32457
32524
|
|
|
32458
|
-
if (lastLevel ===
|
|
32459
|
-
|
|
32525
|
+
if (lastLevel === currentLevel && i !== 0) {
|
|
32526
|
+
if (!skipNextBr) {
|
|
32527
|
+
handledHtml += '<br>';
|
|
32528
|
+
}
|
|
32529
|
+
|
|
32530
|
+
skipNextBr = false;
|
|
32460
32531
|
} // 补充缩进
|
|
32461
32532
|
|
|
32462
32533
|
|
|
32463
|
-
if (lastLevel <
|
|
32464
|
-
var
|
|
32534
|
+
if (lastLevel < currentLevel) {
|
|
32535
|
+
for (var l = lastLevel + 1; l <= currentLevel; l++) {
|
|
32536
|
+
var tagOpen = "<blockquote".concat(isRoot ? rootAttrs : '', ">");
|
|
32537
|
+
var tagClose = '</blockquote>'; // Check for Alert
|
|
32538
|
+
|
|
32539
|
+
if (l === currentLevel) {
|
|
32540
|
+
var alertInfo = _this.getAlertInfo($line);
|
|
32541
|
+
|
|
32542
|
+
if (alertInfo) {
|
|
32543
|
+
var _context3, _context4;
|
|
32465
32544
|
|
|
32466
|
-
|
|
32467
|
-
|
|
32545
|
+
var className = _this.getPanelClass(alertInfo.type);
|
|
32546
|
+
|
|
32547
|
+
var title = _this.getPanelTitle(alertInfo.type);
|
|
32548
|
+
|
|
32549
|
+
tagOpen = concat$1(_context3 = concat$1(_context4 = "<div class=\"".concat(className, "\"")).call(_context4, isRoot ? rootAttrs : '', "><div class=\"cherry-panel--title cherry-panel--title__not-empty\">")).call(_context3, title, "</div><div class=\"cherry-panel--body\"><p>");
|
|
32550
|
+
tagClose = '</p></div></div>';
|
|
32551
|
+
$line = alertInfo.remaining;
|
|
32552
|
+
|
|
32553
|
+
if (trim$2($line).call($line) === '') {
|
|
32554
|
+
skipNextBr = true;
|
|
32555
|
+
}
|
|
32556
|
+
}
|
|
32557
|
+
}
|
|
32558
|
+
|
|
32559
|
+
handledHtml += tagOpen;
|
|
32560
|
+
tagStack.push(tagClose);
|
|
32561
|
+
isRoot = false;
|
|
32562
|
+
}
|
|
32563
|
+
|
|
32564
|
+
lastLevel = currentLevel;
|
|
32468
32565
|
} // 插入当前行内容
|
|
32469
32566
|
|
|
32470
32567
|
|
|
@@ -32472,7 +32569,10 @@
|
|
|
32472
32569
|
} // 标签闭合
|
|
32473
32570
|
|
|
32474
32571
|
|
|
32475
|
-
|
|
32572
|
+
while (tagStack.length) {
|
|
32573
|
+
handledHtml += tagStack.pop();
|
|
32574
|
+
}
|
|
32575
|
+
|
|
32476
32576
|
return _this.getCacheWithSpace(_this.pushCache(handledHtml, sign, lineCount), match);
|
|
32477
32577
|
});
|
|
32478
32578
|
}
|
|
@@ -68579,7 +68679,7 @@
|
|
|
68579
68679
|
});
|
|
68580
68680
|
}
|
|
68581
68681
|
|
|
68582
|
-
var VERSION = "1.0.
|
|
68682
|
+
var VERSION = "1.0.4-0006dc04";
|
|
68583
68683
|
var CherryStatic = /*#__PURE__*/function () {
|
|
68584
68684
|
// for type check only
|
|
68585
68685
|
// TODO: fix this error
|