diff --git a/ts/a11y/speech/SpeechUtil.ts b/ts/a11y/speech/SpeechUtil.ts index c0367064a..300264b41 100644 --- a/ts/a11y/speech/SpeechUtil.ts +++ b/ts/a11y/speech/SpeechUtil.ts @@ -151,7 +151,7 @@ function getProsody(element: Element, prosody: ProsodyElement): ProsodyElement { /** * Extracts the prosody value from an attribute. */ -const prosodyRegexp = /([\+-]?)([0-9]+)%/; +const prosodyRegexp = /([+-]?)([0-9]+)%/; /** * Extracts the prosody value from an attribute. diff --git a/ts/adaptors/NodeMixin.ts b/ts/adaptors/NodeMixin.ts index f13b910e7..b2f119bf6 100644 --- a/ts/adaptors/NodeMixin.ts +++ b/ts/adaptors/NodeMixin.ts @@ -55,6 +55,7 @@ export const NodeMixinOptions: OptionList = { * @template N The HTMLElement node class * @template T The Text node class * @template D The Document class + * @template A Extension of AdaptorConstructor */ export function NodeMixin>( Base: A, diff --git a/ts/adaptors/lite/Document.ts b/ts/adaptors/lite/Document.ts index ba40a9f28..f83078ebf 100644 --- a/ts/adaptors/lite/Document.ts +++ b/ts/adaptors/lite/Document.ts @@ -48,6 +48,7 @@ export class LiteDocument { /** * The kind is always #document + * * @returns {string} The document string. */ public get kind(): string { diff --git a/ts/adaptors/lite/Parser.ts b/ts/adaptors/lite/Parser.ts index 2ebd548be..933632d2c 100644 --- a/ts/adaptors/lite/Parser.ts +++ b/ts/adaptors/lite/Parser.ts @@ -196,7 +196,7 @@ export class LiteParser implements MinDOMParser { // // Get the child to be added to the node // - const kind = tag.match(/<(.*?)[\s\n>\/]/)[1].toLowerCase(); + const kind = tag.match(/<(.*?)[\s\n>/]/)[1].toLowerCase(); const child = adaptor.node(kind) as LiteElement; // // Split out the tag attributes as an array of space, name, value1, value3, value3, diff --git a/ts/components/loader.ts b/ts/components/loader.ts index 04fb37f3d..80d7d90b2 100644 --- a/ts/components/loader.ts +++ b/ts/components/loader.ts @@ -127,7 +127,7 @@ export const PathFilters: { [name: string]: PathFilterFunction } = { if (!name.match(/^(?:[a-z]+:\/)?\/|[a-z]:\\|\[/i)) { data.name = '[mathjax]/' + name.replace(/^\.\//, ''); } - if (data.addExtension && !name.match(/\.[^\/]+$/)) { + if (data.addExtension && !name.match(/\.[^/]+$/)) { data.name += '.js'; } return true; @@ -273,7 +273,7 @@ export namespace Loader { const script = document.currentScript || document.getElementById('MathJax-script'); if (script) { - return (script as HTMLScriptElement).src.replace(/\/[^\/]*$/, ''); + return (script as HTMLScriptElement).src.replace(/\/[^/]*$/, ''); } } return mjxRoot(); diff --git a/ts/core/MmlTree/SerializedMmlVisitor.ts b/ts/core/MmlTree/SerializedMmlVisitor.ts index 9303921bd..12bd0f26b 100644 --- a/ts/core/MmlTree/SerializedMmlVisitor.ts +++ b/ts/core/MmlTree/SerializedMmlVisitor.ts @@ -160,7 +160,7 @@ export class SerializedMmlVisitor extends MmlVisitor { .replace(/&/g, '&') .replace(//g, '>') - .replace(/\"/g, '"') + .replace(/"/g, '"') .replace(/[\uD800-\uDBFF]./g, toEntity) .replace(/[\u0080-\uD7FF\uE000-\uFFFF]/g, toEntity); } diff --git a/ts/input/tex/TexError.ts b/ts/input/tex/TexError.ts index 3cc15ecec..7085e2ffd 100644 --- a/ts/input/tex/TexError.ts +++ b/ts/input/tex/TexError.ts @@ -23,7 +23,7 @@ export default class TexError { private static pattern = - /%(\d+|\{\d+\}|\{[a-z]+:\%\d+(?:\|(?:%\{\d+\}|%.|[^\}])*)+\}|.)/g; + /%(\d+|\{\d+\}|\{[a-z]+:%\d+(?:\|(?:%\{\d+\}|%.|[^}])*)+\}|.)/g; /** * Default error message. diff --git a/ts/input/tex/base/BaseMethods.ts b/ts/input/tex/base/BaseMethods.ts index ce21007dd..9e31d28ee 100644 --- a/ts/input/tex/base/BaseMethods.ts +++ b/ts/input/tex/base/BaseMethods.ts @@ -1338,7 +1338,7 @@ const BaseMethods: { [key: string]: ParseMethod } = { }); if (v) { mml = parser.create('node', 'mpadded', [mml], { voffset: v }); - if (v.match(/^\-/)) { + if (v.match(/^-/)) { NodeUtil.setAttribute(mml, 'height', v); NodeUtil.setAttribute(mml, 'depth', '+' + v.substring(1)); } else { diff --git a/ts/input/tex/bbox/BboxConfiguration.ts b/ts/input/tex/bbox/BboxConfiguration.ts index e488b72ae..14d0c76f1 100644 --- a/ts/input/tex/bbox/BboxConfiguration.ts +++ b/ts/input/tex/bbox/BboxConfiguration.ts @@ -67,7 +67,7 @@ const BboxMethods: { [key: string]: ParseMethod } = { width: '+' + 2 * parseInt(match[1], 10) + match[3], }; } - } else if (part.match(/^([a-z0-9]+|\#[0-9a-f]{6}|\#[0-9a-f]{3})$/i)) { + } else if (part.match(/^([a-z0-9]+|#[0-9a-f]{6}|#[0-9a-f]{3})$/i)) { // @test Bbox-Background if (background) { // @test Bbox-Background-Error diff --git a/ts/input/tex/html/HtmlMethods.ts b/ts/input/tex/html/HtmlMethods.ts index f6391e28c..00fafd710 100644 --- a/ts/input/tex/html/HtmlMethods.ts +++ b/ts/input/tex/html/HtmlMethods.ts @@ -39,7 +39,7 @@ const nonCharacterRegexp = */ function isLegalAttributeName(name: string): boolean { return !( - name.match(/[\x00-\x1f\x7f-\x9f "'>\/=]/) || name.match(nonCharacterRegexp) + name.match(/[\x00-\x1f\x7f-\x9f "'>/=]/) || name.match(nonCharacterRegexp) ); } diff --git a/ts/output/common/FontData.ts b/ts/output/common/FontData.ts index 6641881ad..a0e851ba7 100644 --- a/ts/output/common/FontData.ts +++ b/ts/output/common/FontData.ts @@ -348,9 +348,10 @@ export interface FontExtensionData< /** * Merge options into an object or array. * - * @param obj - * @param dst - * @param src + * @param {OptionList} obj The target options list. + * @param {string} dst Name of the option to merge into. + * @param {OptionList} src The options to be merged. + * @returns The options for `dst`. */ export function mergeOptions(obj: OptionList, dst: string, src: OptionList) { return src ? defaultOptions(obj, { [dst]: src })[dst] : obj[dst]; @@ -1213,7 +1214,7 @@ export class FontData< const prefix = !dynamic.extension ? this.options.dynamicPrefix : this.CLASS.dynamicExtensions.get(dynamic.extension).prefix; - return dynamic.file.match(/^(?:[\/\[]|[a-z]+:\/\/|[a-z]:)/i) + return dynamic.file.match(/^(?:[/[]|[a-z]+:\/\/|[a-z]:)/i) ? dynamic.file : prefix + '/' + dynamic.file.replace(/(? any }; declare const __dirname: string; -let root = 'file://' + __dirname.replace(/\/[^\/]*\/[^\/]*$/, '/'); +let root = 'file://' + __dirname.replace(/\/[^/]*\/[^/]*$/, '/'); if (!mathjax.asyncLoad && typeof System !== 'undefined' && System.import) { mathjax.asyncLoad = (name: string) => { diff --git a/ts/util/string.ts b/ts/util/string.ts index 8f4256377..a23d9edc2 100644 --- a/ts/util/string.ts +++ b/ts/util/string.ts @@ -45,7 +45,7 @@ export function sortLength(a: string, b: string): number { * @returns {string} The quoted string */ export function quotePattern(text: string): string { - return text.replace(/([\^$(){}.+*?\-|\[\]\:\\])/g, '\\$1'); + return text.replace(/([\^$(){}.+*?\-|[\]:\\])/g, '\\$1'); } /**