decord/source/modules/markup/MarkupListRule.tsx

137 lines
4.2 KiB
TypeScript
Raw Normal View History

// Module ID: 5075
// Function ID: 5076
// Name: MarkupListRule
// Dependencies: [4301, 38, 2]
2026-07-28 08:39:19 +00:00
// Module 5075 (MarkupListRule)
2026-08-24 06:08:38 +00:00
import _modDef38 from "module_38" /* 38 */;
import _modDef4301 from "module_4301" /* 4301 */;
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
const re2 = /\n{2,}$/;
const re3 = /(?:^|\n)( *)$/;
let regExp = new RegExp("^" + "(%INDENT_CAPTURE_PATTERN%)((?:[*-]|\\d+\\.)) +".replace("%INDENT_CAPTURE_PATTERN%", " *"));
const re5 = / *\n$/;
let regExp1 = new RegExp("^( *)((?:[*-]|\\d+\\.)) [\\s\\S]+?(?:\\n(?! )(?!\\1(?:[*-]|\\d+\\.) )|$)");
const regExp2 = new RegExp("^\\n" + "^( *)((?:[*-]|\\d+\\.)) [\\s\\S]+?(?:\\n(?! )(?!\\1(?:[*-]|\\d+\\.) )|$)".slice(1));
2026-07-28 08:39:19 +00:00
const re8 = /^\n/;
const re9 = /\n *$/;
let closure_10 = "\n".charCodeAt(0);
2026-07-28 08:39:19 +00:00
const re11 = /^[ \t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+$/;
2026-07-23 10:11:24 +00:00
let obj = {};
let merged = Object.assign(_modDef4301.defaultRules.list);
2026-07-29 08:29:29 +00:00
obj.requiredFirstCharacters = "\n *-0123456789".split("");
obj.match = function match(str, allowList) {
2026-07-20 16:05:17 +00:00
if (allowList.allowList) {
if (allowList._listLevel >= 11) {
return null;
2026-07-28 08:39:19 +00:00
} else if (str.charCodeAt(0) === closure_10) {
let str3 = "";
if (null != allowList.prevCapture) {
str3 = allowList.prevCapture[0];
}
let match = null;
if ("" !== str3) {
match = null;
if (!re9.test(str3)) {
2026-07-28 08:39:19 +00:00
match = regExp2.exec(str);
}
}
return match;
2026-07-20 16:05:17 +00:00
} else {
2026-07-28 08:39:19 +00:00
str = "";
2026-07-20 16:05:17 +00:00
if (null != allowList.prevCapture) {
str = allowList.prevCapture[0];
}
const match1 = re3.exec(str);
2026-07-28 08:39:19 +00:00
let match2 = null;
if (null != match1) {
match2 = null;
if (!re11.test(match1[0])) {
2026-07-28 08:39:19 +00:00
match2 = regExp1.exec(str);
2026-07-20 16:05:17 +00:00
}
}
2026-07-28 08:39:19 +00:00
return match2;
2026-07-20 16:05:17 +00:00
}
} else {
return null;
}
};
2026-07-29 08:29:29 +00:00
obj.parse = function parse(arg0, arg1, arg2) {
2026-08-24 06:08:38 +00:00
importDefault = arg1;
dependencyMap = arg2;
2026-07-20 16:05:17 +00:00
let bound;
if (arg0[2].length > 1) {
const _Math = Math;
const _Math2 = Math;
bound = Math.min(1000000000, Math.max(1, +arr));
}
const isMatch = regex2.test(arg0[0]);
const str3 = arg0[0].replace(regex2, "").replace(regExp1, "\n");
const match = regex.exec(str3);
2026-07-20 16:05:17 +00:00
let num2 = 0;
if (null != match) {
num2 = match[0].length;
}
let num3 = 0;
if (null != match) {
num3 = match[1].length;
}
const regExp = new RegExp("(%INDENT_CAPTURE_PATTERN%)((?:[*-]|\\d+\\.)) +[^\\n]*(?:\\n(?!%INDENT_CAPTURE_PATTERN%(?:[*-]|\\d+\\.) )[^\\n]*)*(\n|$)".replaceAll("%INDENT_CAPTURE_PATTERN%", " {" + num3 + "," + num3 + 1 + "}"), "gm");
2026-07-23 10:11:24 +00:00
regExp1 = new RegExp("^ {1," + num2 + "}", "gm");
2026-07-28 08:39:19 +00:00
const match1 = str3.match(regExp);
2026-08-24 06:08:38 +00:00
_modDef38(null != match1, "markup list items can not be parsed.");
regex = false;
const str2 = arg0[0].replace(regex2, "");
2026-07-29 08:29:29 +00:00
return {
2026-07-20 16:05:17 +00:00
ordered: arg0[2].length > 1,
start: bound,
items: match1.map((item, index) => {
const replaced = item.replace(regExp, "").replace(regExp1, "");
2026-07-29 08:29:29 +00:00
const diff = match1.length - 1;
2026-07-20 16:05:17 +00:00
let tmp2 = -1 !== replaced.indexOf("\n\n");
if (!tmp2) {
tmp2 = index === diff && closure_4;
const tmp4 = index === diff && closure_4;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
closure_4 = tmp2;
2026-07-23 10:11:24 +00:00
_listLevel = _listLevel._listLevel;
_listLevel._list = true;
2026-07-29 08:29:29 +00:00
let num = _listLevel;
2026-07-23 10:11:24 +00:00
({ inline, _list } = _listLevel);
2026-07-29 08:29:29 +00:00
if (_listLevel == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
_listLevel._listLevel = num + 1;
2026-07-20 16:05:17 +00:00
if (tmp2) {
2026-07-29 08:29:29 +00:00
tmp5.inline = false;
let replaced1 = replaced.replace(re5, "\n\n");
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
tmp5.inline = true;
replaced1 = replaced.replace(re5, "");
2026-07-20 16:05:17 +00:00
}
const obj = {};
2026-07-29 08:29:29 +00:00
const merged = Object.assign(tmp5);
obj.allowHeading = false;
let str = item.replace(regExp, "");
2026-07-23 10:11:24 +00:00
_listLevel.inline = inline;
_listLevel._list = _list;
_listLevel._listLevel = _listLevel;
return closure_0(replaced1, obj).map((type) => {
2026-07-29 08:29:29 +00:00
let tmp = "text" === type.type;
if (tmp) {
tmp = null != type.content;
}
if (tmp) {
type.content = type.content.replace(/\n+\s*$/, "");
}
return type;
});
2026-08-15 05:55:55 +00:00
}),
consumedLeadingNewline: isMatch
2026-07-20 16:05:17 +00:00
};
};
const size = fn(2);
const result = size.fileFinishedImporting("modules/markup/MarkupListRule.tsx");
2026-07-20 16:05:17 +00:00
export default obj;