Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superfluous slashes in reg exps #1134

Open
wants to merge 1 commit into
base: refactor/ownProperties
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ts/a11y/speech/SpeechUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions ts/adaptors/NodeMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<N, T, D, A extends AdaptorConstructor<N, T, D>>(
Base: A,
Expand Down
1 change: 1 addition & 0 deletions ts/adaptors/lite/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class LiteDocument {

/**
* The kind is always #document
*
* @returns {string} The document string.
*/
public get kind(): string {
Expand Down
2 changes: 1 addition & 1 deletion ts/adaptors/lite/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class LiteParser implements MinDOMParser<LiteDocument> {
//
// 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,
Expand Down
4 changes: 2 additions & 2 deletions ts/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ts/core/MmlTree/SerializedMmlVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class SerializedMmlVisitor extends MmlVisitor {
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\"/g, '&quot;')
.replace(/"/g, '&quot;')
.replace(/[\uD800-\uDBFF]./g, toEntity)
.replace(/[\u0080-\uD7FF\uE000-\uFFFF]/g, toEntity);
}
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/TexError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/bbox/BboxConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ts/input/tex/html/HtmlMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

Expand Down
9 changes: 5 additions & 4 deletions ts/output/common/FontData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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(/(?<!\.js)$/, '.js');
}
Expand Down
2 changes: 1 addition & 1 deletion ts/util/asyncLoad/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { mathjax } from '../../mathjax.js';
declare const System: { import: (name: string, url?: string) => 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) => {
Expand Down
2 changes: 1 addition & 1 deletion ts/util/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down