more general web fixes and updates

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-10-28 11:26:30 +00:00
parent c920b28acc
commit f23792881e
5 changed files with 57 additions and 37 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/** /**
* marked v14.0.0 - a markdown parser * marked v14.1.3 - a markdown parser
* Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed) * Copyright (c) 2011-2024, Christopher Jeffrey. (MIT Licensed)
* https://github.com/markedjs/marked * https://github.com/markedjs/marked
*/ */
@ -253,7 +253,7 @@
code(src) { code(src) {
const cap = this.rules.block.code.exec(src); const cap = this.rules.block.code.exec(src);
if (cap) { if (cap) {
const text = cap[0].replace(/^ {1,4}/gm, ''); const text = cap[0].replace(/^(?: {1,4}| {0,3}\t)/gm, '');
return { return {
type: 'code', type: 'code',
raw: cap[0], raw: cap[0],
@ -437,7 +437,7 @@
itemContents = line.slice(indent); itemContents = line.slice(indent);
indent += cap[1].length; indent += cap[1].length;
} }
if (blankLine && /^ *$/.test(nextLine)) { // Items begin with at most one blank line if (blankLine && /^[ \t]*$/.test(nextLine)) { // Items begin with at most one blank line
raw += nextLine + '\n'; raw += nextLine + '\n';
src = src.substring(nextLine.length + 1); src = src.substring(nextLine.length + 1);
endEarly = true; endEarly = true;
@ -447,13 +447,19 @@
const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`); const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`); const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`); const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
const htmlBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}<[a-z].*>`, 'i');
// Check if following lines should be included in List Item // Check if following lines should be included in List Item
while (src) { while (src) {
const rawLine = src.split('\n', 1)[0]; const rawLine = src.split('\n', 1)[0];
let nextLineWithoutTabs;
nextLine = rawLine; nextLine = rawLine;
// Re-align to follow commonmark nesting rules // Re-align to follow commonmark nesting rules
if (this.options.pedantic) { if (this.options.pedantic) {
nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' '); nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, ' ');
nextLineWithoutTabs = nextLine;
}
else {
nextLineWithoutTabs = nextLine.replace(/\t/g, ' ');
} }
// End list item if found code fences // End list item if found code fences
if (fencesBeginRegex.test(nextLine)) { if (fencesBeginRegex.test(nextLine)) {
@ -463,16 +469,20 @@
if (headingBeginRegex.test(nextLine)) { if (headingBeginRegex.test(nextLine)) {
break; break;
} }
// End list item if found start of html block
if (htmlBeginRegex.test(nextLine)) {
break;
}
// End list item if found start of new bullet // End list item if found start of new bullet
if (nextBulletRegex.test(nextLine)) { if (nextBulletRegex.test(nextLine)) {
break; break;
} }
// Horizontal rule found // Horizontal rule found
if (hrRegex.test(src)) { if (hrRegex.test(nextLine)) {
break; break;
} }
if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible if (nextLineWithoutTabs.search(/[^ ]/) >= indent || !nextLine.trim()) { // Dedent if possible
itemContents += '\n' + nextLine.slice(indent); itemContents += '\n' + nextLineWithoutTabs.slice(indent);
} }
else { else {
// not enough indentation // not enough indentation
@ -480,7 +490,7 @@
break; break;
} }
// paragraph continuation unless last line was a different block level element // paragraph continuation unless last line was a different block level element
if (line.search(/[^ ]/) >= 4) { // indented code block if (line.replace(/\t/g, ' ').search(/[^ ]/) >= 4) { // indented code block
break; break;
} }
if (fencesBeginRegex.test(line)) { if (fencesBeginRegex.test(line)) {
@ -499,7 +509,7 @@
} }
raw += rawLine + '\n'; raw += rawLine + '\n';
src = src.substring(rawLine.length + 1); src = src.substring(rawLine.length + 1);
line = nextLine.slice(indent); line = nextLineWithoutTabs.slice(indent);
} }
} }
if (!list.loose) { if (!list.loose) {
@ -507,7 +517,7 @@
if (endsWithBlankLine) { if (endsWithBlankLine) {
list.loose = true; list.loose = true;
} }
else if (/\n *\n *$/.test(raw)) { else if (/\n[ \t]*\n[ \t]*$/.test(raw)) {
endsWithBlankLine = true; endsWithBlankLine = true;
} }
} }
@ -969,15 +979,15 @@
/** /**
* Block-Level Grammar * Block-Level Grammar
*/ */
const newline = /^(?: *(?:\n|$))+/; const newline = /^(?:[ \t]*(?:\n|$))+/;
const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/; const blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/; const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/; const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/; const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
const bullet = /(?:[*+-]|\d{1,9}[.)])/; const bullet = /(?:[*+-]|\d{1,9}[.)])/;
const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/) const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/)
.replace(/bull/g, bullet) // lists can interrupt .replace(/bull/g, bullet) // lists can interrupt
.replace(/blockCode/g, / {4}/) // indented code blocks can interrupt .replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code blocks can interrupt
.replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt
.replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt
.replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt .replace(/heading/g, / {0,3}#{1,6}/) // ATX heading can interrupt
@ -986,7 +996,7 @@
const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/; const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
const blockText = /^[^\n]+/; const blockText = /^[^\n]+/;
const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/; const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/) const def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/)
.replace('label', _blockLabel) .replace('label', _blockLabel)
.replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/) .replace('title', /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/)
.getRegex(); .getRegex();
@ -1006,9 +1016,9 @@
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3) + '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4) + '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5) + '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (6) + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) open tag + '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)' // (7) closing tag + '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
+ ')', 'i') + ')', 'i')
.replace('comment', _comment) .replace('comment', _comment)
.replace('tag', _tag) .replace('tag', _tag)
@ -1055,7 +1065,7 @@
.replace('hr', hr) .replace('hr', hr)
.replace('heading', ' {0,3}#{1,6}(?:\\s|$)') .replace('heading', ' {0,3}#{1,6}(?:\\s|$)')
.replace('blockquote', ' {0,3}>') .replace('blockquote', ' {0,3}>')
.replace('code', ' {4}[^\\n]') .replace('code', '(?: {4}| {0,3}\t)[^\\n]')
.replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n') .replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n')
.replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt .replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
.replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)') .replace('html', '</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)')
@ -1118,7 +1128,7 @@
const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u') const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u')
.replace(/punctuation/g, _punctuation).getRegex(); .replace(/punctuation/g, _punctuation).getRegex();
// sequences em should skip over [title](link), `code`, <html> // sequences em should skip over [title](link), `code`, <html>
const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u') const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u')
.replace(/punct/g, _punctuation) .replace(/punct/g, _punctuation)
.getRegex(); .getRegex();
@ -1335,11 +1345,6 @@
if (this.options.pedantic) { if (this.options.pedantic) {
src = src.replace(/\t/g, ' ').replace(/^ +$/gm, ''); src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
} }
else {
src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
return leading + ' '.repeat(tabs.length);
});
}
let token; let token;
let lastToken; let lastToken;
let cutSrc; let cutSrc;
@ -2082,6 +2087,7 @@
class _Hooks { class _Hooks {
options; options;
block;
constructor(options) { constructor(options) {
this.options = options || exports.defaults; this.options = options || exports.defaults;
} }
@ -2108,13 +2114,25 @@
processAllTokens(tokens) { processAllTokens(tokens) {
return tokens; return tokens;
} }
/**
* Provide function to tokenize markdown
*/
provideLexer() {
return this.block ? _Lexer.lex : _Lexer.lexInline;
}
/**
* Provide function to parse tokens
*/
provideParser() {
return this.block ? _Parser.parse : _Parser.parseInline;
}
} }
class Marked { class Marked {
defaults = _getDefaults(); defaults = _getDefaults();
options = this.setOptions; options = this.setOptions;
parse = this.parseMarkdown(_Lexer.lex, _Parser.parse); parse = this.parseMarkdown(true);
parseInline = this.parseMarkdown(_Lexer.lexInline, _Parser.parseInline); parseInline = this.parseMarkdown(false);
Parser = _Parser; Parser = _Parser;
Renderer = _Renderer; Renderer = _Renderer;
TextRenderer = _TextRenderer; TextRenderer = _TextRenderer;
@ -2287,8 +2305,8 @@
if (!(prop in hooks)) { if (!(prop in hooks)) {
throw new Error(`hook '${prop}' does not exist`); throw new Error(`hook '${prop}' does not exist`);
} }
if (prop === 'options') { if (['options', 'block'].includes(prop)) {
// ignore options property // ignore options and block properties
continue; continue;
} }
const hooksProp = prop; const hooksProp = prop;
@ -2346,7 +2364,7 @@
parser(tokens, options) { parser(tokens, options) {
return _Parser.parse(tokens, options ?? this.defaults); return _Parser.parse(tokens, options ?? this.defaults);
} }
parseMarkdown(lexer, parser) { parseMarkdown(blockType) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const parse = (src, options) => { const parse = (src, options) => {
const origOpt = { ...options }; const origOpt = { ...options };
@ -2366,7 +2384,10 @@
} }
if (opt.hooks) { if (opt.hooks) {
opt.hooks.options = opt; opt.hooks.options = opt;
opt.hooks.block = blockType;
} }
const lexer = opt.hooks ? opt.hooks.provideLexer() : (blockType ? _Lexer.lex : _Lexer.lexInline);
const parser = opt.hooks ? opt.hooks.provideParser() : (blockType ? _Parser.parse : _Parser.parseInline);
if (opt.async) { if (opt.async) {
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src) return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src)
.then(src => lexer(src, opt)) .then(src => lexer(src, opt))

File diff suppressed because one or more lines are too long

View File

@ -33670,10 +33670,7 @@
"tr": "Aracı güncellemesi için", "tr": "Aracı güncellemesi için",
"zh-chs": "代理更新", "zh-chs": "代理更新",
"zh-cht": "對於代理更新", "zh-cht": "對於代理更新",
"uk": "Для оновлення агента", "uk": "Для оновлення агента"
"xloc": [
"default.handlebars->47->784"
]
}, },
{ {
"bs": "Prisilno ažuriranje agenta", "bs": "Prisilno ažuriranje agenta",
@ -33701,7 +33698,8 @@
"zh-cht": "強制代理更新", "zh-cht": "強制代理更新",
"uk": "Примусове оновити агента", "uk": "Примусове оновити агента",
"xloc": [ "xloc": [
"default.handlebars->47->743" "default.handlebars->47->743",
"default.handlebars->47->784"
] ]
}, },
{ {

View File

@ -5949,7 +5949,7 @@
} else if (op == 110) { } else if (op == 110) {
// Force agent update // Force agent update
var x = "Force agent update on selected devices?" + '<br /><br />'; var x = "Force agent update on selected devices?" + '<br /><br />';
setDialogMode(2, "For agent update", 3, d2groupActionFunctionAgentUpdateExec, x); setDialogMode(2, "Force agent update", 3, d2groupActionFunctionAgentUpdateExec, x);
} else if (op == 111) { } else if (op == 111) {
// Clear agent core // Clear agent core
var x = "Clear agent core on selected devices?" + '<br /><br />'; var x = "Clear agent core on selected devices?" + '<br /><br />';