marked 7.0.2 → 7.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.
package/lib/marked.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * marked v7.0.2 - a markdown parser
2
+ * marked v7.0.3 - a markdown parser
3
3
  * Copyright (c) 2011-2023, Christopher Jeffrey. (MIT Licensed)
4
4
  * https://github.com/markedjs/marked
5
5
  */
@@ -836,7 +836,8 @@ class _Tokenizer {
836
836
  return;
837
837
  const nextChar = match[1] || match[2] || '';
838
838
  if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
839
- const lLength = match[0].length - 1;
839
+ // unicode Regex counts emoji as 1 char; spread into array for proper count (used multiple times below)
840
+ const lLength = [...match[0]].length - 1;
840
841
  let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
841
842
  const endReg = match[0][0] === '*' ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd;
842
843
  endReg.lastIndex = 0;
@@ -846,7 +847,7 @@ class _Tokenizer {
846
847
  rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
847
848
  if (!rDelim)
848
849
  continue; // skip single * in __abc*abc__
849
- rLength = rDelim.length;
850
+ rLength = [...rDelim].length;
850
851
  if (match[3] || match[4]) { // found another Left Delim
851
852
  delimTotal += rLength;
852
853
  continue;
@@ -862,7 +863,7 @@ class _Tokenizer {
862
863
  continue; // Haven't found enough closing delimiters
863
864
  // Remove extra characters. *a*** -> *a*
864
865
  rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
865
- const raw = src.slice(0, lLength + match.index + rLength + 1);
866
+ const raw = [...src].slice(0, lLength + match.index + rLength + 1).join('');
866
867
  // Create `em` if smallest delimiter has odd char count. *a***
867
868
  if (Math.min(lLength, rLength) % 2) {
868
869
  const text = raw.slice(1, -1);