cherry-muse 1.0.3 → 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.
@@ -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 = prismCore.highlight(code, prismCore.languages[language], language);
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
- cacheCode = _this4.$codeCache(sign, cacheCode);
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, _context4;
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 = 1;
32428
- var level = 0;
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 handledHtml = concat$1(_context = concat$1(_context2 = "<blockquote data-sign=\"".concat(sign, "_")).call(_context2, lineCount, "\" data-lines=\"")).call(_context, lineCount, "\">");
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
- level = leadSymbols.length;
32516
+ currentLevel = leadSymbols.length;
32450
32517
  } else {
32451
32518
  // 否则保持当前缩进层级
32452
- level = lastLevel;
32519
+ currentLevel = lastLevel;
32453
32520
  }
32454
32521
 
32455
32522
  return '';
32456
32523
  }); // 同层级,且不为首行时补充一个换行
32457
32524
 
32458
- if (lastLevel === level && i !== 0) {
32459
- handledHtml += '<br>';
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 < level) {
32464
- var _context3;
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
- handledHtml += repeat$1(_context3 = '<blockquote>').call(_context3, level - lastLevel);
32467
- lastLevel = level;
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
- handledHtml += repeat$1(_context4 = '</blockquote>').call(_context4, lastLevel);
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
  }
@@ -68137,8 +68237,7 @@
68137
68237
  // The locale Cherry is going to use. Locales live in /src/locales/
68138
68238
  locale: 'zh_CN',
68139
68239
  // cherry初始化后是否检查 location.hash 尝试滚动到对应位置
68140
- autoScrollByHashAfterInit: true,
68141
- stats: true
68240
+ autoScrollByHashAfterInit: true
68142
68241
  };
68143
68242
 
68144
68243
  if (window.outerWidth <= 600) {
@@ -68580,7 +68679,7 @@
68580
68679
  });
68581
68680
  }
68582
68681
 
68583
- var VERSION = "1.0.2-62696535";
68682
+ var VERSION = "1.0.4-0006dc04";
68584
68683
  var CherryStatic = /*#__PURE__*/function () {
68585
68684
  // for type check only
68586
68685
  // TODO: fix this error
@@ -69202,8 +69301,6 @@
69202
69301
  _classCallCheck(this, Stats);
69203
69302
 
69204
69303
  this.$cherry = options.$cherry;
69205
- console.log(options);
69206
- if (!this.$cherry.options.stats) return;
69207
69304
  this.container = null;
69208
69305
  this.stats = {
69209
69306
  characters: 0,