@limetech/lime-elements 39.34.1 → 39.34.2

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.
@@ -2,9 +2,9 @@
2
2
 
3
3
  var index$1 = require('./index-8x93m5oI.js');
4
4
  var types = require('./types-Bu6wcdI0.js');
5
- var markdownParser = require('./markdown-parser-ZtNkFlPt.js');
5
+ var markdownParser = require('./markdown-parser-F3YRMjcy.js');
6
6
  var cloneDeep = require('./cloneDeep-hE40Q8aw.js');
7
- var index = require('./index-BgFEL6FF.js');
7
+ var index = require('./index-ETPz91V5.js');
8
8
  var translations = require('./translations-VEsa81QY.js');
9
9
  var randomString = require('./random-string-BTzDB2ee.js');
10
10
  var isItem = require('./is-item-DMELyaao.js');
@@ -16615,6 +16615,10 @@ function isPunctChar (ch) {
16615
16615
  return P.test(ch) || regex.test(ch)
16616
16616
  }
16617
16617
 
16618
+ function isPunctCharCode (code) {
16619
+ return isPunctChar(fromCodePoint(code))
16620
+ }
16621
+
16618
16622
  // Markdown ASCII punctuation characters.
16619
16623
  //
16620
16624
  // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
@@ -16676,6 +16680,7 @@ function normalizeReference (str) {
16676
16680
  // (remove this when node v10 is no longer supported).
16677
16681
  //
16678
16682
  if ('ẞ'.toLowerCase() === 'Ṿ') {
16683
+ /* c8 ignore next 2 */
16679
16684
  str = str.replace(/ẞ/g, 'ß');
16680
16685
  }
16681
16686
 
@@ -16714,6 +16719,28 @@ function normalizeReference (str) {
16714
16719
  return str.toLowerCase().toUpperCase()
16715
16720
  }
16716
16721
 
16722
+ function isAsciiTrimmable (c) {
16723
+ return c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d
16724
+ }
16725
+
16726
+ // "Light" .trim() for blocks (headers, paragraphs), where unicode spaces
16727
+ // should be preserved.
16728
+ function asciiTrim (str) {
16729
+ let start = 0;
16730
+ for (; start < str.length; start++) {
16731
+ if (!isAsciiTrimmable(str.charCodeAt(start))) {
16732
+ break
16733
+ }
16734
+ }
16735
+ let end = str.length - 1;
16736
+ for (; end >= start; end--) {
16737
+ if (!isAsciiTrimmable(str.charCodeAt(end))) {
16738
+ break
16739
+ }
16740
+ }
16741
+ return str.slice(start, end + 1)
16742
+ }
16743
+
16717
16744
  // Re-export libraries commonly used in both markdown-it and its plugins,
16718
16745
  // so plugins won't have to depend on them explicitly, which reduces their
16719
16746
  // bundled size (e.g. a browser build).
@@ -16723,6 +16750,7 @@ const lib = { mdurl, ucmicro };
16723
16750
  var utils = /*#__PURE__*/Object.freeze({
16724
16751
  __proto__: null,
16725
16752
  arrayReplaceAt: arrayReplaceAt,
16753
+ asciiTrim: asciiTrim,
16726
16754
  assign: assign$1,
16727
16755
  escapeHtml: escapeHtml,
16728
16756
  escapeRE: escapeRE$1,
@@ -16730,6 +16758,7 @@ var utils = /*#__PURE__*/Object.freeze({
16730
16758
  has: has,
16731
16759
  isMdAsciiPunct: isMdAsciiPunct,
16732
16760
  isPunctChar: isPunctChar,
16761
+ isPunctCharCode: isPunctCharCode,
16733
16762
  isSpace: isSpace,
16734
16763
  isString: isString$1,
16735
16764
  isValidEntityCode: isValidEntityCode,
@@ -18093,14 +18122,36 @@ const QUOTE_TEST_RE = /['"]/;
18093
18122
  const QUOTE_RE = /['"]/g;
18094
18123
  const APOSTROPHE = '\u2019'; /* ’ */
18095
18124
 
18096
- function replaceAt (str, index, ch) {
18097
- return str.slice(0, index) + ch + str.slice(index + 1)
18125
+ function addReplacement (replacements, tokenIdx, pos, ch) {
18126
+ if (!replacements[tokenIdx]) {
18127
+ replacements[tokenIdx] = [];
18128
+ }
18129
+
18130
+ replacements[tokenIdx].push({ pos, ch });
18131
+ }
18132
+
18133
+ function applyReplacements (str, replacements) {
18134
+ let result = '';
18135
+ let lastPos = 0;
18136
+
18137
+ replacements.sort((a, b) => a.pos - b.pos);
18138
+
18139
+ for (let i = 0; i < replacements.length; i++) {
18140
+ const replacement = replacements[i];
18141
+
18142
+ result += str.slice(lastPos, replacement.pos) + replacement.ch;
18143
+ lastPos = replacement.pos + 1;
18144
+ }
18145
+
18146
+ return result + str.slice(lastPos)
18098
18147
  }
18099
18148
 
18100
18149
  function process_inlines (tokens, state) {
18101
18150
  let j;
18102
18151
 
18103
18152
  const stack = [];
18153
+ // token index -> list of replacements in the original token content
18154
+ const replacements = {};
18104
18155
 
18105
18156
  for (let i = 0; i < tokens.length; i++) {
18106
18157
  const token = tokens[i];
@@ -18114,9 +18165,9 @@ function process_inlines (tokens, state) {
18114
18165
 
18115
18166
  if (token.type !== 'text') { continue }
18116
18167
 
18117
- let text = token.content;
18168
+ const text = token.content;
18118
18169
  let pos = 0;
18119
- let max = text.length;
18170
+ const max = text.length;
18120
18171
 
18121
18172
  /* eslint no-labels:0,block-scoped-var:0 */
18122
18173
  OUTER:
@@ -18164,8 +18215,8 @@ function process_inlines (tokens, state) {
18164
18215
  }
18165
18216
  }
18166
18217
 
18167
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
18168
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
18218
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
18219
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
18169
18220
 
18170
18221
  const isLastWhiteSpace = isWhiteSpace(lastChar);
18171
18222
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -18208,7 +18259,7 @@ function process_inlines (tokens, state) {
18208
18259
  if (!canOpen && !canClose) {
18209
18260
  // middle of word
18210
18261
  if (isSingle) {
18211
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
18262
+ addReplacement(replacements, i, t.index, APOSTROPHE);
18212
18263
  }
18213
18264
  continue
18214
18265
  }
@@ -18231,18 +18282,8 @@ function process_inlines (tokens, state) {
18231
18282
  closeQuote = state.md.options.quotes[1];
18232
18283
  }
18233
18284
 
18234
- // replace token.content *before* tokens[item.token].content,
18235
- // because, if they are pointing at the same token, replaceAt
18236
- // could mess up indices when quote length != 1
18237
- token.content = replaceAt(token.content, t.index, closeQuote);
18238
- tokens[item.token].content = replaceAt(
18239
- tokens[item.token].content, item.pos, openQuote);
18240
-
18241
- pos += closeQuote.length - 1;
18242
- if (item.token === i) { pos += openQuote.length - 1; }
18243
-
18244
- text = token.content;
18245
- max = text.length;
18285
+ addReplacement(replacements, i, t.index, closeQuote);
18286
+ addReplacement(replacements, item.token, item.pos, openQuote);
18246
18287
 
18247
18288
  stack.length = j;
18248
18289
  continue OUTER
@@ -18258,10 +18299,14 @@ function process_inlines (tokens, state) {
18258
18299
  level: thisLevel
18259
18300
  });
18260
18301
  } else if (canClose && isSingle) {
18261
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
18302
+ addReplacement(replacements, i, t.index, APOSTROPHE);
18262
18303
  }
18263
18304
  }
18264
18305
  }
18306
+
18307
+ Object.keys(replacements).forEach(function (tokenIdx) {
18308
+ tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
18309
+ });
18265
18310
  }
18266
18311
 
18267
18312
  function smartquotes (state) {
@@ -19865,11 +19910,22 @@ function html_block (state, startLine, endLine, silent) {
19865
19910
 
19866
19911
  let nextLine = startLine + 1;
19867
19912
 
19913
+ // Block types 6 and 7 (the only ones whose end condition is a blank line)
19914
+ // have `/^$/` as their closing regexp. For all other types (1-5, e.g.
19915
+ // `<!--` comments), a blank line is regular content and must not terminate
19916
+ // the block - it ends only when its closing sequence is found.
19917
+ const endsOnBlankLine = HTML_SEQUENCES[i][1].test('');
19918
+
19868
19919
  // If we are here - we detected HTML block.
19869
19920
  // Let's roll down till block end.
19870
19921
  if (!HTML_SEQUENCES[i][1].test(lineText)) {
19871
19922
  for (; nextLine < endLine; nextLine++) {
19872
- if (state.sCount[nextLine] < state.blkIndent) { break }
19923
+ if (state.sCount[nextLine] < state.blkIndent) {
19924
+ // An outdented blank line shouldn't end a block that doesn't end on a
19925
+ // blank line (e.g. a `<!--` comment inside a list item). Such blocks
19926
+ // must continue until their closing sequence regardless of indent.
19927
+ if (endsOnBlankLine || !state.isEmpty(nextLine)) { break }
19928
+ }
19873
19929
 
19874
19930
  pos = state.bMarks[nextLine] + state.tShift[nextLine];
19875
19931
  max = state.eMarks[nextLine];
@@ -19932,7 +19988,7 @@ function heading (state, startLine, endLine, silent) {
19932
19988
  token_o.map = [startLine, state.line];
19933
19989
 
19934
19990
  const token_i = state.push('inline', '', 0);
19935
- token_i.content = state.src.slice(pos, max).trim();
19991
+ token_i.content = asciiTrim(state.src.slice(pos, max));
19936
19992
  token_i.map = [startLine, state.line];
19937
19993
  token_i.children = [];
19938
19994
 
@@ -19944,6 +20000,7 @@ function heading (state, startLine, endLine, silent) {
19944
20000
 
19945
20001
  // lheading (---, ===)
19946
20002
 
20003
+
19947
20004
  function lheading (state, startLine, endLine/*, silent */) {
19948
20005
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
19949
20006
 
@@ -20001,10 +20058,11 @@ function lheading (state, startLine, endLine/*, silent */) {
20001
20058
 
20002
20059
  if (!level) {
20003
20060
  // Didn't find valid underline
20061
+ state.parentType = oldParentType;
20004
20062
  return false
20005
20063
  }
20006
20064
 
20007
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
20065
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
20008
20066
 
20009
20067
  state.line = nextLine + 1;
20010
20068
 
@@ -20027,6 +20085,7 @@ function lheading (state, startLine, endLine/*, silent */) {
20027
20085
 
20028
20086
  // Paragraph
20029
20087
 
20088
+
20030
20089
  function paragraph (state, startLine, endLine) {
20031
20090
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
20032
20091
  const oldParentType = state.parentType;
@@ -20053,7 +20112,7 @@ function paragraph (state, startLine, endLine) {
20053
20112
  if (terminate) { break }
20054
20113
  }
20055
20114
 
20056
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
20115
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
20057
20116
 
20058
20117
  state.line = nextLine;
20059
20118
 
@@ -20280,8 +20339,30 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
20280
20339
  const max = this.posMax;
20281
20340
  const marker = this.src.charCodeAt(start);
20282
20341
 
20283
- // treat beginning of the line as a whitespace
20284
- const lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
20342
+ // Astral characters below are combined manually, because .codePointAt()
20343
+ // does not guarantee numeric type output. And we don't wish JIT cache issues.
20344
+ // The broken surrogate pairs are evaluated as U+FFFD to prevent possible
20345
+ // crashes.
20346
+
20347
+ let lastChar;
20348
+ if (start === 0) {
20349
+ // treat beginning of the line as a whitespace
20350
+ lastChar = 0x20;
20351
+ } else if (start === 1) {
20352
+ lastChar = this.src.charCodeAt(0);
20353
+ if ((lastChar & 0xF800) === 0xD800) { lastChar = 0xFFFD; }
20354
+ } else {
20355
+ lastChar = this.src.charCodeAt(start - 1);
20356
+ if ((lastChar & 0xFC00) === 0xDC00) {
20357
+ // low surrogate => add high one, replace broken pair with U+FFFD
20358
+ const highSurr = this.src.charCodeAt(start - 2);
20359
+ lastChar = (highSurr & 0xFC00) === 0xD800
20360
+ ? 0x10000 + ((highSurr - 0xD800) << 10) + (lastChar - 0xDC00)
20361
+ : 0xFFFD;
20362
+ } else if ((lastChar & 0xFC00) === 0xD800) {
20363
+ lastChar = 0xFFFD;
20364
+ }
20365
+ }
20285
20366
 
20286
20367
  let pos = start;
20287
20368
  while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
@@ -20289,10 +20370,19 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
20289
20370
  const count = pos - start;
20290
20371
 
20291
20372
  // treat end of the line as a whitespace
20292
- const nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
20373
+ let nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
20374
+ if ((nextChar & 0xFC00) === 0xD800) {
20375
+ // high surrogate => add low one, replace broken pair with U+FFFD
20376
+ const lowSurr = this.src.charCodeAt(pos + 1);
20377
+ nextChar = (lowSurr & 0xFC00) === 0xDC00
20378
+ ? 0x10000 + ((nextChar - 0xD800) << 10) + (lowSurr - 0xDC00)
20379
+ : 0xFFFD;
20380
+ } else if ((nextChar & 0xFC00) === 0xDC00) {
20381
+ nextChar = 0xFFFD;
20382
+ }
20293
20383
 
20294
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
20295
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
20384
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
20385
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
20296
20386
 
20297
20387
  const isLastWhiteSpace = isWhiteSpace(lastChar);
20298
20388
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -21319,7 +21409,7 @@ function entity (state, silent) {
21319
21409
  } else {
21320
21410
  const match = state.src.slice(pos).match(NAMED_RE);
21321
21411
  if (match) {
21322
- const decoded = index.decodeHTML(match[0]);
21412
+ const decoded = index.decodeHTMLStrict(match[0]);
21323
21413
  if (decoded !== match[0]) {
21324
21414
  if (!silent) {
21325
21415
  const token = state.push('text_special', '', 0);
@@ -21981,11 +22071,6 @@ const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghik
21981
22071
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
21982
22072
  const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
21983
22073
 
21984
- function resetScanCache (self) {
21985
- self.__index__ = -1;
21986
- self.__text_cache__ = '';
21987
- }
21988
-
21989
22074
  function createValidator (re) {
21990
22075
  return function (text, pos) {
21991
22076
  const tail = text.slice(pos);
@@ -22024,8 +22109,11 @@ function compile (self) {
22024
22109
  function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
22025
22110
 
22026
22111
  re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
22112
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
22027
22113
  re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
22114
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
22028
22115
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
22116
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
22029
22117
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
22030
22118
 
22031
22119
  //
@@ -22119,12 +22207,6 @@ function compile (self) {
22119
22207
  '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
22120
22208
  'i'
22121
22209
  );
22122
-
22123
- //
22124
- // Cleanup
22125
- //
22126
-
22127
- resetScanCache(self);
22128
22210
  }
22129
22211
 
22130
22212
  /**
@@ -22132,55 +22214,45 @@ function compile (self) {
22132
22214
  *
22133
22215
  * Match result. Single element of array, returned by [[LinkifyIt#match]]
22134
22216
  **/
22135
- function Match (self, shift) {
22136
- const start = self.__index__;
22137
- const end = self.__last_index__;
22138
- const text = self.__text_cache__.slice(start, end);
22217
+ function Match (text, schema, index, lastIndex) {
22218
+ const raw = text.slice(index, lastIndex);
22139
22219
 
22140
22220
  /**
22141
22221
  * Match#schema -> String
22142
22222
  *
22143
22223
  * Prefix (protocol) for matched string.
22144
22224
  **/
22145
- this.schema = self.__schema__.toLowerCase();
22225
+ this.schema = schema.toLowerCase();
22146
22226
  /**
22147
22227
  * Match#index -> Number
22148
22228
  *
22149
22229
  * First position of matched string.
22150
22230
  **/
22151
- this.index = start + shift;
22231
+ this.index = index;
22152
22232
  /**
22153
22233
  * Match#lastIndex -> Number
22154
22234
  *
22155
22235
  * Next position after matched string.
22156
22236
  **/
22157
- this.lastIndex = end + shift;
22237
+ this.lastIndex = lastIndex;
22158
22238
  /**
22159
22239
  * Match#raw -> String
22160
22240
  *
22161
22241
  * Matched string.
22162
22242
  **/
22163
- this.raw = text;
22243
+ this.raw = raw;
22164
22244
  /**
22165
22245
  * Match#text -> String
22166
22246
  *
22167
22247
  * Notmalized text of matched string.
22168
22248
  **/
22169
- this.text = text;
22249
+ this.text = raw;
22170
22250
  /**
22171
22251
  * Match#url -> String
22172
22252
  *
22173
22253
  * Normalized url of matched string.
22174
22254
  **/
22175
- this.url = text;
22176
- }
22177
-
22178
- function createMatch (self, shift) {
22179
- const match = new Match(self, shift);
22180
-
22181
- self.__compiled__[match.schema].normalize(match, self);
22182
-
22183
- return match
22255
+ this.url = raw;
22184
22256
  }
22185
22257
 
22186
22258
  /**
@@ -22235,12 +22307,6 @@ function LinkifyIt (schemas, options) {
22235
22307
 
22236
22308
  this.__opts__ = assign({}, defaultOptions, options);
22237
22309
 
22238
- // Cache last tested result. Used to skip repeating steps on next `match` call.
22239
- this.__index__ = -1;
22240
- this.__last_index__ = -1; // Next scan position
22241
- this.__schema__ = '';
22242
- this.__text_cache__ = '';
22243
-
22244
22310
  this.__schemas__ = assign({}, defaultSchemas, schemas);
22245
22311
  this.__compiled__ = {};
22246
22312
 
@@ -22282,69 +22348,38 @@ LinkifyIt.prototype.set = function set (options) {
22282
22348
  * Searches linkifiable pattern and returns `true` on success or `false` on fail.
22283
22349
  **/
22284
22350
  LinkifyIt.prototype.test = function test (text) {
22285
- // Reset scan cache
22286
- this.__text_cache__ = text;
22287
- this.__index__ = -1;
22288
-
22289
22351
  if (!text.length) { return false }
22290
22352
 
22291
- let m, ml, me, len, shift, next, re, tld_pos, at_pos;
22353
+ let m, re;
22292
22354
 
22293
22355
  // try to scan for link with schema - that's the most simple rule
22294
22356
  if (this.re.schema_test.test(text)) {
22295
22357
  re = this.re.schema_search;
22296
22358
  re.lastIndex = 0;
22297
22359
  while ((m = re.exec(text)) !== null) {
22298
- len = this.testSchemaAt(text, m[2], re.lastIndex);
22299
- if (len) {
22300
- this.__schema__ = m[2];
22301
- this.__index__ = m.index + m[1].length;
22302
- this.__last_index__ = m.index + m[0].length + len;
22303
- break
22304
- }
22360
+ if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
22305
22361
  }
22306
22362
  }
22307
22363
 
22308
22364
  if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
22309
22365
  // guess schemaless links
22310
- tld_pos = text.search(this.re.host_fuzzy_test);
22311
- if (tld_pos >= 0) {
22312
- // if tld is located after found link - no need to check fuzzy pattern
22313
- if (this.__index__ < 0 || tld_pos < this.__index__) {
22314
- if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
22315
- shift = ml.index + ml[1].length;
22316
-
22317
- if (this.__index__ < 0 || shift < this.__index__) {
22318
- this.__schema__ = '';
22319
- this.__index__ = shift;
22320
- this.__last_index__ = ml.index + ml[0].length;
22321
- }
22322
- }
22366
+ if (text.search(this.re.host_fuzzy_test) >= 0) {
22367
+ if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
22368
+ return true
22323
22369
  }
22324
22370
  }
22325
22371
  }
22326
22372
 
22327
22373
  if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
22328
22374
  // guess schemaless emails
22329
- at_pos = text.indexOf('@');
22330
- if (at_pos >= 0) {
22375
+ if (text.indexOf('@') >= 0) {
22331
22376
  // We can't skip this check, because this cases are possible:
22332
22377
  // 192.168.1.1@gmail.com, my.in@example.com
22333
- if ((me = text.match(this.re.email_fuzzy)) !== null) {
22334
- shift = me.index + me[1].length;
22335
- next = me.index + me[0].length;
22336
-
22337
- if (this.__index__ < 0 || shift < this.__index__ ||
22338
- (shift === this.__index__ && next > this.__last_index__)) {
22339
- this.__schema__ = 'mailto:';
22340
- this.__index__ = shift;
22341
- this.__last_index__ = next;
22342
- }
22343
- }
22378
+ if (text.match(this.re.email_fuzzy) !== null) { return true }
22344
22379
  }
22345
22380
  }
22346
22381
 
22347
- return this.__index__ >= 0
22382
+ return false
22348
22383
  };
22349
22384
 
22350
22385
  /**
@@ -22393,23 +22428,88 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
22393
22428
  **/
22394
22429
  LinkifyIt.prototype.match = function match (text) {
22395
22430
  const result = [];
22396
- let shift = 0;
22431
+ const type_schemed = [];
22432
+ const type_fuzzy_link = [];
22433
+ const type_fuzzy_email = [];
22434
+ let m, len, re;
22435
+
22436
+ function choose (a, b) {
22437
+ if (!a) { return b }
22438
+ if (!b) { return a }
22439
+ if (a.index !== b.index) { return a.index < b.index ? a : b }
22440
+ return a.lastIndex >= b.lastIndex ? a : b
22441
+ }
22442
+
22443
+ if (!text.length) { return null }
22444
+
22445
+ // scan for links with schema
22446
+ if (this.re.schema_test.test(text)) {
22447
+ re = this.re.schema_search;
22448
+ re.lastIndex = 0;
22449
+ while ((m = re.exec(text)) !== null) {
22450
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
22451
+ if (len) {
22452
+ type_schemed.push({
22453
+ schema: m[2],
22454
+ index: m.index + m[1].length,
22455
+ lastIndex: m.index + m[0].length + len
22456
+ });
22457
+ }
22458
+ }
22459
+ }
22397
22460
 
22398
- // Try to take previous element from cache, if .test() called before
22399
- if (this.__index__ >= 0 && this.__text_cache__ === text) {
22400
- result.push(createMatch(this, shift));
22401
- shift = this.__last_index__;
22461
+ if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
22462
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
22463
+ re.lastIndex = 0;
22464
+ while ((m = re.exec(text)) !== null) {
22465
+ type_fuzzy_link.push({
22466
+ schema: '',
22467
+ index: m.index + m[1].length,
22468
+ lastIndex: m.index + m[0].length
22469
+ });
22470
+ }
22402
22471
  }
22403
22472
 
22404
- // Cut head if cache was used
22405
- let tail = shift ? text.slice(shift) : text;
22473
+ if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
22474
+ re = this.re.email_fuzzy_global;
22475
+ re.lastIndex = 0;
22476
+ while ((m = re.exec(text)) !== null) {
22477
+ type_fuzzy_email.push({
22478
+ schema: 'mailto:',
22479
+ index: m.index + m[1].length,
22480
+ lastIndex: m.index + m[0].length
22481
+ });
22482
+ }
22483
+ }
22406
22484
 
22407
- // Scan string until end reached
22408
- while (this.test(tail)) {
22409
- result.push(createMatch(this, shift));
22485
+ const indexes = [0, 0, 0];
22486
+ let lastIndex = 0;
22410
22487
 
22411
- tail = tail.slice(this.__last_index__);
22412
- shift += this.__last_index__;
22488
+ for (;;) {
22489
+ const candidates = [
22490
+ type_schemed[indexes[0]],
22491
+ type_fuzzy_email[indexes[1]],
22492
+ type_fuzzy_link[indexes[2]]
22493
+ ];
22494
+
22495
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
22496
+
22497
+ if (!candidate) { break }
22498
+
22499
+ if (candidate === candidates[0]) {
22500
+ indexes[0]++;
22501
+ } else if (candidate === candidates[1]) {
22502
+ indexes[1]++;
22503
+ } else {
22504
+ indexes[2]++;
22505
+ }
22506
+
22507
+ if (candidate.index < lastIndex) { continue }
22508
+
22509
+ const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
22510
+ this.__compiled__[match.schema].normalize(match, this);
22511
+ result.push(match);
22512
+ lastIndex = candidate.lastIndex;
22413
22513
  }
22414
22514
 
22415
22515
  if (result.length) {
@@ -22426,10 +22526,6 @@ LinkifyIt.prototype.match = function match (text) {
22426
22526
  * of the string, and null otherwise.
22427
22527
  **/
22428
22528
  LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
22429
- // Reset scan cache
22430
- this.__text_cache__ = text;
22431
- this.__index__ = -1;
22432
-
22433
22529
  if (!text.length) return null
22434
22530
 
22435
22531
  const m = this.re.schema_at_start.exec(text);
@@ -22438,11 +22534,10 @@ LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
22438
22534
  const len = this.testSchemaAt(text, m[2], m[0].length);
22439
22535
  if (!len) return null
22440
22536
 
22441
- this.__schema__ = m[2];
22442
- this.__index__ = m.index + m[1].length;
22443
- this.__last_index__ = m.index + m[0].length + len;
22537
+ const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
22444
22538
 
22445
- return createMatch(this, 0)
22539
+ this.__compiled__[match.schema].normalize(match, this);
22540
+ return match
22446
22541
  };
22447
22542
 
22448
22543
  /** chainable
@@ -23494,7 +23589,7 @@ function MarkdownIt (presetName, options) {
23494
23589
  * ```javascript
23495
23590
  * var md = require('markdown-it')()
23496
23591
  * .set({ html: true, breaks: true })
23497
- * .set({ typographer, true });
23592
+ * .set({ typographer: true });
23498
23593
  * ```
23499
23594
  *
23500
23595
  * __Note:__ To achieve the best possible performance, don't modify a