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