mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-08-06 04:28:34 +00:00
update
This commit is contained in:
7
node_modules/markdown-it/lib/helpers/index.js
generated
vendored
Normal file
7
node_modules/markdown-it/lib/helpers/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Just a shortcut for bulk export
|
||||
'use strict';
|
||||
|
||||
|
||||
exports.parseLinkLabel = require('./parse_link_label');
|
||||
exports.parseLinkDestination = require('./parse_link_destination');
|
||||
exports.parseLinkTitle = require('./parse_link_title');
|
80
node_modules/markdown-it/lib/helpers/parse_link_destination.js
generated
vendored
Normal file
80
node_modules/markdown-it/lib/helpers/parse_link_destination.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// Parse link destination
|
||||
//
|
||||
'use strict';
|
||||
|
||||
|
||||
var isSpace = require('../common/utils').isSpace;
|
||||
var unescapeAll = require('../common/utils').unescapeAll;
|
||||
|
||||
|
||||
module.exports = function parseLinkDestination(str, pos, max) {
|
||||
var code, level,
|
||||
lines = 0,
|
||||
start = pos,
|
||||
result = {
|
||||
ok: false,
|
||||
pos: 0,
|
||||
lines: 0,
|
||||
str: ''
|
||||
};
|
||||
|
||||
if (str.charCodeAt(pos) === 0x3C /* < */) {
|
||||
pos++;
|
||||
while (pos < max) {
|
||||
code = str.charCodeAt(pos);
|
||||
if (code === 0x0A /* \n */ || isSpace(code)) { return result; }
|
||||
if (code === 0x3E /* > */) {
|
||||
result.pos = pos + 1;
|
||||
result.str = unescapeAll(str.slice(start + 1, pos));
|
||||
result.ok = true;
|
||||
return result;
|
||||
}
|
||||
if (code === 0x5C /* \ */ && pos + 1 < max) {
|
||||
pos += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
// no closing '>'
|
||||
return result;
|
||||
}
|
||||
|
||||
// this should be ... } else { ... branch
|
||||
|
||||
level = 0;
|
||||
while (pos < max) {
|
||||
code = str.charCodeAt(pos);
|
||||
|
||||
if (code === 0x20) { break; }
|
||||
|
||||
// ascii control characters
|
||||
if (code < 0x20 || code === 0x7F) { break; }
|
||||
|
||||
if (code === 0x5C /* \ */ && pos + 1 < max) {
|
||||
pos += 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code === 0x28 /* ( */) {
|
||||
level++;
|
||||
}
|
||||
|
||||
if (code === 0x29 /* ) */) {
|
||||
if (level === 0) { break; }
|
||||
level--;
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (start === pos) { return result; }
|
||||
if (level !== 0) { return result; }
|
||||
|
||||
result.str = unescapeAll(str.slice(start, pos));
|
||||
result.lines = lines;
|
||||
result.pos = pos;
|
||||
result.ok = true;
|
||||
return result;
|
||||
};
|
48
node_modules/markdown-it/lib/helpers/parse_link_label.js
generated
vendored
Normal file
48
node_modules/markdown-it/lib/helpers/parse_link_label.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
// Parse link label
|
||||
//
|
||||
// this function assumes that first character ("[") already matches;
|
||||
// returns the end of the label
|
||||
//
|
||||
'use strict';
|
||||
|
||||
module.exports = function parseLinkLabel(state, start, disableNested) {
|
||||
var level, found, marker, prevPos,
|
||||
labelEnd = -1,
|
||||
max = state.posMax,
|
||||
oldPos = state.pos;
|
||||
|
||||
state.pos = start + 1;
|
||||
level = 1;
|
||||
|
||||
while (state.pos < max) {
|
||||
marker = state.src.charCodeAt(state.pos);
|
||||
if (marker === 0x5D /* ] */) {
|
||||
level--;
|
||||
if (level === 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
prevPos = state.pos;
|
||||
state.md.inline.skipToken(state);
|
||||
if (marker === 0x5B /* [ */) {
|
||||
if (prevPos === state.pos - 1) {
|
||||
// increase level if we find text `[`, which is not a part of any token
|
||||
level++;
|
||||
} else if (disableNested) {
|
||||
state.pos = oldPos;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
labelEnd = state.pos;
|
||||
}
|
||||
|
||||
// restore old state
|
||||
state.pos = oldPos;
|
||||
|
||||
return labelEnd;
|
||||
};
|
53
node_modules/markdown-it/lib/helpers/parse_link_title.js
generated
vendored
Normal file
53
node_modules/markdown-it/lib/helpers/parse_link_title.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
// Parse link title
|
||||
//
|
||||
'use strict';
|
||||
|
||||
|
||||
var unescapeAll = require('../common/utils').unescapeAll;
|
||||
|
||||
|
||||
module.exports = function parseLinkTitle(str, pos, max) {
|
||||
var code,
|
||||
marker,
|
||||
lines = 0,
|
||||
start = pos,
|
||||
result = {
|
||||
ok: false,
|
||||
pos: 0,
|
||||
lines: 0,
|
||||
str: ''
|
||||
};
|
||||
|
||||
if (pos >= max) { return result; }
|
||||
|
||||
marker = str.charCodeAt(pos);
|
||||
|
||||
if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }
|
||||
|
||||
pos++;
|
||||
|
||||
// if opening marker is "(", switch it to closing marker ")"
|
||||
if (marker === 0x28) { marker = 0x29; }
|
||||
|
||||
while (pos < max) {
|
||||
code = str.charCodeAt(pos);
|
||||
if (code === marker) {
|
||||
result.pos = pos + 1;
|
||||
result.lines = lines;
|
||||
result.str = unescapeAll(str.slice(start + 1, pos));
|
||||
result.ok = true;
|
||||
return result;
|
||||
} else if (code === 0x0A) {
|
||||
lines++;
|
||||
} else if (code === 0x5C /* \ */ && pos + 1 < max) {
|
||||
pos++;
|
||||
if (str.charCodeAt(pos) === 0x0A) {
|
||||
lines++;
|
||||
}
|
||||
}
|
||||
|
||||
pos++;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
Reference in New Issue
Block a user