@gov-cy/govcy-frontend-renderer 1.28.1 → 1.30.0

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/index.mjs CHANGED
@@ -14476,6 +14476,15 @@ getDecoder(xmlDecodeTree);
14476
14476
  function decodeHTML(str, mode = DecodingMode.Legacy) {
14477
14477
  return htmlDecoder(str, mode);
14478
14478
  }
14479
+ /**
14480
+ * Decodes an HTML string, requiring all entities to be terminated by a semicolon.
14481
+ *
14482
+ * @param str The string to decode.
14483
+ * @returns The decoded string.
14484
+ */
14485
+ function decodeHTMLStrict(str) {
14486
+ return htmlDecoder(str, DecodingMode.Strict);
14487
+ }
14479
14488
 
14480
14489
  // Utilities
14481
14490
  //
@@ -14655,6 +14664,10 @@ function isPunctChar (ch) {
14655
14664
  return P.test(ch) || regex.test(ch)
14656
14665
  }
14657
14666
 
14667
+ function isPunctCharCode (code) {
14668
+ return isPunctChar(fromCodePoint(code))
14669
+ }
14670
+
14658
14671
  // Markdown ASCII punctuation characters.
14659
14672
  //
14660
14673
  // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
@@ -14716,6 +14729,7 @@ function normalizeReference (str) {
14716
14729
  // (remove this when node v10 is no longer supported).
14717
14730
  //
14718
14731
  if ('ẞ'.toLowerCase() === 'Ṿ') {
14732
+ /* c8 ignore next 2 */
14719
14733
  str = str.replace(/ẞ/g, 'ß');
14720
14734
  }
14721
14735
 
@@ -14754,6 +14768,28 @@ function normalizeReference (str) {
14754
14768
  return str.toLowerCase().toUpperCase()
14755
14769
  }
14756
14770
 
14771
+ function isAsciiTrimmable (c) {
14772
+ return c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d
14773
+ }
14774
+
14775
+ // "Light" .trim() for blocks (headers, paragraphs), where unicode spaces
14776
+ // should be preserved.
14777
+ function asciiTrim (str) {
14778
+ let start = 0;
14779
+ for (; start < str.length; start++) {
14780
+ if (!isAsciiTrimmable(str.charCodeAt(start))) {
14781
+ break
14782
+ }
14783
+ }
14784
+ let end = str.length - 1;
14785
+ for (; end >= start; end--) {
14786
+ if (!isAsciiTrimmable(str.charCodeAt(end))) {
14787
+ break
14788
+ }
14789
+ }
14790
+ return str.slice(start, end + 1)
14791
+ }
14792
+
14757
14793
  // Re-export libraries commonly used in both markdown-it and its plugins,
14758
14794
  // so plugins won't have to depend on them explicitly, which reduces their
14759
14795
  // bundled size (e.g. a browser build).
@@ -14763,6 +14799,7 @@ const lib = { mdurl, ucmicro };
14763
14799
  var utils$2 = /*#__PURE__*/Object.freeze({
14764
14800
  __proto__: null,
14765
14801
  arrayReplaceAt: arrayReplaceAt,
14802
+ asciiTrim: asciiTrim,
14766
14803
  assign: assign$1,
14767
14804
  escapeHtml: escapeHtml,
14768
14805
  escapeRE: escapeRE$1,
@@ -14770,6 +14807,7 @@ var utils$2 = /*#__PURE__*/Object.freeze({
14770
14807
  has: has,
14771
14808
  isMdAsciiPunct: isMdAsciiPunct,
14772
14809
  isPunctChar: isPunctChar,
14810
+ isPunctCharCode: isPunctCharCode,
14773
14811
  isSpace: isSpace,
14774
14812
  isString: isString$1,
14775
14813
  isValidEntityCode: isValidEntityCode,
@@ -16133,14 +16171,36 @@ const QUOTE_TEST_RE = /['"]/;
16133
16171
  const QUOTE_RE = /['"]/g;
16134
16172
  const APOSTROPHE = '\u2019'; /* ’ */
16135
16173
 
16136
- function replaceAt (str, index, ch) {
16137
- return str.slice(0, index) + ch + str.slice(index + 1)
16174
+ function addReplacement (replacements, tokenIdx, pos, ch) {
16175
+ if (!replacements[tokenIdx]) {
16176
+ replacements[tokenIdx] = [];
16177
+ }
16178
+
16179
+ replacements[tokenIdx].push({ pos, ch });
16180
+ }
16181
+
16182
+ function applyReplacements (str, replacements) {
16183
+ let result = '';
16184
+ let lastPos = 0;
16185
+
16186
+ replacements.sort((a, b) => a.pos - b.pos);
16187
+
16188
+ for (let i = 0; i < replacements.length; i++) {
16189
+ const replacement = replacements[i];
16190
+
16191
+ result += str.slice(lastPos, replacement.pos) + replacement.ch;
16192
+ lastPos = replacement.pos + 1;
16193
+ }
16194
+
16195
+ return result + str.slice(lastPos)
16138
16196
  }
16139
16197
 
16140
16198
  function process_inlines (tokens, state) {
16141
16199
  let j;
16142
16200
 
16143
16201
  const stack = [];
16202
+ // token index -> list of replacements in the original token content
16203
+ const replacements = {};
16144
16204
 
16145
16205
  for (let i = 0; i < tokens.length; i++) {
16146
16206
  const token = tokens[i];
@@ -16154,9 +16214,9 @@ function process_inlines (tokens, state) {
16154
16214
 
16155
16215
  if (token.type !== 'text') { continue }
16156
16216
 
16157
- let text = token.content;
16217
+ const text = token.content;
16158
16218
  let pos = 0;
16159
- let max = text.length;
16219
+ const max = text.length;
16160
16220
 
16161
16221
  /* eslint no-labels:0,block-scoped-var:0 */
16162
16222
  OUTER:
@@ -16204,8 +16264,8 @@ function process_inlines (tokens, state) {
16204
16264
  }
16205
16265
  }
16206
16266
 
16207
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
16208
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
16267
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
16268
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
16209
16269
 
16210
16270
  const isLastWhiteSpace = isWhiteSpace(lastChar);
16211
16271
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -16248,7 +16308,7 @@ function process_inlines (tokens, state) {
16248
16308
  if (!canOpen && !canClose) {
16249
16309
  // middle of word
16250
16310
  if (isSingle) {
16251
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
16311
+ addReplacement(replacements, i, t.index, APOSTROPHE);
16252
16312
  }
16253
16313
  continue
16254
16314
  }
@@ -16271,18 +16331,8 @@ function process_inlines (tokens, state) {
16271
16331
  closeQuote = state.md.options.quotes[1];
16272
16332
  }
16273
16333
 
16274
- // replace token.content *before* tokens[item.token].content,
16275
- // because, if they are pointing at the same token, replaceAt
16276
- // could mess up indices when quote length != 1
16277
- token.content = replaceAt(token.content, t.index, closeQuote);
16278
- tokens[item.token].content = replaceAt(
16279
- tokens[item.token].content, item.pos, openQuote);
16280
-
16281
- pos += closeQuote.length - 1;
16282
- if (item.token === i) { pos += openQuote.length - 1; }
16283
-
16284
- text = token.content;
16285
- max = text.length;
16334
+ addReplacement(replacements, i, t.index, closeQuote);
16335
+ addReplacement(replacements, item.token, item.pos, openQuote);
16286
16336
 
16287
16337
  stack.length = j;
16288
16338
  continue OUTER
@@ -16298,10 +16348,14 @@ function process_inlines (tokens, state) {
16298
16348
  level: thisLevel
16299
16349
  });
16300
16350
  } else if (canClose && isSingle) {
16301
- token.content = replaceAt(token.content, t.index, APOSTROPHE);
16351
+ addReplacement(replacements, i, t.index, APOSTROPHE);
16302
16352
  }
16303
16353
  }
16304
16354
  }
16355
+
16356
+ Object.keys(replacements).forEach(function (tokenIdx) {
16357
+ tokens[tokenIdx].content = applyReplacements(tokens[tokenIdx].content, replacements[tokenIdx]);
16358
+ });
16305
16359
  }
16306
16360
 
16307
16361
  function smartquotes (state) {
@@ -17905,11 +17959,22 @@ function html_block (state, startLine, endLine, silent) {
17905
17959
 
17906
17960
  let nextLine = startLine + 1;
17907
17961
 
17962
+ // Block types 6 and 7 (the only ones whose end condition is a blank line)
17963
+ // have `/^$/` as their closing regexp. For all other types (1-5, e.g.
17964
+ // `<!--` comments), a blank line is regular content and must not terminate
17965
+ // the block - it ends only when its closing sequence is found.
17966
+ const endsOnBlankLine = HTML_SEQUENCES[i][1].test('');
17967
+
17908
17968
  // If we are here - we detected HTML block.
17909
17969
  // Let's roll down till block end.
17910
17970
  if (!HTML_SEQUENCES[i][1].test(lineText)) {
17911
17971
  for (; nextLine < endLine; nextLine++) {
17912
- if (state.sCount[nextLine] < state.blkIndent) { break }
17972
+ if (state.sCount[nextLine] < state.blkIndent) {
17973
+ // An outdented blank line shouldn't end a block that doesn't end on a
17974
+ // blank line (e.g. a `<!--` comment inside a list item). Such blocks
17975
+ // must continue until their closing sequence regardless of indent.
17976
+ if (endsOnBlankLine || !state.isEmpty(nextLine)) { break }
17977
+ }
17913
17978
 
17914
17979
  pos = state.bMarks[nextLine] + state.tShift[nextLine];
17915
17980
  max = state.eMarks[nextLine];
@@ -17972,7 +18037,7 @@ function heading (state, startLine, endLine, silent) {
17972
18037
  token_o.map = [startLine, state.line];
17973
18038
 
17974
18039
  const token_i = state.push('inline', '', 0);
17975
- token_i.content = state.src.slice(pos, max).trim();
18040
+ token_i.content = asciiTrim(state.src.slice(pos, max));
17976
18041
  token_i.map = [startLine, state.line];
17977
18042
  token_i.children = [];
17978
18043
 
@@ -17984,6 +18049,7 @@ function heading (state, startLine, endLine, silent) {
17984
18049
 
17985
18050
  // lheading (---, ===)
17986
18051
 
18052
+
17987
18053
  function lheading (state, startLine, endLine/*, silent */) {
17988
18054
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
17989
18055
 
@@ -18041,10 +18107,11 @@ function lheading (state, startLine, endLine/*, silent */) {
18041
18107
 
18042
18108
  if (!level) {
18043
18109
  // Didn't find valid underline
18110
+ state.parentType = oldParentType;
18044
18111
  return false
18045
18112
  }
18046
18113
 
18047
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
18114
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
18048
18115
 
18049
18116
  state.line = nextLine + 1;
18050
18117
 
@@ -18067,6 +18134,7 @@ function lheading (state, startLine, endLine/*, silent */) {
18067
18134
 
18068
18135
  // Paragraph
18069
18136
 
18137
+
18070
18138
  function paragraph (state, startLine, endLine) {
18071
18139
  const terminatorRules = state.md.block.ruler.getRules('paragraph');
18072
18140
  const oldParentType = state.parentType;
@@ -18093,7 +18161,7 @@ function paragraph (state, startLine, endLine) {
18093
18161
  if (terminate) { break }
18094
18162
  }
18095
18163
 
18096
- const content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
18164
+ const content = asciiTrim(state.getLines(startLine, nextLine, state.blkIndent, false));
18097
18165
 
18098
18166
  state.line = nextLine;
18099
18167
 
@@ -18320,8 +18388,30 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
18320
18388
  const max = this.posMax;
18321
18389
  const marker = this.src.charCodeAt(start);
18322
18390
 
18323
- // treat beginning of the line as a whitespace
18324
- const lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
18391
+ // Astral characters below are combined manually, because .codePointAt()
18392
+ // does not guarantee numeric type output. And we don't wish JIT cache issues.
18393
+ // The broken surrogate pairs are evaluated as U+FFFD to prevent possible
18394
+ // crashes.
18395
+
18396
+ let lastChar;
18397
+ if (start === 0) {
18398
+ // treat beginning of the line as a whitespace
18399
+ lastChar = 0x20;
18400
+ } else if (start === 1) {
18401
+ lastChar = this.src.charCodeAt(0);
18402
+ if ((lastChar & 0xF800) === 0xD800) { lastChar = 0xFFFD; }
18403
+ } else {
18404
+ lastChar = this.src.charCodeAt(start - 1);
18405
+ if ((lastChar & 0xFC00) === 0xDC00) {
18406
+ // low surrogate => add high one, replace broken pair with U+FFFD
18407
+ const highSurr = this.src.charCodeAt(start - 2);
18408
+ lastChar = (highSurr & 0xFC00) === 0xD800
18409
+ ? 0x10000 + ((highSurr - 0xD800) << 10) + (lastChar - 0xDC00)
18410
+ : 0xFFFD;
18411
+ } else if ((lastChar & 0xFC00) === 0xD800) {
18412
+ lastChar = 0xFFFD;
18413
+ }
18414
+ }
18325
18415
 
18326
18416
  let pos = start;
18327
18417
  while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
@@ -18329,10 +18419,19 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
18329
18419
  const count = pos - start;
18330
18420
 
18331
18421
  // treat end of the line as a whitespace
18332
- const nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
18422
+ let nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
18423
+ if ((nextChar & 0xFC00) === 0xD800) {
18424
+ // high surrogate => add low one, replace broken pair with U+FFFD
18425
+ const lowSurr = this.src.charCodeAt(pos + 1);
18426
+ nextChar = (lowSurr & 0xFC00) === 0xDC00
18427
+ ? 0x10000 + ((nextChar - 0xD800) << 10) + (lowSurr - 0xDC00)
18428
+ : 0xFFFD;
18429
+ } else if ((nextChar & 0xFC00) === 0xDC00) {
18430
+ nextChar = 0xFFFD;
18431
+ }
18333
18432
 
18334
- const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
18335
- const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
18433
+ const isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctCharCode(lastChar);
18434
+ const isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctCharCode(nextChar);
18336
18435
 
18337
18436
  const isLastWhiteSpace = isWhiteSpace(lastChar);
18338
18437
  const isNextWhiteSpace = isWhiteSpace(nextChar);
@@ -19359,7 +19458,7 @@ function entity (state, silent) {
19359
19458
  } else {
19360
19459
  const match = state.src.slice(pos).match(NAMED_RE);
19361
19460
  if (match) {
19362
- const decoded = decodeHTML(match[0]);
19461
+ const decoded = decodeHTMLStrict(match[0]);
19363
19462
  if (decoded !== match[0]) {
19364
19463
  if (!silent) {
19365
19464
  const token = state.push('text_special', '', 0);
@@ -20021,11 +20120,6 @@ const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghik
20021
20120
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
20022
20121
  const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
20023
20122
 
20024
- function resetScanCache (self) {
20025
- self.__index__ = -1;
20026
- self.__text_cache__ = '';
20027
- }
20028
-
20029
20123
  function createValidator (re) {
20030
20124
  return function (text, pos) {
20031
20125
  const tail = text.slice(pos);
@@ -20064,8 +20158,11 @@ function compile (self) {
20064
20158
  function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
20065
20159
 
20066
20160
  re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
20161
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
20067
20162
  re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
20163
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
20068
20164
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
20165
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
20069
20166
  re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
20070
20167
 
20071
20168
  //
@@ -20159,12 +20256,6 @@ function compile (self) {
20159
20256
  '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
20160
20257
  'i'
20161
20258
  );
20162
-
20163
- //
20164
- // Cleanup
20165
- //
20166
-
20167
- resetScanCache(self);
20168
20259
  }
20169
20260
 
20170
20261
  /**
@@ -20172,55 +20263,45 @@ function compile (self) {
20172
20263
  *
20173
20264
  * Match result. Single element of array, returned by [[LinkifyIt#match]]
20174
20265
  **/
20175
- function Match (self, shift) {
20176
- const start = self.__index__;
20177
- const end = self.__last_index__;
20178
- const text = self.__text_cache__.slice(start, end);
20266
+ function Match (text, schema, index, lastIndex) {
20267
+ const raw = text.slice(index, lastIndex);
20179
20268
 
20180
20269
  /**
20181
20270
  * Match#schema -> String
20182
20271
  *
20183
20272
  * Prefix (protocol) for matched string.
20184
20273
  **/
20185
- this.schema = self.__schema__.toLowerCase();
20274
+ this.schema = schema.toLowerCase();
20186
20275
  /**
20187
20276
  * Match#index -> Number
20188
20277
  *
20189
20278
  * First position of matched string.
20190
20279
  **/
20191
- this.index = start + shift;
20280
+ this.index = index;
20192
20281
  /**
20193
20282
  * Match#lastIndex -> Number
20194
20283
  *
20195
20284
  * Next position after matched string.
20196
20285
  **/
20197
- this.lastIndex = end + shift;
20286
+ this.lastIndex = lastIndex;
20198
20287
  /**
20199
20288
  * Match#raw -> String
20200
20289
  *
20201
20290
  * Matched string.
20202
20291
  **/
20203
- this.raw = text;
20292
+ this.raw = raw;
20204
20293
  /**
20205
20294
  * Match#text -> String
20206
20295
  *
20207
20296
  * Notmalized text of matched string.
20208
20297
  **/
20209
- this.text = text;
20298
+ this.text = raw;
20210
20299
  /**
20211
20300
  * Match#url -> String
20212
20301
  *
20213
20302
  * Normalized url of matched string.
20214
20303
  **/
20215
- this.url = text;
20216
- }
20217
-
20218
- function createMatch (self, shift) {
20219
- const match = new Match(self, shift);
20220
-
20221
- self.__compiled__[match.schema].normalize(match, self);
20222
-
20223
- return match
20304
+ this.url = raw;
20224
20305
  }
20225
20306
 
20226
20307
  /**
@@ -20275,12 +20356,6 @@ function LinkifyIt (schemas, options) {
20275
20356
 
20276
20357
  this.__opts__ = assign({}, defaultOptions$1, options);
20277
20358
 
20278
- // Cache last tested result. Used to skip repeating steps on next `match` call.
20279
- this.__index__ = -1;
20280
- this.__last_index__ = -1; // Next scan position
20281
- this.__schema__ = '';
20282
- this.__text_cache__ = '';
20283
-
20284
20359
  this.__schemas__ = assign({}, defaultSchemas, schemas);
20285
20360
  this.__compiled__ = {};
20286
20361
 
@@ -20322,69 +20397,38 @@ LinkifyIt.prototype.set = function set (options) {
20322
20397
  * Searches linkifiable pattern and returns `true` on success or `false` on fail.
20323
20398
  **/
20324
20399
  LinkifyIt.prototype.test = function test (text) {
20325
- // Reset scan cache
20326
- this.__text_cache__ = text;
20327
- this.__index__ = -1;
20328
-
20329
20400
  if (!text.length) { return false }
20330
20401
 
20331
- let m, ml, me, len, shift, next, re, tld_pos, at_pos;
20402
+ let m, re;
20332
20403
 
20333
20404
  // try to scan for link with schema - that's the most simple rule
20334
20405
  if (this.re.schema_test.test(text)) {
20335
20406
  re = this.re.schema_search;
20336
20407
  re.lastIndex = 0;
20337
20408
  while ((m = re.exec(text)) !== null) {
20338
- len = this.testSchemaAt(text, m[2], re.lastIndex);
20339
- if (len) {
20340
- this.__schema__ = m[2];
20341
- this.__index__ = m.index + m[1].length;
20342
- this.__last_index__ = m.index + m[0].length + len;
20343
- break
20344
- }
20409
+ if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
20345
20410
  }
20346
20411
  }
20347
20412
 
20348
20413
  if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
20349
20414
  // guess schemaless links
20350
- tld_pos = text.search(this.re.host_fuzzy_test);
20351
- if (tld_pos >= 0) {
20352
- // if tld is located after found link - no need to check fuzzy pattern
20353
- if (this.__index__ < 0 || tld_pos < this.__index__) {
20354
- if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
20355
- shift = ml.index + ml[1].length;
20356
-
20357
- if (this.__index__ < 0 || shift < this.__index__) {
20358
- this.__schema__ = '';
20359
- this.__index__ = shift;
20360
- this.__last_index__ = ml.index + ml[0].length;
20361
- }
20362
- }
20415
+ if (text.search(this.re.host_fuzzy_test) >= 0) {
20416
+ if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
20417
+ return true
20363
20418
  }
20364
20419
  }
20365
20420
  }
20366
20421
 
20367
20422
  if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
20368
20423
  // guess schemaless emails
20369
- at_pos = text.indexOf('@');
20370
- if (at_pos >= 0) {
20424
+ if (text.indexOf('@') >= 0) {
20371
20425
  // We can't skip this check, because this cases are possible:
20372
20426
  // 192.168.1.1@gmail.com, my.in@example.com
20373
- if ((me = text.match(this.re.email_fuzzy)) !== null) {
20374
- shift = me.index + me[1].length;
20375
- next = me.index + me[0].length;
20376
-
20377
- if (this.__index__ < 0 || shift < this.__index__ ||
20378
- (shift === this.__index__ && next > this.__last_index__)) {
20379
- this.__schema__ = 'mailto:';
20380
- this.__index__ = shift;
20381
- this.__last_index__ = next;
20382
- }
20383
- }
20427
+ if (text.match(this.re.email_fuzzy) !== null) { return true }
20384
20428
  }
20385
20429
  }
20386
20430
 
20387
- return this.__index__ >= 0
20431
+ return false
20388
20432
  };
20389
20433
 
20390
20434
  /**
@@ -20433,23 +20477,88 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
20433
20477
  **/
20434
20478
  LinkifyIt.prototype.match = function match (text) {
20435
20479
  const result = [];
20436
- let shift = 0;
20480
+ const type_schemed = [];
20481
+ const type_fuzzy_link = [];
20482
+ const type_fuzzy_email = [];
20483
+ let m, len, re;
20437
20484
 
20438
- // Try to take previous element from cache, if .test() called before
20439
- if (this.__index__ >= 0 && this.__text_cache__ === text) {
20440
- result.push(createMatch(this, shift));
20441
- shift = this.__last_index__;
20485
+ function choose (a, b) {
20486
+ if (!a) { return b }
20487
+ if (!b) { return a }
20488
+ if (a.index !== b.index) { return a.index < b.index ? a : b }
20489
+ return a.lastIndex >= b.lastIndex ? a : b
20442
20490
  }
20443
20491
 
20444
- // Cut head if cache was used
20445
- let tail = shift ? text.slice(shift) : text;
20492
+ if (!text.length) { return null }
20446
20493
 
20447
- // Scan string until end reached
20448
- while (this.test(tail)) {
20449
- result.push(createMatch(this, shift));
20494
+ // scan for links with schema
20495
+ if (this.re.schema_test.test(text)) {
20496
+ re = this.re.schema_search;
20497
+ re.lastIndex = 0;
20498
+ while ((m = re.exec(text)) !== null) {
20499
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
20500
+ if (len) {
20501
+ type_schemed.push({
20502
+ schema: m[2],
20503
+ index: m.index + m[1].length,
20504
+ lastIndex: m.index + m[0].length + len
20505
+ });
20506
+ }
20507
+ }
20508
+ }
20450
20509
 
20451
- tail = tail.slice(this.__last_index__);
20452
- shift += this.__last_index__;
20510
+ if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
20511
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
20512
+ re.lastIndex = 0;
20513
+ while ((m = re.exec(text)) !== null) {
20514
+ type_fuzzy_link.push({
20515
+ schema: '',
20516
+ index: m.index + m[1].length,
20517
+ lastIndex: m.index + m[0].length
20518
+ });
20519
+ }
20520
+ }
20521
+
20522
+ if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
20523
+ re = this.re.email_fuzzy_global;
20524
+ re.lastIndex = 0;
20525
+ while ((m = re.exec(text)) !== null) {
20526
+ type_fuzzy_email.push({
20527
+ schema: 'mailto:',
20528
+ index: m.index + m[1].length,
20529
+ lastIndex: m.index + m[0].length
20530
+ });
20531
+ }
20532
+ }
20533
+
20534
+ const indexes = [0, 0, 0];
20535
+ let lastIndex = 0;
20536
+
20537
+ for (;;) {
20538
+ const candidates = [
20539
+ type_schemed[indexes[0]],
20540
+ type_fuzzy_email[indexes[1]],
20541
+ type_fuzzy_link[indexes[2]]
20542
+ ];
20543
+
20544
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
20545
+
20546
+ if (!candidate) { break }
20547
+
20548
+ if (candidate === candidates[0]) {
20549
+ indexes[0]++;
20550
+ } else if (candidate === candidates[1]) {
20551
+ indexes[1]++;
20552
+ } else {
20553
+ indexes[2]++;
20554
+ }
20555
+
20556
+ if (candidate.index < lastIndex) { continue }
20557
+
20558
+ const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
20559
+ this.__compiled__[match.schema].normalize(match, this);
20560
+ result.push(match);
20561
+ lastIndex = candidate.lastIndex;
20453
20562
  }
20454
20563
 
20455
20564
  if (result.length) {
@@ -20466,10 +20575,6 @@ LinkifyIt.prototype.match = function match (text) {
20466
20575
  * of the string, and null otherwise.
20467
20576
  **/
20468
20577
  LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
20469
- // Reset scan cache
20470
- this.__text_cache__ = text;
20471
- this.__index__ = -1;
20472
-
20473
20578
  if (!text.length) return null
20474
20579
 
20475
20580
  const m = this.re.schema_at_start.exec(text);
@@ -20478,11 +20583,10 @@ LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
20478
20583
  const len = this.testSchemaAt(text, m[2], m[0].length);
20479
20584
  if (!len) return null
20480
20585
 
20481
- this.__schema__ = m[2];
20482
- this.__index__ = m.index + m[1].length;
20483
- this.__last_index__ = m.index + m[0].length + len;
20586
+ const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
20484
20587
 
20485
- return createMatch(this, 0)
20588
+ this.__compiled__[match.schema].normalize(match, this);
20589
+ return match
20486
20590
  };
20487
20591
 
20488
20592
  /** chainable
@@ -21534,7 +21638,7 @@ function MarkdownIt (presetName, options) {
21534
21638
  * ```javascript
21535
21639
  * var md = require('markdown-it')()
21536
21640
  * .set({ html: true, breaks: true })
21537
- * .set({ typographer, true });
21641
+ * .set({ typographer: true });
21538
21642
  * ```
21539
21643
  *
21540
21644
  * __Note:__ To achieve the best possible performance, don't modify a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gov-cy/govcy-frontend-renderer",
3
- "version": "1.28.1",
3
+ "version": "1.30.0",
4
4
  "description": "Render html for design elements of the Unified design system using njk or json template.",
5
5
  "author": "DMRID - DSF Team",
6
6
  "license": "MIT",