@khanacademy/perseus-linter 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/index.js CHANGED
@@ -2,13 +2,21 @@ import { PerseusError, Errors, addLibraryVersionToPerseusDebug } from '@khanacad
2
2
  import PropTypes from 'prop-types';
3
3
 
4
4
  function _extends() {
5
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
6
- for (var e = 1; e < arguments.length; e++) {
7
- var t = arguments[e];
8
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
5
+ _extends = Object.assign || function (target) {
6
+ for (var i = 1; i < arguments.length; i++) {
7
+ var source = arguments[i];
8
+
9
+ for (var key in source) {
10
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11
+ target[key] = source[key];
12
+ }
13
+ }
9
14
  }
10
- return n;
11
- }, _extends.apply(null, arguments);
15
+
16
+ return target;
17
+ };
18
+
19
+ return _extends.apply(this, arguments);
12
20
  }
13
21
 
14
22
  /* eslint-disable no-useless-escape */
@@ -1834,7 +1842,7 @@ class Stack {
1834
1842
 
1835
1843
  // This file is processed by a Rollup plugin (replace) to inject the production
1836
1844
  const libName = "@khanacademy/perseus-linter";
1837
- const libVersion = "1.2.5";
1845
+ const libVersion = "1.2.6";
1838
1846
  addLibraryVersionToPerseusDebug(libName, libVersion);
1839
1847
 
1840
1848
  // Define the shape of the linter context object that is passed through the
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../src/selector.ts","../../src/rule.ts","../../src/rules/lint-utils.ts","../../src/rules/absolute-url.ts","../../src/rules/blockquoted-math.ts","../../src/rules/blockquoted-widget.ts","../../src/rules/double-spacing-after-terminal.ts","../../src/rules/expression-widget.ts","../../src/rules/extra-content-spacing.ts","../../src/rules/heading-level-1.ts","../../src/rules/heading-level-skip.ts","../../src/rules/heading-sentence-case.ts","../../src/rules/heading-title-case.ts","../../src/rules/image-alt-text.ts","../../src/rules/image-in-table.ts","../../src/rules/image-spaces-around-urls.ts","../../src/rules/image-widget.ts","../../src/rules/link-click-here.ts","../../src/rules/long-paragraph.ts","../../src/rules/math-adjacent.ts","../../src/rules/math-align-extra-break.ts","../../src/rules/math-align-linebreaks.ts","../../src/rules/math-empty.ts","../../src/rules/math-font-size.ts","../../src/rules/math-frac.ts","../../src/rules/math-nested.ts","../../src/rules/math-starts-with-space.ts","../../src/rules/math-text-empty.ts","../../src/rules/math-without-dollars.ts","../../src/rules/nested-lists.ts","../../src/rules/static-widget-in-question-stem.ts","../../src/rules/table-missing-cells.ts","../../src/rules/unbalanced-code-delimiters.ts","../../src/rules/unescaped-dollar.ts","../../src/rules/widget-in-table.ts","../../src/rules/all-rules.ts","../../src/tree-transformer.ts","../../src/version.ts","../../src/proptypes.ts","../../src/index.ts"],"sourcesContent":["function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","/* eslint-disable no-useless-escape */\n/**\n * The Selector class implements a CSS-like system for matching nodes in a\n * parse tree based on the structure of the tree. Create a Selector object by\n * calling the static Selector.parse() method on a string that describes the\n * tree structure you want to match. For example, if you want to find text\n * nodes that are direct children of paragraph nodes that immediately follow\n * heading nodes, you could create an appropriate selector like this:\n *\n * selector = Selector.parse(\"heading + paragraph > text\");\n *\n * Recall from the TreeTransformer class, that we consider any object with a\n * string-valued `type` property to be a tree node. The words \"heading\",\n * \"paragraph\" and \"text\" in the selector string above specify node types and\n * will match nodes in a parse tree that have `type` properties with those\n * values.\n *\n * Selectors are designed for use during tree traversals done with the\n * TreeTransformer traverse() method. To test whether the node currently being\n * traversed matches a selector, simply pass the TraversalState object to the\n * match() method of the Selector object. If the node does not match the\n * selector, match() returns null. If it does match, then match() returns an\n * array of nodes that match the selector. In the example above the first\n * element of the array would be the node the heading node, the second would\n * be the paragraph node that follows it, and the third would be the text node\n * that is a child of the paragraph. The last element of a returned array of\n * nodes is always equal to the current node of the tree traversal.\n *\n * Code that uses a selector might look like this:\n *\n * matchingNodes = selector.match(state);\n * if (matchingNodes) {\n * let heading = matchingNodes[0];\n * let text = matchingNodes[2];\n * // do something with those nodes\n * }\n *\n * The Selector.parse() method recognizes a grammar that is similar to CSS\n * selectors:\n *\n * selector := treeSelector (, treeSelector)*\n *\n * A selector is one or more comma-separated treeSelectors. A node matches\n * the selector if it matches any of the treeSelectors.\n *\n * treeSelector := (treeSelector combinator)? nodeSelector\n *\n * A treeSelector is a nodeSelector optionally preceeded by a combinator\n * and another tree selector. The tree selector matches if the current node\n * matches the node selector and a sibling or ancestor (depending on the\n * combinator) of the current node matches the optional treeSelector.\n *\n * combinator := ' ' | '>' | '+' | '~' // standard CSS3 combinators\n *\n * A combinator is a space or punctuation character that specifies the\n * relationship between two nodeSelectors. A space between two\n * nodeSelectors means that the first selector much match an ancestor of\n * the node that matches the second selector. A '>' character means that\n * the first selector must match the parent of the node matched by the\n * second. The '~' combinator means that the first selector must match a\n * previous sibling of the node matched by the second. And the '+' selector\n * means that first selector must match the immediate previous sibling of\n * the node that matched the second.\n *\n * nodeSelector := <IDENTIFIER> | '*'\n *\n * A nodeSelector is simply an identifier (a letter followed by any number\n * of letters, digits, hypens, and underscores) or the wildcard asterisk\n * character. A wildcard node selector matches any node. An identifier\n * selector matches any node that has a `type` property whose value matches\n * the identifier.\n *\n * If you call Selector.parse() on a string that does not match this grammar,\n * it will throw an exception\n *\n * TODO(davidflanagan): it might be useful to allow more sophsticated node\n * selector matching with attribute matches and pseudo-classes, like\n * \"heading[level=2]\" or \"paragraph:first-child\"\n *\n * Implementation Note: this file exports a very simple Selector class but all\n * the actual work is done in various internal classes. The Parser class\n * parses the string representation of a selector into a parse tree that\n * consists of instances of various subclasses of the Selector class. It is\n * these subclasses that implement the selector matching logic, often\n * depending on features of the TraversalState object from the TreeTransformer\n * traversal.\n */\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\nimport type {TreeNode, TraversalState} from \"./tree-transformer\";\n\n/**\n * This is the base class for all Selector types. The key method that all\n * selector subclasses must implement is match(). It takes a TraversalState\n * object (from a TreeTransformer traversal) and tests whether the selector\n * matches at the current node. See the comment at the start of this file for\n * more details on the match() method.\n */\nexport default class Selector {\n static parse(selectorText: string): Selector {\n return new Parser(selectorText).parse();\n }\n\n /**\n * Return an array of the nodes that matched or null if no match.\n * This is the base class so we just throw an exception. All Selector\n * subclasses must provide an implementation of this method.\n */\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n throw new PerseusError(\n \"Selector subclasses must implement match()\",\n Errors.NotAllowed,\n );\n }\n\n /**\n * Selector subclasses all define a toString() method primarily\n * because it makes it easy to write parser tests.\n */\n toString(): string {\n return \"Unknown selector class\";\n }\n}\n\n/**\n * This class implements a parser for the selector grammar. Pass the source\n * text to the Parser() constructor, and then call the parse() method to\n * obtain a corresponding Selector object. parse() throws an exception\n * if there are syntax errors in the selector.\n *\n * This class is not exported, and you don't need to use it directly.\n * Instead call the static Selector.parse() method.\n */\nclass Parser {\n static TOKENS: RegExp; // We do lexing with a simple regular expression\n tokens: ReadonlyArray<string>; // The array of tokens\n tokenIndex: number; // Which token in the array we're looking at now\n\n constructor(s: string) {\n // Normalize whitespace:\n // - remove leading and trailing whitespace\n // - replace runs of whitespace with single space characters\n s = s.trim().replace(/\\s+/g, \" \");\n // Convert the string to an array of tokens. Note that the TOKENS\n // pattern ignores spaces that do not appear before identifiers\n // or the * wildcard.\n this.tokens = s.match(Parser.TOKENS) || [];\n this.tokenIndex = 0;\n }\n\n // Return the next token or the empty string if there are no more\n nextToken(): string {\n return this.tokens[this.tokenIndex] || \"\";\n }\n\n // Increment the token index to \"consume\" the token we were looking at\n // and move on to the next one.\n consume(): void {\n this.tokenIndex++;\n }\n\n // Return true if the current token is an identifier or false otherwise\n isIdentifier(): boolean {\n // The Parser.TOKENS regexp ensures that we only have to check\n // the first character of a token to know what kind of token it is.\n const c = this.tokens[this.tokenIndex][0];\n return (c >= \"a\" && c <= \"z\") || (c >= \"A\" && c <= \"Z\");\n }\n\n // Consume space tokens until the next token is not a space.\n skipSpace(): void {\n while (this.nextToken() === \" \") {\n this.consume();\n }\n }\n\n // Parse a comma-separated sequence of tree selectors. This is the\n // entry point for the Parser class and the only method that clients\n // ever need to call.\n parse(): Selector {\n // We expect at least one tree selector\n const ts = this.parseTreeSelector();\n\n // Now see what's next\n let token = this.nextToken();\n\n // If there is no next token then we're done parsing and can return\n // the tree selector object we got above\n if (!token) {\n return ts;\n }\n\n // Otherwise, there is more go come and we're going to need a\n // list of tree selectors\n const treeSelectors = [ts];\n while (token) {\n // The only character we allow after a tree selector is a comma\n if (token === \",\") {\n this.consume();\n } else {\n throw new ParseError(\"Expected comma\");\n }\n\n // And if we saw a comma, then it must be followed by another\n // tree selector\n treeSelectors.push(this.parseTreeSelector());\n token = this.nextToken();\n }\n\n // If we parsed more than one tree selector, return them in a\n // SelectorList object.\n return new SelectorList(treeSelectors);\n }\n\n // Parse a sequence of node selectors linked together with\n // hierarchy combinators: space, >, + and ~.\n parseTreeSelector(): Selector {\n this.skipSpace(); // Ignore space after a comma, for example\n\n // A tree selector must begin with a node selector\n let ns: Selector = this.parseNodeSelector();\n\n for (;;) {\n // Now check the next token. If there is none, or if it is a\n // comma, then we're done with the treeSelector. Otherwise\n // we expect a combinator followed by another node selector.\n // If we don't see a combinator, we throw an error. If we\n // do see a combinator and another node selector then we\n // combine the current node selector with the new node selector\n // using a Selector subclass that depends on the combinator.\n const token = this.nextToken();\n\n if (!token || token === \",\") {\n break;\n } else if (token === \" \") {\n this.consume();\n ns = new AncestorCombinator(ns, this.parseNodeSelector());\n } else if (token === \">\") {\n this.consume();\n ns = new ParentCombinator(ns, this.parseNodeSelector());\n } else if (token === \"+\") {\n this.consume();\n ns = new PreviousCombinator(ns, this.parseNodeSelector());\n } else if (token === \"~\") {\n this.consume();\n ns = new SiblingCombinator(ns, this.parseNodeSelector());\n } else {\n throw new ParseError(\"Unexpected token: \" + token);\n }\n }\n\n return ns;\n }\n\n // Parse a single node selector.\n // For now, this is just a node type or a wildcard.\n //\n // TODO(davidflanagan): we may need to extend this with attribute\n // selectors like 'heading[level=3]', or with pseudo-classes like\n // paragraph:first-child\n parseNodeSelector(): Selector {\n // First, skip any whitespace\n this.skipSpace();\n\n const t = this.nextToken();\n if (t === \"*\") {\n this.consume();\n return new AnyNode();\n }\n if (this.isIdentifier()) {\n this.consume();\n return new TypeSelector(t);\n }\n\n throw new ParseError(\"Expected node type\");\n }\n}\n\n// We break the input string into tokens with this regexp. Token types\n// are identifiers, integers, punctuation and spaces. Note that spaces\n// tokens are only returned when they appear before an identifier or\n// wildcard token and are otherwise omitted.\nParser.TOKENS = /([a-zA-Z][\\w-]*)|(\\d+)|[^\\s]|(\\s(?=[a-zA-Z\\*]))/g;\n\n/**\n * This is a trivial Error subclass that the Parser uses to signal parse errors\n */\nclass ParseError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * This Selector subclass is a list of selectors. It matches a node if any of\n * the selectors on the list matches the node. It considers the selectors in\n * order, and returns the array of nodes returned by whichever one matches\n * first.\n */\nclass SelectorList extends Selector {\n selectors: ReadonlyArray<Selector>;\n\n constructor(selectors: ReadonlyArray<Selector>) {\n super();\n this.selectors = selectors;\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n for (let i = 0; i < this.selectors.length; i++) {\n const s = this.selectors[i];\n const result = s.match(state);\n if (result) {\n return result;\n }\n }\n return null;\n }\n\n toString(): string {\n let result = \"\";\n for (let i = 0; i < this.selectors.length; i++) {\n result += i > 0 ? \", \" : \"\";\n result += this.selectors[i].toString();\n }\n return result;\n }\n}\n\n/**\n * This trivial Selector subclass implements the '*' wildcard and\n * matches any node.\n */\nclass AnyNode extends Selector {\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n return [state.currentNode()];\n }\n\n toString(): string {\n return \"*\";\n }\n}\n\n/**\n * This selector subclass implements the <IDENTIFIER> part of the grammar.\n * it matches any node whose `type` property is a specified string\n */\nclass TypeSelector extends Selector {\n type: string;\n\n constructor(type: string) {\n super();\n this.type = type;\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const node = state.currentNode();\n if (node.type === this.type) {\n return [node];\n }\n return null;\n }\n\n toString(): string {\n return this.type;\n }\n}\n\n/**\n * This selector subclass is the superclass of the classes that implement\n * matching for the four combinators. It defines left and right properties for\n * the two selectors that are to be combined, but does not define a match\n * method.\n */\nclass SelectorCombinator extends Selector {\n left: Selector;\n right: Selector;\n\n constructor(left: Selector, right: Selector) {\n super();\n this.left = left;\n this.right = right;\n }\n}\n\n/**\n * This Selector subclass implements the space combinator. It matches if the\n * right selector matches the current node and the left selector matches some\n * ancestor of the current node.\n */\nclass AncestorCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n state = state.clone();\n while (state.hasParent()) {\n state.goToParent();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the > combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * the parent of the current node.\n */\nclass ParentCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n if (state.hasParent()) {\n state = state.clone();\n state.goToParent();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" > \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the + combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * the immediate previous sibling of the current node.\n */\nclass PreviousCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n if (state.hasPreviousSibling()) {\n state = state.clone();\n state.goToPreviousSibling();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" + \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the ~ combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * any previous sibling of the current node.\n */\nclass SiblingCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n state = state.clone();\n while (state.hasPreviousSibling()) {\n state.goToPreviousSibling();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" ~ \" + this.right.toString();\n }\n}\n","/**\n * The Rule class represents a Perseus lint rule. A Rule instance has a check()\n * method that takes the same (node, state, content) arguments that a\n * TreeTransformer traversal callback function does. Call the check() method\n * during a tree traversal to determine whether the current node of the tree\n * violates the rule. If there is no violation, then check() returns\n * null. Otherwise, it returns an object that includes the name of the rule,\n * an error message, and the start and end positions within the node's content\n * string of the lint.\n *\n * A Perseus lint rule consists of a name, a severity, a selector, a pattern\n * (RegExp) and two functions. The check() method uses the selector, pattern,\n * and functions as follows:\n *\n * - First, when determining which rules to apply to a particular piece of\n * content, each rule can specify an optional function provided in the fifth\n * parameter to evaluate whether or not we should be applying this rule.\n * If the function returns false, we don't use the rule on this content.\n *\n * - Next, check() tests whether the node currently being traversed matches\n * the selector. If it does not, then the rule does not apply at this node\n * and there is no lint and check() returns null.\n *\n * - If the selector matched, then check() tests the text content of the node\n * (and its children) against the pattern. If the pattern does not match,\n * then there is no lint, and check() returns null.\n *\n * - If both the selector and pattern match, then check() calls the function\n * passing the TraversalState object, the content string for the node, the\n * array of nodes returned by the selector match, and the array of strings\n * returned by the pattern match. This function can use these arguments to\n * implement any kind of lint detection logic it wants. If it determines\n * that there is no lint, then it should return null. Otherwise, it should\n * return an error message as a string, or an object with `message`, `start`\n * and `end` properties. The start and end properties are numbers that mark\n * the beginning and end of the problematic content. Note that these numbers\n * are relative to the content string passed to the traversal callback, not\n * to the entire string that was used to generate the parse tree in the\n * first place. TODO(davidflanagan): modify the simple-markdown library to\n * have an option to add the text offset of each node to the parse\n * tree. This will allows us to pinpoint lint errors within a long string\n * of markdown text.\n *\n * - If the function returns null, then check() returns null. Otherwise,\n * check() returns an object with `rule`, `message`, `start` and `end`\n * properties. The value of the `rule` property is the name of the rule,\n * which is useful for error reporting purposes.\n *\n * The name, severity, selector, pattern and function arguments to the Rule()\n * constructor are optional, but you may not omit both the selector and the\n * pattern. If you do not specify a selector, a default selector that matches\n * any node of type \"text\" will be used. If you do not specify a pattern, then\n * any node that matches the selector will be assumed to match the pattern as\n * well. If you don't pass a function as the fourth argument to the Rule()\n * constructor, then you must pass an error message string instead. If you do\n * this, you'll get a default function that unconditionally returns an object\n * that includes the error message and the start and end indexes of the\n * portion of the content string that matched the pattern. If you don't pass a\n * function in the fifth parameter, the rule will be applied in any context.\n *\n * One of the design goals of this Rule class is to allow simple lint rules to\n * be described in JSON files without any JavaScript code. So in addition to\n * the Rule() constructor, the class also defines a Rule.makeRule() factory\n * method. This method takes a single object as its argument and expects the\n * object to have four string properties. The `name` property is passed as the\n * first argument to the Rule() construtctor. The optional `selector`\n * property, if specified, is passed to Selector.parse() and the resulting\n * Selector object is used as the second argument to Rule(). The optional\n * `pattern` property is converted to a RegExp before being passed as the\n * third argument to Rule(). (See Rule.makePattern() for details on the string\n * to RegExp conversion). Finally, the `message` property specifies an error\n * message that is passed as the final argument to Rule(). You can also use a\n * real RegExp as the value of the `pattern` property or define a custom lint\n * function on the `lint` property instead of setting the `message`\n * property. Doing either of these things means that your rule description can\n * no longer be saved in a JSON file, however.\n *\n * For example, here are two lint rules defined with Rule.makeRule():\n *\n * let nestedLists = Rule.makeRule({\n * name: \"nested-lists\",\n * selector: \"list list\",\n * message: `Nested lists:\n * nested lists are hard to read on mobile devices;\n * do not use additional indentation.`,\n * });\n *\n * let longParagraph = Rule.makeRule({\n * name: \"long-paragraph\",\n * selector: \"paragraph\",\n * pattern: /^.{501,}/,\n * lint: function(state, content, nodes, match) {\n * return `Paragraph too long:\n * This paragraph is ${content.length} characters long.\n * Shorten it to 500 characters or fewer.`;\n * },\n * });\n *\n * Certain advanced lint rules need additional information about the content\n * being linted in order to detect lint. For example, a rule to check for\n * whitespace at the start and end of the URL for an image can't use the\n * information in the node or content arguments because the markdown parser\n * strips leading and trailing whitespace when parsing. (Nevertheless, these\n * spaces have been a practical problem for our content translation process so\n * in order to check for them, a lint rule needs access to the original\n * unparsed source text. Similarly, there are various lint rules that check\n * widget usage. For example, it is easy to write a lint rule to ensure that\n * images have alt text for images encoded in markdown. But when images are\n * added to our content via an image widget we also want to be able to check\n * for alt text. In order to do this, the lint rule needs to be able to look\n * widgets up by name in the widgets object associated with the parse tree.\n *\n * In order to support advanced linting rules like these, the check() method\n * takes a context object as its optional fourth argument, and passes this\n * object on to the lint function of each rule. Rules that require extra\n * context should not assume that they will always get it, and should verify\n * that the necessary context has been supplied before using it. Currently the\n * \"content\" property of the context object is the unparsed source text if\n * available, and the \"widgets\" property of the context object is the widget\n * object associated with that content string in the JSON object that defines\n * the Perseus article or exercise that is being linted.\n */\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\nimport Selector from \"./selector\";\n\nimport type {TraversalState, TreeNode} from \"./tree-transformer\";\n\nexport type MakeRuleOptions = {\n name: string;\n pattern?: RegExp;\n severity?: number;\n selector?: string;\n locale?: string;\n message?: string;\n lint?: (\n state: TraversalState,\n content: string,\n nodes: any,\n match: any,\n context: LintRuleContextObject,\n ) => string | undefined;\n applies?: AppliesTester;\n};\n\n// This represents the type returned by String.match(). It is an\n// array of strings, but also has index:number and input:string properties.\n// TypeScript doesn't handle it well, so we punt and just use any.\ntype PatternMatchType = any;\n\n// This is the return type of the check() method of a Rule object\ntype RuleCheckReturnType =\n | {\n rule: string;\n message: string;\n start: number;\n end: number;\n severity?: number;\n }\n | null\n | undefined;\n\n// This is the return type of the lint detection function passed as the 4th\n// argument to the Rule() constructor. It can return null or a string or an\n// object containing a string and two numbers.\n// prettier-ignore\n// (prettier formats this in a way that ka-lint does not like)\ntype LintTesterReturnType = string | {\n message: string,\n start: number,\n end: number\n} | null | undefined;\n\ntype LintRuleContextObject =\n | {\n content: string;\n contentType: \"article\" | \"exercise\";\n stack: string[];\n widgets: any[];\n }\n | null\n | undefined;\n\n// This is the type of the lint detection function that the Rule() constructor\n// expects as its fourth argument. It is passed the TraversalState object and\n// content string that were passed to check(), and is also passed the array of\n// nodes returned by the selector match and the array of strings returned by\n// the pattern match. It should return null if no lint is detected or an\n// error message or an object contining an error message.\ntype LintTester = (\n state: TraversalState,\n content: string,\n selectorMatch: ReadonlyArray<TreeNode>,\n patternMatch: PatternMatchType,\n context: LintRuleContextObject,\n) => LintTesterReturnType;\n\n// An optional check to verify whether or not a particular rule should\n// be checked by context. For example, some rules only apply in exercises,\n// and should never be applied to articles. Defaults to true, so if we\n// omit the applies function in a rule, it'll be tested everywhere.\ntype AppliesTester = (context: LintRuleContextObject) => boolean;\n\n/**\n * A Rule object describes a Perseus lint rule. See the comment at the top of\n * this file for detailed description.\n */\nexport default class Rule {\n name: string; // The name of the rule\n severity: number; // The severity of the rule\n selector: Selector; // The specified selector or the DEFAULT_SELECTOR\n pattern: RegExp | null | undefined; // A regular expression if one was specified\n lint: LintTester; // The lint-testing function or a default\n applies: AppliesTester; // Checks to see if we should apply a rule or not\n message: string | null | undefined; // The error message for use with the default function\n static DEFAULT_SELECTOR: Selector;\n\n // The comment at the top of this file has detailed docs for\n // this constructor and its arguments\n constructor(\n name: string | null | undefined,\n severity: number | null | undefined,\n selector: Selector | null | undefined,\n pattern: RegExp | null | undefined,\n lint: LintTester | string | undefined,\n applies: AppliesTester | undefined,\n ) {\n if (!selector && !pattern) {\n throw new PerseusError(\n \"Lint rules must have a selector or pattern\",\n Errors.InvalidInput,\n {metadata: {name}},\n );\n }\n\n this.name = name || \"unnamed rule\";\n this.severity = severity || Rule.Severity.BULK_WARNING;\n this.selector = selector || Rule.DEFAULT_SELECTOR;\n this.pattern = pattern || null;\n\n // If we're called with an error message instead of a function then\n // use a default function that will return the message.\n if (typeof lint === \"function\") {\n this.lint = lint;\n this.message = null;\n } else {\n this.lint = (...args) => this._defaultLintFunction(...args);\n this.message = lint;\n }\n\n this.applies =\n applies ||\n function () {\n return true;\n };\n }\n\n // A factory method for use with rules described in JSON files\n // See the documentation at the start of this file for details.\n static makeRule(options: MakeRuleOptions): Rule {\n return new Rule(\n options.name,\n options.severity,\n options.selector ? Selector.parse(options.selector) : null,\n Rule.makePattern(options.pattern),\n options.lint || options.message,\n options.applies,\n );\n }\n\n // Check the node n to see if it violates this lint rule. A return value\n // of false means there is no lint. A returned object indicates a lint\n // error. See the documentation at the top of this file for details.\n check(\n node: TreeNode,\n traversalState: TraversalState,\n content: string,\n context: LintRuleContextObject,\n ): RuleCheckReturnType {\n // First, see if we match the selector.\n // If no selector was passed to the constructor, we use a\n // default selector that matches text nodes.\n const selectorMatch = this.selector.match(traversalState);\n\n // If the selector did not match, then we're done\n if (!selectorMatch) {\n return null;\n }\n\n // If the selector matched, then see if the pattern matches\n let patternMatch;\n if (this.pattern) {\n patternMatch = content.match(this.pattern);\n } else {\n // If there is no pattern, then just match all of the content.\n // Use a fake RegExp match object to represent this default match.\n patternMatch = Rule.FakePatternMatch(content, content, 0);\n }\n\n // If there was a pattern and it didn't match, then we're done\n if (!patternMatch) {\n return null;\n }\n\n try {\n // If we get here, then the selector and pattern have matched\n // so now we call the lint function to see if there is lint.\n const error = this.lint(\n traversalState,\n content,\n selectorMatch,\n patternMatch,\n context,\n );\n\n if (!error) {\n return null; // No lint; we're done\n }\n if (typeof error === \"string\") {\n // If the lint function returned a string we assume it\n // applies to the entire content of the node and return it.\n return {\n rule: this.name,\n severity: this.severity,\n message: error,\n start: 0,\n end: content.length,\n };\n }\n // If the lint function returned an object, then we just\n // add the rule name to the message, start and end.\n return {\n rule: this.name,\n severity: this.severity,\n message: error.message,\n start: error.start,\n end: error.end,\n };\n } catch (e: any) {\n // If the lint function threw an exception we handle that as\n // a special type of lint. We want the user to see the lint\n // warning in this case (even though it is out of their control)\n // so that the bug gets reported. Otherwise we'd never know that\n // a rule was failing.\n return {\n rule: \"lint-rule-failure\",\n message: `Exception in rule ${this.name}: ${e.message}\nStack trace:\n${e.stack}`,\n start: 0,\n end: content.length,\n };\n }\n }\n\n // This internal method is the default lint function that we use when a\n // rule is defined without a function. This is useful for rules where the\n // selector and/or pattern match are enough to indicate lint. This\n // function unconditionally returns the error message that was passed in\n // place of a function, but also adds start and end properties that\n // specify which particular portion of the node content matched the\n // pattern.\n _defaultLintFunction(\n state: TraversalState,\n content: string,\n selectorMatch: ReadonlyArray<TreeNode>,\n patternMatch: PatternMatchType,\n context: LintRuleContextObject,\n ): {\n end: number;\n message: string;\n start: number;\n } {\n return {\n message: this.message || \"\",\n start: patternMatch.index,\n end: patternMatch.index + patternMatch[0].length,\n };\n }\n\n // The makeRule() factory function uses this static method to turn its\n // argument into a RegExp. If the argument is already a RegExp, we just\n // return it. Otherwise, we compile it into a RegExp and return that.\n // The reason this is necessary is that Rule.makeRule() is designed for\n // use with data from JSON files and JSON files can't include RegExp\n // literals. Strings passed to this function do not need to be delimited\n // with / characters unless you want to include flags for the RegExp.\n //\n // Examples:\n //\n // input \"\" ==> output null\n // input /foo/ ==> output /foo/\n // input \"foo\" ==> output /foo/\n // input \"/foo/i\" ==> output /foo/i\n //\n static makePattern(\n pattern?: RegExp | string | null,\n ): RegExp | null | undefined {\n if (!pattern) {\n return null;\n }\n if (pattern instanceof RegExp) {\n return pattern;\n }\n if (pattern[0] === \"/\") {\n const lastSlash = pattern.lastIndexOf(\"/\");\n const expression = pattern.substring(1, lastSlash);\n const flags = pattern.substring(lastSlash + 1);\n // @ts-expect-error - TS2713 - Cannot access 'RegExp.flags' because 'RegExp' is a type, but not a namespace. Did you mean to retrieve the type of the property 'flags' in 'RegExp' with 'RegExp[\"flags\"]'?\n return new RegExp(expression, flags as RegExp.flags);\n }\n return new RegExp(pattern);\n }\n\n // This static method returns an string array with index and input\n // properties added, in order to simulate the return value of the\n // String.match() method. We use it when a Rule has no pattern and we\n // want to simulate a match on the entire content string.\n static FakePatternMatch(\n input: string,\n match: string | null | undefined,\n index: number,\n ): PatternMatchType {\n const result: any = [match];\n result.index = index;\n result.input = input;\n return result;\n }\n\n static Severity: {\n BULK_WARNING: number;\n ERROR: number;\n GUIDELINE: number;\n WARNING: number;\n } = {\n ERROR: 1,\n WARNING: 2,\n GUIDELINE: 3,\n BULK_WARNING: 4,\n };\n}\n\nRule.DEFAULT_SELECTOR = Selector.parse(\"text\");\n","/* eslint-disable no-useless-escape */\n// Return the portion of a URL between // and /. This is the authority\n// portion which is usually just the hostname, but may also include\n// a username, password or port. We don't strip those things out because\n// we typically want to reject any URL that includes them\nconst HOSTNAME = /\\/\\/([^\\/]+)/;\n\n// Return the hostname of the URL, with any \"www.\" prefix removed.\n// If this is a relative URL with no hostname, return an empty string.\nexport function getHostname(url: string): string {\n if (!url) {\n return \"\";\n }\n const match = url.match(HOSTNAME);\n return match ? match[1] : \"\";\n}\n","import Rule from \"../rule\";\n\nimport {getHostname} from \"./lint-utils\";\n\nexport default Rule.makeRule({\n name: \"absolute-url\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"link, image\",\n lint: function (state, content, nodes, match) {\n const url = nodes[0].target;\n const hostname = getHostname(url);\n\n if (\n hostname === \"khanacademy.org\" ||\n hostname.endsWith(\".khanacademy.org\")\n ) {\n return `Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"blockquoted-math\",\n severity: Rule.Severity.WARNING,\n selector: \"blockQuote math, blockQuote blockMath\",\n message: `Blockquoted math:\nmath should not be indented.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"blockquoted-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"blockQuote widget\",\n message: `Blockquoted widget:\nwidgets should not be indented.`,\n}) as Rule;\n","/* eslint-disable no-useless-escape */\nimport Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"double-spacing-after-terminal\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"paragraph\",\n pattern: /[.!\\?] {2}/i,\n message: `Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nfunction buttonNotInButtonSet(name: string, set: string): string {\n return `Answer requires a button not found in the button sets: ${name} (in ${set})`;\n}\n\nconst stringToButtonSet = {\n \"\\\\sqrt\": \"prealgebra\",\n \"\\\\sin\": \"trig\",\n \"\\\\cos\": \"trig\",\n \"\\\\tan\": \"trig\",\n \"\\\\log\": \"logarithms\",\n \"\\\\ln\": \"logarithms\",\n};\n\n/**\n * Rule to make sure that Expression questions that require\n * a specific math symbol to answer have that math symbol\n * available in the keypad (desktop learners can use a keyboard,\n * but mobile learners must use the MathInput keypad)\n */\nexport default Rule.makeRule({\n name: \"expression-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: function (state, content, nodes, match, context) {\n // This rule only looks at image widgets\n if (state.currentNode().widgetType !== \"expression\") {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n // If it can't find a definition for the widget it does nothing\n const widget = context?.widgets?.[nodeId];\n if (!widget) {\n return;\n }\n\n const answers = widget.options.answerForms;\n const buttons = widget.options.buttonSets;\n for (const answer of answers) {\n for (const [str, set] of Object.entries(stringToButtonSet)) {\n if (answer.value.includes(str) && !buttons.includes(set)) {\n return buttonNotInButtonSet(str, set);\n }\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"extra-content-spacing\",\n selector: \"paragraph\",\n pattern: /\\s+$/,\n applies: function (context) {\n return context?.contentType === \"article\";\n },\n message: `No extra whitespace at the end of content blocks.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-level-1\",\n severity: Rule.Severity.WARNING,\n selector: \"heading\",\n lint: function (state, content, nodes, match) {\n if (nodes[0].level === 1) {\n return `Don't use level-1 headings:\nBegin headings with two or more # characters.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-level-skip\",\n severity: Rule.Severity.WARNING,\n selector: \"heading ~ heading\",\n lint: function (state, content, nodes, match) {\n const currentHeading = nodes[1];\n const previousHeading = nodes[0];\n // A heading can have a level less than, the same as\n // or one more than the previous heading. But going up\n // by 2 or more levels is not right\n if (currentHeading.level > previousHeading.level + 1) {\n return `Skipped heading level:\nthis heading is level ${currentHeading.level} but\nthe previous heading was level ${previousHeading.level}`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-sentence-case\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"heading\",\n pattern: /^\\W*[a-z]/, // first letter is lowercase\n message: `First letter is lowercase:\nthe first letter of a heading should be capitalized.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\n// These are 3-letter and longer words that we would not expect to be\n// capitalized even in a title-case heading. See\n// http://blog.apastyle.org/apastyle/2012/03/title-case-and-sentence-case-capitalization-in-apa-style.html\nconst littleWords = {\n and: true,\n nor: true,\n but: true,\n the: true,\n for: true,\n} as const;\n\nfunction isCapitalized(word: any) {\n const c = word[0];\n return c === c.toUpperCase();\n}\n\nexport default Rule.makeRule({\n name: \"heading-title-case\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"heading\",\n pattern: /[^\\s:]\\s+[A-Z]+[a-z]/,\n locale: \"en\",\n lint: function (state, content, nodes, match) {\n // We want to assert that heading text is in sentence case, not\n // title case. The pattern above requires a capital letter at the\n // start of the heading and allows them after a colon, or in\n // acronyms that are all capitalized.\n //\n // But we can't warn just because the pattern matched because\n // proper nouns are also allowed bo be capitalized. We're not\n // going to do dictionary lookup to check for proper nouns, so\n // we try a heuristic: if the title is more than 3 words long\n // and if all the words are capitalized or are on the list of\n // words that don't get capitalized, then we'll assume that\n // the heading is incorrectly in title case and will warn.\n // But if there is at least one non-capitalized long word then\n // we're not in title case and we should not warn.\n //\n // TODO(davidflanagan): if this rule causes a lot of false\n // positives, we should tweak it or remove it. Note that it will\n // fail for headings like \"World War II in Russia\"\n //\n // TODO(davidflanagan): This rule is specific to English.\n // It is marked with a locale property above, but that is NYI\n //\n // for APA style rules for title case\n\n const heading = content.trim();\n let words = heading.split(/\\s+/);\n\n // Remove the first word and the little words\n words.shift();\n words = words.filter(\n // eslint-disable-next-line no-prototype-builtins\n (w) => w.length > 2 && !littleWords.hasOwnProperty(w),\n );\n\n // If there are at least 3 remaining words and all\n // are capitalized, then the heading is in title case.\n if (words.length >= 3 && words.every((w) => isCapitalized(w))) {\n return `Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-alt-text\",\n severity: Rule.Severity.WARNING,\n selector: \"image\",\n lint: function (state, content, nodes, match) {\n const image = nodes[0];\n if (!image.alt || !image.alt.trim()) {\n return `Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !.`;\n }\n if (image.alt.length < 8) {\n return `Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ${image.alt.length} characters long.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-in-table\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"table image\",\n message: `Image in table:\ndo not put images inside of tables.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-spaces-around-urls\",\n severity: Rule.Severity.ERROR,\n selector: \"image\",\n lint: function (state, content, nodes, match, context) {\n const image = nodes[0];\n const url = image.target;\n\n // The markdown parser strips leading and trailing spaces for us,\n // but they're still a problem for our translation process, so\n // we need to go check for them in the unparsed source string\n // if we have it.\n if (context && context.content) {\n // Find the url in the original content and make sure that the\n // character before is '(' and the character after is ')'\n const index = context.content.indexOf(url);\n if (index === -1) {\n // It is not an error if we didn't find it.\n return;\n }\n\n if (\n context.content[index - 1] !== \"(\" ||\n context.content[index + url.length] !== \")\"\n ) {\n return `Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties.`;\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Normally we have one rule per file. But since our selector class\n// can't match specific widget types directly, this rule implements\n// a number of image widget related rules in one place. This should\n// slightly increase efficiency, but it means that if there is more\n// than one problem with an image widget, the user will only see one\n// problem at a time.\nexport default Rule.makeRule({\n name: \"image-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: function (state, content, nodes, match, context) {\n // This rule only looks at image widgets\n if (state.currentNode().widgetType !== \"image\") {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n // If it can't find a definition for the widget it does nothing\n const widget = context && context.widgets && context.widgets[nodeId];\n if (!widget) {\n return;\n }\n\n // Make sure there is alt text\n const alt = widget.options.alt;\n if (!alt) {\n return `Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the \"Alt Text\" box of the image widget.`;\n }\n\n // Make sure the alt text it is not trivial\n if (alt.trim().length < 8) {\n return `Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ${alt.trim().length} characters long.`;\n }\n\n // Make sure there is no math in the caption\n if (widget.options.caption && widget.options.caption.match(/[^\\\\]\\$/)) {\n return `No math in image captions:\nDon't include math expressions in image captions.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"link-click-here\",\n severity: Rule.Severity.WARNING,\n selector: \"link\",\n pattern: /click here/i,\n message: `Inappropriate link text:\nDo not use the words \"click here\" in links.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"long-paragraph\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"paragraph\",\n pattern: /^.{501,}/,\n lint: function (state, content, nodes, match) {\n return `Paragraph too long:\nThis paragraph is ${content.length} characters long.\nShorten it to 500 characters or fewer.`;\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-adjacent\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath+blockMath\",\n message: `Adjacent math blocks:\ncombine the blocks between \\\\begin{align} and \\\\end{align}`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-align-extra-break\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath\",\n pattern: /(\\\\{2,})\\s*\\\\end{align}/,\n message: `Extra space at end of block:\nDon't end an align block with backslashes`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-align-linebreaks\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath\",\n // Match any align block with double backslashes in it\n // Use [\\s\\S]* instead of .* so we match newlines as well.\n pattern: /\\\\begin{align}[\\s\\S]*\\\\\\\\[\\s\\S]+\\\\end{align}/,\n // Look for double backslashes and ensure that they are\n // followed by optional space and another pair of backslashes.\n // Note that this rule can't know where line breaks belong so\n // it can't tell whether backslashes are completely missing. It just\n // enforces that you don't have the wrong number of pairs of backslashes.\n lint: function (state, content, nodes, match) {\n let text = match[0];\n while (text.length) {\n const index = text.indexOf(\"\\\\\\\\\");\n if (index === -1) {\n // No more backslash pairs, so we found no lint\n return;\n }\n text = text.substring(index + 2);\n\n // Now we expect to find optional spaces, another pair of\n // backslashes, and more optional spaces not followed immediately\n // by another pair of backslashes.\n const nextpair = text.match(/^\\s*\\\\\\\\\\s*(?!\\\\\\\\)/);\n\n // If that does not match then we either have too few or too\n // many pairs of backslashes.\n if (!nextpair) {\n return \"Use four backslashes between lines of an align block\";\n }\n\n // If it did match, then, shorten the string and continue looping\n // (because a single align block may have multiple lines that\n // all must be separated by two sets of double backslashes).\n text = text.substring(nextpair[0].length);\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-empty\",\n severity: Rule.Severity.WARNING,\n selector: \"math, blockMath\",\n pattern: /^$/,\n message: \"Empty math: don't use $$ in your markdown.\",\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-font-size\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern:\n /\\\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\\s*{/,\n message: `Math font size:\nDon't change the default font size with \\\\Large{} or similar commands`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-frac\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern: /\\\\frac[ {]/,\n message: \"Use \\\\dfrac instead of \\\\frac in your math expressions.\",\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-nested\",\n severity: Rule.Severity.ERROR,\n selector: \"math, blockMath\",\n pattern: /\\\\text{[^$}]*\\$[^$}]*\\$[^}]*}/,\n message: `Nested math:\nDon't nest math expressions inside \\\\text{} blocks`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-starts-with-space\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern: /^\\s*(~|\\\\qquad|\\\\quad|\\\\,|\\\\;|\\\\:|\\\\ |\\\\!|\\\\enspace|\\\\phantom)/,\n message: `Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\\\;, \\\\quad, or \\\\phantom`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-text-empty\",\n severity: Rule.Severity.WARNING,\n selector: \"math, blockMath\",\n pattern: /\\\\text{\\s*}/,\n message: \"Empty \\\\text{} block in math expression\",\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Because no selector is specified, this rule only applies to text nodes.\n// Math and code hold their content directly and do not have text nodes\n// beneath them (unlike the HTML DOM) so this rule automatically does not\n// apply inside $$ or ``.\nexport default Rule.makeRule({\n name: \"math-without-dollars\",\n severity: Rule.Severity.GUIDELINE,\n pattern: /\\\\\\w+{[^}]*}|{|}/,\n message: `This looks like LaTeX:\ndid you mean to put it inside dollar signs?`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"nested-lists\",\n severity: Rule.Severity.WARNING,\n selector: \"list list\",\n message: `Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"static-widget-in-question-stem\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: (state, content, nodes, match, context) => {\n if (context?.contentType !== \"exercise\") {\n return;\n }\n\n if (context.stack.includes(\"hint\")) {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n const widget = context?.widgets?.[nodeId];\n if (!widget) {\n return;\n }\n\n if (widget.static) {\n return `Widget in question stem is static (non-interactive).`;\n }\n },\n});\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"table-missing-cells\",\n severity: Rule.Severity.WARNING,\n selector: \"table\",\n lint: function (state, content, nodes, match) {\n const table = nodes[0];\n const headerLength = table.header.length;\n const rowLengths = table.cells.map((r) => r.length);\n for (let r = 0; r < rowLengths.length; r++) {\n if (rowLengths[r] !== headerLength) {\n return `Table rows don't match header:\nThe table header has ${headerLength} cells, but\nRow ${r + 1} has ${rowLengths[r]} cells.`;\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Because no selector is specified, this rule only applies to text nodes.\n// Math and code hold their content directly and do not have text nodes\n// beneath them (unlike the HTML DOM) so this rule automatically does not\n// apply inside $$ or ``.\nexport default Rule.makeRule({\n name: \"unbalanced-code-delimiters\",\n severity: Rule.Severity.ERROR,\n pattern: /[`~]+/,\n message: `Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"unescaped-dollar\",\n severity: Rule.Severity.ERROR,\n selector: \"unescapedDollar\",\n message: `Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\\\$`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"widget-in-table\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"table widget\",\n message: `Widget in table:\ndo not put widgets inside of tables.`,\n}) as Rule;\n","// TODO(davidflanagan):\n// This should probably be converted to use import and to export\n// and object that maps rule names to rules. Also, maybe this should\n// be an auto-generated file with a script that updates it any time\n// we add a new rule?\n\nimport AbsoluteUrl from \"./absolute-url\";\nimport BlockquotedMath from \"./blockquoted-math\";\nimport BlockquotedWidget from \"./blockquoted-widget\";\nimport DoubleSpacingAfterTerminal from \"./double-spacing-after-terminal\";\nimport ExpressionWidget from \"./expression-widget\";\nimport ExtraContentSpacing from \"./extra-content-spacing\";\nimport HeadingLevel1 from \"./heading-level-1\";\nimport HeadingLevelSkip from \"./heading-level-skip\";\nimport HeadingSentenceCase from \"./heading-sentence-case\";\nimport HeadingTitleCase from \"./heading-title-case\";\nimport ImageAltText from \"./image-alt-text\";\nimport ImageInTable from \"./image-in-table\";\nimport ImageSpacesAroundUrls from \"./image-spaces-around-urls\";\nimport ImageWidget from \"./image-widget\";\nimport LinkClickHere from \"./link-click-here\";\nimport LongParagraph from \"./long-paragraph\";\nimport MathAdjacent from \"./math-adjacent\";\nimport MathAlignExtraBreak from \"./math-align-extra-break\";\nimport MathAlignLinebreaks from \"./math-align-linebreaks\";\nimport MathEmpty from \"./math-empty\";\nimport MathFontSize from \"./math-font-size\";\nimport MathFrac from \"./math-frac\";\nimport MathNested from \"./math-nested\";\nimport MathStartsWithSpace from \"./math-starts-with-space\";\nimport MathTextEmpty from \"./math-text-empty\";\nimport MathWithoutDollars from \"./math-without-dollars\";\nimport NestedLists from \"./nested-lists\";\nimport StaticWidgetInQuestionStem from \"./static-widget-in-question-stem\";\nimport TableMissingCells from \"./table-missing-cells\";\nimport UnbalancedCodeDelimiters from \"./unbalanced-code-delimiters\";\nimport UnescapedDollar from \"./unescaped-dollar\";\nimport WidgetInTable from \"./widget-in-table\";\n\nexport default [\n AbsoluteUrl,\n BlockquotedMath,\n BlockquotedWidget,\n DoubleSpacingAfterTerminal,\n ExpressionWidget,\n ExtraContentSpacing,\n HeadingLevel1,\n HeadingLevelSkip,\n HeadingSentenceCase,\n HeadingTitleCase,\n ImageAltText,\n ImageInTable,\n LinkClickHere,\n LongParagraph,\n MathAdjacent,\n MathAlignExtraBreak,\n MathAlignLinebreaks,\n MathEmpty,\n MathFontSize,\n MathFrac,\n MathNested,\n MathStartsWithSpace,\n MathTextEmpty,\n NestedLists,\n StaticWidgetInQuestionStem,\n TableMissingCells,\n UnescapedDollar,\n WidgetInTable,\n MathWithoutDollars,\n UnbalancedCodeDelimiters,\n ImageSpacesAroundUrls,\n ImageWidget,\n];\n","/**\n * TreeTransformer is a class for traversing and transforming trees. Create a\n * TreeTransformer by passing the root node of the tree to the\n * constructor. Then traverse that tree by calling the traverse() method. The\n * argument to traverse() is a callback function that will be called once for\n * each node in the tree. This is a post-order depth-first traversal: the\n * callback is not called on the a way down, but on the way back up. That is,\n * the children of a node are traversed before the node itself is.\n *\n * The traversal callback function is passed three arguments, the node being\n * traversed, a TraversalState object, and the concatentated text content of\n * the node and all of its descendants. The TraversalState object is the most\n * most interesting argument: it has methods for querying the ancestors and\n * siblings of the node, and for deleting or replacing the node. These\n * transformation methods are why this class is a tree transformer and not\n * just a tree traverser.\n *\n * A typical tree traversal looks like this:\n *\n * new TreeTransformer(root).traverse((node, state, content) => {\n * let parent = state.parent();\n * let previous = state.previousSibling();\n * // etc.\n * });\n *\n * The traverse() method descends through nodes and arrays of nodes and calls\n * the traverse callback on each node on the way back up to the root of the\n * tree. (Note that it only calls the callback on the nodes themselves, not\n * any arrays that contain nodes.) A node is loosely defined as any object\n * with a string-valued `type` property. Objects that do not have a type\n * property are assumed to not be part of the tree and are not traversed. When\n * traversing an array, all elements of the array are examined, and any that\n * are nodes or arrays are recursively traversed. When traversing a node, all\n * properties of the object are examined and any node or array values are\n * recursively traversed. In typical parse trees, the children of a node are\n * in a `children` or `content` array, but this class is designed to handle\n * more general trees. The Perseus markdown parser, for example, produces\n * nodes of type \"table\" that have children in the `header` and `cells`\n * properties.\n *\n * CAUTION: the traverse() method does not make any attempt to detect\n * cycles. If you call it on a cyclic graph instead of a tree, it will cause\n * infinite recursion (or, more likely, a stack overflow).\n *\n * TODO(davidflanagan): it probably wouldn't be hard to detect cycles: when\n * pushing a new node onto the containers stack we could just check that it\n * isn't already there.\n *\n * If a node has a text-valued `content` property, it is taken to be the\n * plain-text content of the node. The traverse() method concatenates these\n * content strings and passes them to the traversal callback for each\n * node. This means that the callback has access the full text content of its\n * node and all of the nodes descendants.\n *\n * See the TraversalState class for more information on what information and\n * methods are available to the traversal callback.\n **/\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\n// TreeNode is the type of a node in a parse tree. The only real requirement is\n// that every node has a string-valued `type` property\nexport type TreeNode = {\n type: string;\n widgetType?: string;\n id?: string;\n};\n\n// TraversalCallback is the type of the callback function passed to the\n// traverse() method. It is invoked with node, state, and content arguments\n// and is expected to return nothing.\nexport type TraversalCallback = (\n node: TreeNode,\n state: TraversalState,\n content: string,\n) => void;\n\n// This is the TreeTransformer class described in detail at the\n// top of this file.\nexport default class TreeTransformer {\n root: TreeNode;\n\n // To create a tree transformer, just pass the root node of the tree\n constructor(root: TreeNode) {\n this.root = root;\n }\n\n // A utility function for determing whether an arbitrary value is a node\n static isNode(n: any): boolean {\n return n && typeof n === \"object\" && typeof n.type === \"string\";\n }\n\n // Determines whether a value is a node with type \"text\" and has\n // a text-valued `content` property.\n static isTextNode(n: any): boolean {\n return (\n TreeTransformer.isNode(n) &&\n n.type === \"text\" &&\n typeof n.content === \"string\"\n );\n }\n\n // This is the main entry point for the traverse() method. See the comment\n // at the top of this file for a detailed description. Note that this\n // method just creates a new TraversalState object to use for this\n // traversal and then invokes the internal _traverse() method to begin the\n // recursion.\n traverse(f: TraversalCallback): void {\n this._traverse(this.root, new TraversalState(this.root), f);\n }\n\n // Do a post-order traversal of node and its descendants, invoking the\n // callback function f() once for each node and returning the concatenated\n // text content of the node and its descendants. f() is passed three\n // arguments: the current node, a TraversalState object representing the\n // current state of the traversal, and a string that holds the\n // concatenated text of the node and its descendants.\n //\n // This private method holds all the traversal logic and implementation\n // details. Note that this method uses the TraversalState object to store\n // information about the structure of the tree.\n _traverse(\n n: TreeNode | Array<TreeNode>,\n state: TraversalState,\n f: TraversalCallback,\n ): string {\n let content = \"\";\n if (TreeTransformer.isNode(n)) {\n // If we were called on a node object, then we handle it\n // this way.\n const node = n as TreeNode; // safe cast; we just tested\n\n // Put the node on the stack before recursing on its children\n state._containers.push(node);\n state._ancestors.push(node);\n\n // Record the node's text content if it has any.\n // Usually this is for nodes with a type property of \"text\",\n // but other nodes types like \"math\" may also have content.\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n if (typeof node.content === \"string\") {\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n content = node.content;\n }\n\n // Recurse on the node. If there was content above, then there\n // probably won't be any children to recurse on, but we check\n // anyway.\n //\n // If we wanted to make the traversal completely specific to the\n // actual Perseus parse trees that we'll be dealing with we could\n // put a switch statement here to dispatch on the node type\n // property with specific recursion steps for each known type of\n // node.\n const keys = Object.keys(node);\n keys.forEach((key) => {\n // Never recurse on the type property\n if (key === \"type\") {\n return;\n }\n // Ignore properties that are null or primitive and only\n // recurse on objects and arrays. Note that we don't do a\n // isNode() check here. That is done in the recursive call to\n // _traverse(). Note that the recursive call on each child\n // returns the text content of the child and we add that\n // content to the content for this node. Also note that we\n // push the name of the property we're recursing over onto a\n // TraversalState stack.\n const value = node[key];\n if (value && typeof value === \"object\") {\n state._indexes.push(key);\n content += this._traverse(value, state, f);\n state._indexes.pop();\n }\n });\n\n // Restore the stacks after recursing on the children\n state._currentNode = state._ancestors.pop();\n state._containers.pop();\n\n // And finally call the traversal callback for this node. Note\n // that this is post-order traversal. We call the callback on the\n // way back up the tree, not on the way down. That way we already\n // know all the content contained within the node.\n f(node, state, content);\n } else if (Array.isArray(n)) {\n // If we were called on an array instead of a node, then\n // this is the code we use to recurse.\n const nodes = n;\n\n // Push the array onto the stack. This will allow the\n // TraversalState object to locate siblings of this node.\n state._containers.push(nodes);\n\n // Now loop through this array and recurse on each element in it.\n // Before recursing on an element, we push its array index on a\n // TraversalState stack so that the TraversalState sibling methods\n // can work. Note that TraversalState methods can alter the length\n // of the array, and change the index of the current node, so we\n // are careful here to test the array length on each iteration and\n // to reset the index when we pop the stack. Also note that we\n // concatentate the text content of the children.\n let index = 0;\n while (index < nodes.length) {\n state._indexes.push(index);\n content += this._traverse(nodes[index], state, f);\n // Casting to convince TypeScript that this is a number\n index = (state._indexes.pop() as number) + 1;\n }\n\n // Pop the array off the stack. Note, however, that we do not call\n // the traversal callback on the array. That function is only\n // called for nodes, not arrays of nodes.\n state._containers.pop();\n }\n\n // The _traverse() method always returns the text content of\n // this node and its children. This is the one piece of state that\n // is not tracked in the TraversalState object.\n return content;\n }\n}\n\n// An instance of this class is passed to the callback function for\n// each node traversed. The class itself is not exported, but its\n// methods define the API available to the traversal callback.\n\n/**\n * This class represents the state of a tree traversal. An instance is created\n * by the traverse() method of the TreeTransformer class to maintain the state\n * for that traversal, and the instance is passed to the traversal callback\n * function for each node that is traversed. This class is not intended to be\n * instantiated directly, but is exported so that its type can be used for\n * type annotaions.\n **/\nexport class TraversalState {\n // The root node of the tree being traversed\n root: TreeNode;\n\n // These are internal state properties. Use the accessor methods defined\n // below instead of using these properties directly. Note that the\n // _containers and _indexes stacks can have two different types of\n // elements, depending on whether we just recursed on an array or on a\n // node. This is hard for TypeScript to deal with, so you'll see a number of\n // type casts through the any type when working with these two properties.\n _currentNode: TreeNode | null | undefined;\n _containers: Stack<TreeNode | Array<TreeNode>>;\n _indexes: Stack<string | number>;\n _ancestors: Stack<TreeNode>;\n\n // The constructor just stores the root node and creates empty stacks.\n constructor(root: TreeNode) {\n this.root = root;\n\n // When the callback is called, this property will hold the\n // node that is currently being traversed.\n this._currentNode = null;\n\n // This is a stack of the objects and arrays that we've\n // traversed through before reaching the currentNode.\n // It is different than the ancestors array.\n this._containers = new Stack();\n\n // This stack has the same number of elements as the _containers\n // stack. The last element of this._indexes[] is the index of\n // the current node in the object or array that is the last element\n // of this._containers[]. If the last element of this._containers[] is\n // an array, then the last element of this stack will be a number.\n // Otherwise if the last container is an object, then the last index\n // will be a string property name.\n this._indexes = new Stack();\n\n // This is a stack of the ancestor nodes of the current one.\n // It is different than the containers[] stack because it only\n // includes nodes, not arrays.\n this._ancestors = new Stack();\n }\n\n /**\n * Return the current node in the traversal. Any time the traversal\n * callback is called, this method will return the name value as the\n * first argument to the callback.\n */\n currentNode(): TreeNode {\n return this._currentNode || this.root;\n }\n\n /**\n * Return the parent of the current node, if there is one, or null.\n */\n parent(): TreeNode | null | undefined {\n return this._ancestors.top();\n }\n\n /**\n * Return an array of ancestor nodes. The first element of this array is\n * the same as this.parent() and the last element is the root node. If we\n * are currently at the root node, the the returned array will be empty.\n * This method makes a copy of the internal state, so modifications to the\n * returned array have no effect on the traversal.\n */\n ancestors(): ReadonlyArray<TreeNode> {\n return this._ancestors.values();\n }\n\n /**\n * Return the next sibling of this node, if it has one, or null otherwise.\n */\n nextSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n\n // If we're at the root of the tree or if the parent is an\n // object instead of an array, then there are no siblings.\n if (!siblings || !Array.isArray(siblings)) {\n return null;\n }\n\n // The top index is a number because the top container is an array\n const index = this._indexes.top() as number;\n if (siblings.length > index + 1) {\n return siblings[index + 1];\n }\n return null; // There is no next sibling\n }\n\n /**\n * Return the previous sibling of this node, if it has one, or null\n * otherwise.\n */\n previousSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n\n // If we're at the root of the tree or if the parent is an\n // object instead of an array, then there are no siblings.\n if (!siblings || !Array.isArray(siblings)) {\n return null;\n }\n\n // The top index is a number because the top container is an array\n const index = this._indexes.top() as number;\n if (index > 0) {\n return siblings[index - 1];\n }\n return null; // There is no previous sibling\n }\n\n /**\n * Remove the next sibling node (if there is one) from the tree. Returns\n * the removed sibling or null. This method makes it easy to traverse a\n * tree and concatenate adjacent text nodes into a single node.\n */\n removeNextSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n if (siblings && Array.isArray(siblings)) {\n // top index is a number because top container is an array\n const index = this._indexes.top() as number;\n if (siblings.length > index + 1) {\n return siblings.splice(index + 1, 1)[0];\n }\n }\n return null;\n }\n\n /**\n * Replace the current node in the tree with the specified nodes. If no\n * nodes are passed, this is a node deletion. If one node (or array) is\n * passed, this is a 1-for-1 replacement. If more than one node is passed\n * then this is a combination of deletion and insertion. The new node or\n * nodes will not be traversed, so this method can safely be used to\n * reparent the current node node beneath a new parent.\n *\n * This method throws an error if you attempt to replace the root node of\n * the tree.\n */\n replace(...replacements: ReadonlyArray<TreeNode>): void {\n const parent = this._containers.top();\n if (!parent) {\n throw new PerseusError(\n \"Can't replace the root of the tree\",\n Errors.Internal,\n );\n }\n\n // The top of the container stack is either an array or an object\n // and the top of the indexes stack is a corresponding array index\n // or object property. This is hard for TypeScript, so we have to do some\n // unsafe casting and be careful when we use which cast version\n if (Array.isArray(parent)) {\n const index = this._indexes.top() as number;\n // For an array parent we just splice the new nodes in\n parent.splice(index, 1, ...replacements);\n // Adjust the index to account for the changed array length.\n // We don't want to traverse any of the newly inserted nodes.\n this._indexes.pop();\n this._indexes.push(index + replacements.length - 1);\n } else {\n const property = this._indexes.top() as string;\n // For an object parent we care how many new nodes there are\n if (replacements.length === 0) {\n // Deletion\n delete parent[property];\n } else if (replacements.length === 1) {\n // Replacement\n parent[property] = replacements[0];\n } else {\n // Replace one node with an array of nodes\n parent[property] = replacements;\n }\n }\n }\n\n /**\n * Returns true if the current node has a previous sibling and false\n * otherwise. If this method returns false, then previousSibling() will\n * return null, and goToPreviousSibling() will throw an error.\n */\n hasPreviousSibling(): boolean {\n return (\n Array.isArray(this._containers.top()) &&\n (this._indexes.top() as number) > 0\n );\n }\n\n /**\n * Modify this traversal state object to have the state it would have had\n * when visiting the previous sibling. Note that you may want to use\n * clone() to make a copy before modifying the state object like this.\n * This mutator method is not typically used during ordinary tree\n * traversals, but is used by the Selector class for matching multi-node\n * selectors.\n */\n goToPreviousSibling(): void {\n if (!this.hasPreviousSibling()) {\n throw new PerseusError(\n \"goToPreviousSibling(): node has no previous sibling\",\n Errors.Internal,\n );\n }\n\n this._currentNode = this.previousSibling();\n // Since we know that we have a previous sibling, we know that\n // the value on top of the stack is a number, but we have to do\n // this unsafe cast because TypeScript doesn't know that.\n const index = this._indexes.pop() as number;\n this._indexes.push(index - 1);\n }\n\n /**\n * Returns true if the current node has an ancestor and false otherwise.\n * If this method returns false, then the parent() method will return\n * null and goToParent() will throw an error\n */\n hasParent(): boolean {\n return this._ancestors.size() !== 0;\n }\n\n /**\n * Modify this object to look like it will look when we (later) visit the\n * parent node of this node. You should not modify the instance passed to\n * the tree traversal callback. Instead, make a copy with the clone()\n * method and modify that. This mutator method is not typically used\n * during ordinary tree traversals, but is used by the Selector class for\n * matching multi-node selectors that involve parent and ancestor\n * selectors.\n */\n goToParent(): void {\n if (!this.hasParent()) {\n throw new PerseusError(\n \"goToParent(): node has no ancestor\",\n Errors.NotAllowed,\n );\n }\n\n this._currentNode = this._ancestors.pop();\n\n // We need to pop the containers and indexes stacks at least once\n // and more as needed until we restore the invariant that\n // this._containers.top()[this.indexes.top()] === this._currentNode\n //\n while (\n this._containers.size() &&\n this._containers.top()[this._indexes.top()] !== this._currentNode\n ) {\n this._containers.pop();\n this._indexes.pop();\n }\n }\n\n /**\n * Return a new TraversalState object that is a copy of this one.\n * This method is useful in conjunction with the mutating methods\n * goToParent() and goToPreviousSibling().\n */\n clone(): TraversalState {\n const clone = new TraversalState(this.root);\n clone._currentNode = this._currentNode;\n clone._containers = this._containers.clone();\n clone._indexes = this._indexes.clone();\n clone._ancestors = this._ancestors.clone();\n return clone;\n }\n\n /**\n * Returns true if this TraversalState object is equal to that\n * TraversalState object, or false otherwise. This method exists\n * primarily for use by our unit tests.\n */\n equals(that: TraversalState): boolean {\n return (\n this.root === that.root &&\n this._currentNode === that._currentNode &&\n this._containers.equals(that._containers) &&\n this._indexes.equals(that._indexes) &&\n this._ancestors.equals(that._ancestors)\n );\n }\n}\n\n/**\n * This class is an internal utility that just treats an array as a stack\n * and gives us a top() method so we don't have to write expressions like\n * `ancestors[ancestors.length-1]`. The values() method automatically\n * copies the internal array so we don't have to worry about client code\n * modifying our internal stacks. The use of this Stack abstraction makes\n * the TraversalState class simpler in a number of places.\n */\nclass Stack<T> {\n stack: Array<T>;\n\n constructor(array?: ReadonlyArray<T> | null) {\n this.stack = array ? array.slice(0) : [];\n }\n\n /** Push a value onto the stack. */\n push(v: T): void {\n this.stack.push(v);\n }\n\n /** Pop a value off of the stack. */\n pop(): T {\n // @ts-expect-error - TS2322 - Type 'T | undefined' is not assignable to type 'T'.\n return this.stack.pop();\n }\n\n /** Return the top value of the stack without popping it. */\n top(): T {\n return this.stack[this.stack.length - 1];\n }\n\n /** Return a copy of the stack as an array */\n values(): ReadonlyArray<T> {\n return this.stack.slice(0);\n }\n\n /** Return the number of elements in the stack */\n size(): number {\n return this.stack.length;\n }\n\n /** Return a string representation of the stack */\n toString(): string {\n return this.stack.toString();\n }\n\n /** Return a shallow copy of the stack */\n clone(): Stack<T> {\n return new Stack(this.stack);\n }\n\n /**\n * Compare this stack to another and return true if the contents of\n * the two arrays are the same.\n */\n equals(that: Stack<T>): boolean {\n if (!that || !that.stack || that.stack.length !== this.stack.length) {\n return false;\n }\n for (let i = 0; i < this.stack.length; i++) {\n if (this.stack[i] !== that.stack[i]) {\n return false;\n }\n }\n return true;\n }\n}\n","// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\nimport {addLibraryVersionToPerseusDebug} from \"@khanacademy/perseus-core\";\n\nconst libName = \"@khanacademy/perseus-linter\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","// Define the shape of the linter context object that is passed through the\n// tree with additional information about what we are checking.\nimport PropTypes from \"prop-types\";\n\nimport type {LinterContextProps} from \"./types\";\n\nexport const linterContextProps = PropTypes.shape({\n contentType: PropTypes.string,\n highlightLint: PropTypes.bool,\n paths: PropTypes.arrayOf(PropTypes.string),\n stack: PropTypes.arrayOf(PropTypes.string),\n});\n\nexport const linterContextDefault: LinterContextProps = {\n contentType: \"\",\n highlightLint: false,\n paths: [] as ReadonlyArray<any>,\n stack: [] as ReadonlyArray<any>,\n};\n","import Rule from \"./rule\";\nimport AllRules from \"./rules/all-rules\";\nimport TreeTransformer from \"./tree-transformer\";\n\nexport {libVersion} from \"./version\";\n\nexport {linterContextProps, linterContextDefault} from \"./proptypes\";\nexport type {LinterContextProps} from \"./types\";\n\nconst allLintRules: ReadonlyArray<any> = AllRules.filter(\n (r) => r.severity < Rule.Severity.BULK_WARNING,\n);\n\nexport {Rule, allLintRules as rules};\n\n/**\n * Run the Perseus linter over the specified markdown parse tree,\n * with the specified context object, and\n * return a (possibly empty) array of lint warning objects. If the\n * highlight argument is true, this function also modifies the parse\n * tree to add \"lint\" nodes that can be visually rendered,\n * highlighting the problems for the user. The optional rules argument\n * is an array of Rule objects specifying which lint rules should be\n * applied to this parse tree. When omitted, a default set of rules is used.\n *\n * The context object may have additional properties that some lint\n * rules require:\n *\n * context.content is the source content string that was parsed to create\n * the parse tree.\n *\n * context.widgets is the widgets object associated\n * with the content string\n *\n * TODO: to make this even more general, allow the first argument to be\n * a string and run the parser over it in that case? (but ignore highlight\n * in that case). This would allow the one function to be used for both\n * online linting and batch linting.\n */\nexport function runLinter(\n tree: any,\n context: any,\n highlight: boolean,\n rules: ReadonlyArray<any> = allLintRules,\n): ReadonlyArray<any> {\n const warnings: Array<any> = [];\n const tt = new TreeTransformer(tree);\n\n // The markdown parser often outputs adjacent text nodes. We\n // coalesce them before linting for efficiency and accuracy.\n tt.traverse((node, state, content) => {\n if (TreeTransformer.isTextNode(node)) {\n let next = state.nextSibling();\n while (TreeTransformer.isTextNode(next)) {\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.\n node.content += next.content;\n state.removeNextSibling();\n next = state.nextSibling();\n }\n }\n });\n\n // HTML tables are complicated, and the CSS we use in\n // ../components/lint.jsx to display lint does not work to\n // correctly position the lint indicators in the margin when the\n // lint is inside a table. So as a workaround we keep track of all\n // the lint that appears within a table and move it up to the\n // table element itself.\n //\n // It is not ideal to have to do this here,\n // but it is cleaner here than fixing up the lint during rendering\n // in perseus-markdown.jsx. If our lint display was simpler and\n // did not require indicators in the margin, this wouldn't be a\n // problem. Or, if we modified the lint display stuff so that\n // indicator positioning and tooltip display were both handled\n // with JavaScript (instead of pure CSS), then we could avoid this\n // issue too. But using JavaScript has its own downsides: there is\n // risk that the linter JavaScript would interfere with\n // widget-related Javascript.\n let tableWarnings: Array<never> = [];\n let insideTable = false;\n\n // Traverse through the nodes of the parse tree. At each node, loop\n // through the array of lint rules and check whether there is a\n // lint violation at that node.\n tt.traverse((node, state, content) => {\n const nodeWarnings: Array<any> = [];\n\n // If our rule is only designed to be tested against a particular\n // content type and we're not in that content type, we don't need to\n // consider that rule.\n const applicableRules = rules.filter((r) => r.applies(context));\n\n // Generate a stack so we can identify our position in the tree in\n // lint rules\n const stack = [...context.stack];\n stack.push(node.type);\n\n const nodeContext = {\n ...context,\n stack: stack.join(\".\"),\n } as const;\n\n applicableRules.forEach((rule) => {\n const warning = rule.check(node, state, content, nodeContext);\n if (warning) {\n // The start and end locations are relative to this\n // particular node, and so are not generally very useful.\n // TODO: When the markdown parser saves the node\n // locations in the source string then we can add\n // these numbers to that one and get and absolute\n // character range that will be useful\n if (warning.start || warning.end) {\n warning.target = content.substring(\n warning.start,\n warning.end,\n );\n }\n\n // Add the warning to the list of all lint we've found\n warnings.push(warning);\n\n // If we're going to be highlighting lint, then we also\n // need to keep track of warnings specific to this node.\n if (highlight) {\n nodeWarnings.push(warning);\n }\n }\n });\n\n // If we're not highlighting lint in the tree, then we're done\n // traversing this node.\n if (!highlight) {\n return;\n }\n\n // If the node we are currently at is a table, and there was lint\n // inside the table, then we want to add that lint here\n if (node.type === \"table\") {\n if (tableWarnings.length) {\n nodeWarnings.push(...tableWarnings);\n }\n\n // We're not in a table anymore, and don't have to remember\n // the warnings for the table\n insideTable = false;\n tableWarnings = [];\n } else if (!insideTable) {\n // Otherwise, if we are not already inside a table, check\n // to see if we've entered one. Because this is a post-order\n // traversal we'll see the table contents before the table itself.\n // Note that once we're inside the table, we don't have to\n // do this check each time... We can just wait until we ascend\n // up to the table, then we'll know we're out of it.\n insideTable = state.ancestors().some((n) => n.type === \"table\");\n }\n\n // If we are inside a table and there were any warnings on\n // this node, then we need to save the warnings for display\n // on the table itself\n if (insideTable && nodeWarnings.length) {\n // @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.\n tableWarnings.push(...nodeWarnings);\n }\n\n // If there were any warnings on this node, and if we're highlighting\n // lint, then reparent the node so we can highlight it. Note that\n // a single node can have multiple warnings. If this happends we\n // concatenate the warnings and newline separate them. (The lint.jsx\n // component that displays the warnings may want to convert the\n // newlines into <br> tags.) We also provide a lint rule name\n // so that lint.jsx can link to a document that provides more details\n // on that particular lint rule. If there is more than one warning\n // we only link to the first rule, however.\n //\n // Note that even if we're inside a table, we still reparent the\n // linty node so that it can be highlighted. We just make a note\n // of whether this lint is inside a table or not.\n if (nodeWarnings.length) {\n nodeWarnings.sort((a, b) => {\n return a.severity - b.severity;\n });\n\n if (node.type !== \"text\" || nodeWarnings.length > 1) {\n // If the linty node is not a text node, or if there is more\n // than one warning on a text node, then reparent the entire\n // node under a new lint node and put the warnings there.\n state.replace({\n type: \"lint\",\n // @ts-expect-error - TS2345 - Argument of type '{ type: string; content: TreeNode; message: string; ruleName: any; blockHighlight: any; insideTable: boolean; severity: any; }' is not assignable to parameter of type 'TreeNode'.\n content: node,\n message: nodeWarnings.map((w) => w.message).join(\"\\n\\n\"),\n ruleName: nodeWarnings[0].rule,\n blockHighlight: nodeContext.blockHighlight,\n insideTable: insideTable,\n severity: nodeWarnings[0].severity,\n });\n } else {\n //\n // Otherwise, it is a single warning on a text node, and we\n // only want to highlight the actual linty part of that string\n // of text. So we want to replace the text node with (in the\n // general case) three nodes:\n //\n // 1) A new text node that holds the non-linty prefix\n //\n // 2) A lint node that is the parent of a new text node\n // that holds the linty part\n //\n // 3) A new text node that holds the non-linty suffix\n //\n // If the lint begins and/or ends at the boundaries of the\n // original text node, then nodes 1 and/or 3 won't exist, of\n // course.\n //\n // Note that we could generalize this to work with multple\n // warnings on a text node as long as the warnings are\n // non-overlapping. Hopefully, though, multiple warnings in a\n // single text node will be rare in practice. Also, we don't\n // have a good way to display multiple lint indicators on a\n // single line, so keeping them combined in that case might\n // be the best thing, anyway.\n //\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n const content = node.content; // Text nodes have content\n const warning = nodeWarnings[0]; // There is only one warning.\n // These are the lint boundaries within the content\n const start = warning.start || 0;\n const end = warning.end || content.length;\n const prefix = content.substring(0, start);\n const lint = content.substring(start, end);\n const suffix = content.substring(end);\n // TODO(FEI-5003): Give this a real type.\n const replacements: any[] = []; // What we'll replace the node with\n\n // The prefix text node, if there is one\n if (prefix) {\n replacements.push({\n type: \"text\",\n content: prefix,\n });\n }\n\n // The lint node wrapped around the linty text\n replacements.push({\n type: \"lint\",\n content: {\n type: \"text\",\n content: lint,\n },\n message: warning.message,\n ruleName: warning.rule,\n insideTable: insideTable,\n severity: warning.severity,\n });\n\n // The suffix node, if there is one\n if (suffix) {\n replacements.push({\n type: \"text\",\n content: suffix,\n });\n }\n\n // Now replace the lint text node with the one to three\n // nodes in the replacement array\n state.replace(...replacements);\n }\n }\n });\n\n return warnings;\n}\n\nexport function pushContextStack(context: any, name: string): any {\n const stack = context.stack || [];\n return {\n ...context,\n stack: stack.concat(name),\n };\n}\n"],"names":["Selector","parse","selectorText","Parser","match","state","PerseusError","Errors","NotAllowed","toString","constructor","s","tokens","tokenIndex","trim","replace","TOKENS","nextToken","consume","isIdentifier","c","skipSpace","ts","parseTreeSelector","token","treeSelectors","ParseError","push","SelectorList","ns","parseNodeSelector","AncestorCombinator","ParentCombinator","PreviousCombinator","SiblingCombinator","t","AnyNode","TypeSelector","Error","message","selectors","i","length","result","currentNode","type","node","SelectorCombinator","left","right","rightResult","clone","hasParent","goToParent","leftResult","concat","hasPreviousSibling","goToPreviousSibling","Rule","name","severity","selector","pattern","lint","applies","InvalidInput","metadata","Severity","BULK_WARNING","DEFAULT_SELECTOR","args","_defaultLintFunction","makeRule","options","makePattern","check","traversalState","content","context","selectorMatch","patternMatch","FakePatternMatch","error","rule","start","end","e","stack","index","RegExp","lastSlash","lastIndexOf","expression","substring","flags","input","ERROR","WARNING","GUIDELINE","HOSTNAME","getHostname","url","nodes","target","hostname","endsWith","buttonNotInButtonSet","set","stringToButtonSet","_context$widgets","widgetType","nodeId","id","widget","widgets","answers","answerForms","buttons","buttonSets","answer","str","Object","entries","value","includes","contentType","level","currentHeading","previousHeading","littleWords","and","nor","but","the","for","isCapitalized","word","toUpperCase","locale","heading","words","split","shift","filter","w","hasOwnProperty","every","image","alt","indexOf","caption","text","nextpair","static","table","headerLength","header","rowLengths","cells","map","r","AbsoluteUrl","BlockquotedMath","BlockquotedWidget","DoubleSpacingAfterTerminal","ExpressionWidget","ExtraContentSpacing","HeadingLevel1","HeadingLevelSkip","HeadingSentenceCase","HeadingTitleCase","ImageAltText","ImageInTable","LinkClickHere","LongParagraph","MathAdjacent","MathAlignExtraBreak","MathAlignLinebreaks","MathEmpty","MathFontSize","MathFrac","MathNested","MathStartsWithSpace","MathTextEmpty","NestedLists","StaticWidgetInQuestionStem","TableMissingCells","UnescapedDollar","WidgetInTable","MathWithoutDollars","UnbalancedCodeDelimiters","ImageSpacesAroundUrls","ImageWidget","TreeTransformer","root","isNode","n","isTextNode","traverse","f","_traverse","TraversalState","_containers","_ancestors","keys","forEach","key","_indexes","pop","_currentNode","Array","isArray","Stack","parent","top","ancestors","values","nextSibling","siblings","previousSibling","removeNextSibling","splice","replacements","Internal","property","size","equals","that","array","slice","v","libName","libVersion","addLibraryVersionToPerseusDebug","linterContextProps","PropTypes","shape","string","highlightLint","bool","paths","arrayOf","linterContextDefault","allLintRules","AllRules","runLinter","tree","highlight","rules","warnings","tt","next","tableWarnings","insideTable","nodeWarnings","applicableRules","nodeContext","_extends","join","warning","some","sort","a","b","ruleName","blockHighlight","prefix","suffix","pushContextStack"],"mappings":";;;AAAA,SAAS,QAAQ,GAAG;AACpB,EAAE,OAAO,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,EAAE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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AAGA;AAYA;AACA;AACA;AACA;AACA;AAiBA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACe,MAAMiD,IAAI,CAAC;AAUtB;AACA;AACAhD,EAAAA,WAAWA,CACPiD,IAA+B,EAC/BC,QAAmC,EACnCC,QAAqC,EACrCC,OAAkC,EAClCC,IAAqC,EACrCC,OAAkC,EACpC;AAAA,IAAA,IAAA,CAlBFL,IAAI,GAAA,KAAA,CAAA,CAAA;AAAU;AAAA,IAAA,IAAA,CACdC,QAAQ,GAAA,KAAA,CAAA,CAAA;AAAU;AAAA,IAAA,IAAA,CAClBC,QAAQ,GAAA,KAAA,CAAA,CAAA;AAAY;AAAA,IAAA,IAAA,CACpBC,OAAO,GAAA,KAAA,CAAA,CAAA;AAA6B;AAAA,IAAA,IAAA,CACpCC,IAAI,GAAA,KAAA,CAAA,CAAA;AAAc;AAAA,IAAA,IAAA,CAClBC,OAAO,GAAA,KAAA,CAAA,CAAA;AAAiB;AAAA,IAAA,IAAA,CACxBzB,OAAO,GAAA,KAAA,CAAA,CAAA;AAaH,IAAA,IAAI,CAACsB,QAAQ,IAAI,CAACC,OAAO,EAAE;MACvB,MAAM,IAAIxD,YAAY,CAClB,4CAA4C,EAC5CC,MAAM,CAAC0D,YAAY,EACnB;AAACC,QAAAA,QAAQ,EAAE;AAACP,UAAAA,IAA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AAEO,SAASmB,gBAAgBA,CAAC9L,OAAY,EAAEnB,IAAY,EAAO;AAC9D,EAAA,MAAM4B,KAAK,GAAGT,OAAO,CAACS,KAAK,IAAI,EAAE,CAAA;EACjC,OAAA0K,QAAA,KACOnL,OAAO,EAAA;AACVS,IAAAA,KAAK,EAAEA,KAAK,CAAChC,MAAM,CAACI,IAAI,CAAA;AAAC,GAAA,CAAA,CAAA;AAEjC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../src/selector.ts","../../src/rule.ts","../../src/rules/lint-utils.ts","../../src/rules/absolute-url.ts","../../src/rules/blockquoted-math.ts","../../src/rules/blockquoted-widget.ts","../../src/rules/double-spacing-after-terminal.ts","../../src/rules/expression-widget.ts","../../src/rules/extra-content-spacing.ts","../../src/rules/heading-level-1.ts","../../src/rules/heading-level-skip.ts","../../src/rules/heading-sentence-case.ts","../../src/rules/heading-title-case.ts","../../src/rules/image-alt-text.ts","../../src/rules/image-in-table.ts","../../src/rules/image-spaces-around-urls.ts","../../src/rules/image-widget.ts","../../src/rules/link-click-here.ts","../../src/rules/long-paragraph.ts","../../src/rules/math-adjacent.ts","../../src/rules/math-align-extra-break.ts","../../src/rules/math-align-linebreaks.ts","../../src/rules/math-empty.ts","../../src/rules/math-font-size.ts","../../src/rules/math-frac.ts","../../src/rules/math-nested.ts","../../src/rules/math-starts-with-space.ts","../../src/rules/math-text-empty.ts","../../src/rules/math-without-dollars.ts","../../src/rules/nested-lists.ts","../../src/rules/static-widget-in-question-stem.ts","../../src/rules/table-missing-cells.ts","../../src/rules/unbalanced-code-delimiters.ts","../../src/rules/unescaped-dollar.ts","../../src/rules/widget-in-table.ts","../../src/rules/all-rules.ts","../../src/tree-transformer.ts","../../src/version.ts","../../src/proptypes.ts","../../src/index.ts"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","/* eslint-disable no-useless-escape */\n/**\n * The Selector class implements a CSS-like system for matching nodes in a\n * parse tree based on the structure of the tree. Create a Selector object by\n * calling the static Selector.parse() method on a string that describes the\n * tree structure you want to match. For example, if you want to find text\n * nodes that are direct children of paragraph nodes that immediately follow\n * heading nodes, you could create an appropriate selector like this:\n *\n * selector = Selector.parse(\"heading + paragraph > text\");\n *\n * Recall from the TreeTransformer class, that we consider any object with a\n * string-valued `type` property to be a tree node. The words \"heading\",\n * \"paragraph\" and \"text\" in the selector string above specify node types and\n * will match nodes in a parse tree that have `type` properties with those\n * values.\n *\n * Selectors are designed for use during tree traversals done with the\n * TreeTransformer traverse() method. To test whether the node currently being\n * traversed matches a selector, simply pass the TraversalState object to the\n * match() method of the Selector object. If the node does not match the\n * selector, match() returns null. If it does match, then match() returns an\n * array of nodes that match the selector. In the example above the first\n * element of the array would be the node the heading node, the second would\n * be the paragraph node that follows it, and the third would be the text node\n * that is a child of the paragraph. The last element of a returned array of\n * nodes is always equal to the current node of the tree traversal.\n *\n * Code that uses a selector might look like this:\n *\n * matchingNodes = selector.match(state);\n * if (matchingNodes) {\n * let heading = matchingNodes[0];\n * let text = matchingNodes[2];\n * // do something with those nodes\n * }\n *\n * The Selector.parse() method recognizes a grammar that is similar to CSS\n * selectors:\n *\n * selector := treeSelector (, treeSelector)*\n *\n * A selector is one or more comma-separated treeSelectors. A node matches\n * the selector if it matches any of the treeSelectors.\n *\n * treeSelector := (treeSelector combinator)? nodeSelector\n *\n * A treeSelector is a nodeSelector optionally preceeded by a combinator\n * and another tree selector. The tree selector matches if the current node\n * matches the node selector and a sibling or ancestor (depending on the\n * combinator) of the current node matches the optional treeSelector.\n *\n * combinator := ' ' | '>' | '+' | '~' // standard CSS3 combinators\n *\n * A combinator is a space or punctuation character that specifies the\n * relationship between two nodeSelectors. A space between two\n * nodeSelectors means that the first selector much match an ancestor of\n * the node that matches the second selector. A '>' character means that\n * the first selector must match the parent of the node matched by the\n * second. The '~' combinator means that the first selector must match a\n * previous sibling of the node matched by the second. And the '+' selector\n * means that first selector must match the immediate previous sibling of\n * the node that matched the second.\n *\n * nodeSelector := <IDENTIFIER> | '*'\n *\n * A nodeSelector is simply an identifier (a letter followed by any number\n * of letters, digits, hypens, and underscores) or the wildcard asterisk\n * character. A wildcard node selector matches any node. An identifier\n * selector matches any node that has a `type` property whose value matches\n * the identifier.\n *\n * If you call Selector.parse() on a string that does not match this grammar,\n * it will throw an exception\n *\n * TODO(davidflanagan): it might be useful to allow more sophsticated node\n * selector matching with attribute matches and pseudo-classes, like\n * \"heading[level=2]\" or \"paragraph:first-child\"\n *\n * Implementation Note: this file exports a very simple Selector class but all\n * the actual work is done in various internal classes. The Parser class\n * parses the string representation of a selector into a parse tree that\n * consists of instances of various subclasses of the Selector class. It is\n * these subclasses that implement the selector matching logic, often\n * depending on features of the TraversalState object from the TreeTransformer\n * traversal.\n */\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\nimport type {TreeNode, TraversalState} from \"./tree-transformer\";\n\n/**\n * This is the base class for all Selector types. The key method that all\n * selector subclasses must implement is match(). It takes a TraversalState\n * object (from a TreeTransformer traversal) and tests whether the selector\n * matches at the current node. See the comment at the start of this file for\n * more details on the match() method.\n */\nexport default class Selector {\n static parse(selectorText: string): Selector {\n return new Parser(selectorText).parse();\n }\n\n /**\n * Return an array of the nodes that matched or null if no match.\n * This is the base class so we just throw an exception. All Selector\n * subclasses must provide an implementation of this method.\n */\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n throw new PerseusError(\n \"Selector subclasses must implement match()\",\n Errors.NotAllowed,\n );\n }\n\n /**\n * Selector subclasses all define a toString() method primarily\n * because it makes it easy to write parser tests.\n */\n toString(): string {\n return \"Unknown selector class\";\n }\n}\n\n/**\n * This class implements a parser for the selector grammar. Pass the source\n * text to the Parser() constructor, and then call the parse() method to\n * obtain a corresponding Selector object. parse() throws an exception\n * if there are syntax errors in the selector.\n *\n * This class is not exported, and you don't need to use it directly.\n * Instead call the static Selector.parse() method.\n */\nclass Parser {\n static TOKENS: RegExp; // We do lexing with a simple regular expression\n tokens: ReadonlyArray<string>; // The array of tokens\n tokenIndex: number; // Which token in the array we're looking at now\n\n constructor(s: string) {\n // Normalize whitespace:\n // - remove leading and trailing whitespace\n // - replace runs of whitespace with single space characters\n s = s.trim().replace(/\\s+/g, \" \");\n // Convert the string to an array of tokens. Note that the TOKENS\n // pattern ignores spaces that do not appear before identifiers\n // or the * wildcard.\n this.tokens = s.match(Parser.TOKENS) || [];\n this.tokenIndex = 0;\n }\n\n // Return the next token or the empty string if there are no more\n nextToken(): string {\n return this.tokens[this.tokenIndex] || \"\";\n }\n\n // Increment the token index to \"consume\" the token we were looking at\n // and move on to the next one.\n consume(): void {\n this.tokenIndex++;\n }\n\n // Return true if the current token is an identifier or false otherwise\n isIdentifier(): boolean {\n // The Parser.TOKENS regexp ensures that we only have to check\n // the first character of a token to know what kind of token it is.\n const c = this.tokens[this.tokenIndex][0];\n return (c >= \"a\" && c <= \"z\") || (c >= \"A\" && c <= \"Z\");\n }\n\n // Consume space tokens until the next token is not a space.\n skipSpace(): void {\n while (this.nextToken() === \" \") {\n this.consume();\n }\n }\n\n // Parse a comma-separated sequence of tree selectors. This is the\n // entry point for the Parser class and the only method that clients\n // ever need to call.\n parse(): Selector {\n // We expect at least one tree selector\n const ts = this.parseTreeSelector();\n\n // Now see what's next\n let token = this.nextToken();\n\n // If there is no next token then we're done parsing and can return\n // the tree selector object we got above\n if (!token) {\n return ts;\n }\n\n // Otherwise, there is more go come and we're going to need a\n // list of tree selectors\n const treeSelectors = [ts];\n while (token) {\n // The only character we allow after a tree selector is a comma\n if (token === \",\") {\n this.consume();\n } else {\n throw new ParseError(\"Expected comma\");\n }\n\n // And if we saw a comma, then it must be followed by another\n // tree selector\n treeSelectors.push(this.parseTreeSelector());\n token = this.nextToken();\n }\n\n // If we parsed more than one tree selector, return them in a\n // SelectorList object.\n return new SelectorList(treeSelectors);\n }\n\n // Parse a sequence of node selectors linked together with\n // hierarchy combinators: space, >, + and ~.\n parseTreeSelector(): Selector {\n this.skipSpace(); // Ignore space after a comma, for example\n\n // A tree selector must begin with a node selector\n let ns: Selector = this.parseNodeSelector();\n\n for (;;) {\n // Now check the next token. If there is none, or if it is a\n // comma, then we're done with the treeSelector. Otherwise\n // we expect a combinator followed by another node selector.\n // If we don't see a combinator, we throw an error. If we\n // do see a combinator and another node selector then we\n // combine the current node selector with the new node selector\n // using a Selector subclass that depends on the combinator.\n const token = this.nextToken();\n\n if (!token || token === \",\") {\n break;\n } else if (token === \" \") {\n this.consume();\n ns = new AncestorCombinator(ns, this.parseNodeSelector());\n } else if (token === \">\") {\n this.consume();\n ns = new ParentCombinator(ns, this.parseNodeSelector());\n } else if (token === \"+\") {\n this.consume();\n ns = new PreviousCombinator(ns, this.parseNodeSelector());\n } else if (token === \"~\") {\n this.consume();\n ns = new SiblingCombinator(ns, this.parseNodeSelector());\n } else {\n throw new ParseError(\"Unexpected token: \" + token);\n }\n }\n\n return ns;\n }\n\n // Parse a single node selector.\n // For now, this is just a node type or a wildcard.\n //\n // TODO(davidflanagan): we may need to extend this with attribute\n // selectors like 'heading[level=3]', or with pseudo-classes like\n // paragraph:first-child\n parseNodeSelector(): Selector {\n // First, skip any whitespace\n this.skipSpace();\n\n const t = this.nextToken();\n if (t === \"*\") {\n this.consume();\n return new AnyNode();\n }\n if (this.isIdentifier()) {\n this.consume();\n return new TypeSelector(t);\n }\n\n throw new ParseError(\"Expected node type\");\n }\n}\n\n// We break the input string into tokens with this regexp. Token types\n// are identifiers, integers, punctuation and spaces. Note that spaces\n// tokens are only returned when they appear before an identifier or\n// wildcard token and are otherwise omitted.\nParser.TOKENS = /([a-zA-Z][\\w-]*)|(\\d+)|[^\\s]|(\\s(?=[a-zA-Z\\*]))/g;\n\n/**\n * This is a trivial Error subclass that the Parser uses to signal parse errors\n */\nclass ParseError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n\n/**\n * This Selector subclass is a list of selectors. It matches a node if any of\n * the selectors on the list matches the node. It considers the selectors in\n * order, and returns the array of nodes returned by whichever one matches\n * first.\n */\nclass SelectorList extends Selector {\n selectors: ReadonlyArray<Selector>;\n\n constructor(selectors: ReadonlyArray<Selector>) {\n super();\n this.selectors = selectors;\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n for (let i = 0; i < this.selectors.length; i++) {\n const s = this.selectors[i];\n const result = s.match(state);\n if (result) {\n return result;\n }\n }\n return null;\n }\n\n toString(): string {\n let result = \"\";\n for (let i = 0; i < this.selectors.length; i++) {\n result += i > 0 ? \", \" : \"\";\n result += this.selectors[i].toString();\n }\n return result;\n }\n}\n\n/**\n * This trivial Selector subclass implements the '*' wildcard and\n * matches any node.\n */\nclass AnyNode extends Selector {\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n return [state.currentNode()];\n }\n\n toString(): string {\n return \"*\";\n }\n}\n\n/**\n * This selector subclass implements the <IDENTIFIER> part of the grammar.\n * it matches any node whose `type` property is a specified string\n */\nclass TypeSelector extends Selector {\n type: string;\n\n constructor(type: string) {\n super();\n this.type = type;\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const node = state.currentNode();\n if (node.type === this.type) {\n return [node];\n }\n return null;\n }\n\n toString(): string {\n return this.type;\n }\n}\n\n/**\n * This selector subclass is the superclass of the classes that implement\n * matching for the four combinators. It defines left and right properties for\n * the two selectors that are to be combined, but does not define a match\n * method.\n */\nclass SelectorCombinator extends Selector {\n left: Selector;\n right: Selector;\n\n constructor(left: Selector, right: Selector) {\n super();\n this.left = left;\n this.right = right;\n }\n}\n\n/**\n * This Selector subclass implements the space combinator. It matches if the\n * right selector matches the current node and the left selector matches some\n * ancestor of the current node.\n */\nclass AncestorCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n state = state.clone();\n while (state.hasParent()) {\n state.goToParent();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the > combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * the parent of the current node.\n */\nclass ParentCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n if (state.hasParent()) {\n state = state.clone();\n state.goToParent();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" > \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the + combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * the immediate previous sibling of the current node.\n */\nclass PreviousCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n if (state.hasPreviousSibling()) {\n state = state.clone();\n state.goToPreviousSibling();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" + \" + this.right.toString();\n }\n}\n\n/**\n * This Selector subclass implements the ~ combinator. It matches if the\n * right selector matches the current node and the left selector matches\n * any previous sibling of the current node.\n */\nclass SiblingCombinator extends SelectorCombinator {\n constructor(left: Selector, right: Selector) {\n super(left, right);\n }\n\n match(state: TraversalState): ReadonlyArray<TreeNode> | null | undefined {\n const rightResult = this.right.match(state);\n if (rightResult) {\n state = state.clone();\n while (state.hasPreviousSibling()) {\n state.goToPreviousSibling();\n const leftResult = this.left.match(state);\n if (leftResult) {\n return leftResult.concat(rightResult);\n }\n }\n }\n return null;\n }\n\n toString(): string {\n return this.left.toString() + \" ~ \" + this.right.toString();\n }\n}\n","/**\n * The Rule class represents a Perseus lint rule. A Rule instance has a check()\n * method that takes the same (node, state, content) arguments that a\n * TreeTransformer traversal callback function does. Call the check() method\n * during a tree traversal to determine whether the current node of the tree\n * violates the rule. If there is no violation, then check() returns\n * null. Otherwise, it returns an object that includes the name of the rule,\n * an error message, and the start and end positions within the node's content\n * string of the lint.\n *\n * A Perseus lint rule consists of a name, a severity, a selector, a pattern\n * (RegExp) and two functions. The check() method uses the selector, pattern,\n * and functions as follows:\n *\n * - First, when determining which rules to apply to a particular piece of\n * content, each rule can specify an optional function provided in the fifth\n * parameter to evaluate whether or not we should be applying this rule.\n * If the function returns false, we don't use the rule on this content.\n *\n * - Next, check() tests whether the node currently being traversed matches\n * the selector. If it does not, then the rule does not apply at this node\n * and there is no lint and check() returns null.\n *\n * - If the selector matched, then check() tests the text content of the node\n * (and its children) against the pattern. If the pattern does not match,\n * then there is no lint, and check() returns null.\n *\n * - If both the selector and pattern match, then check() calls the function\n * passing the TraversalState object, the content string for the node, the\n * array of nodes returned by the selector match, and the array of strings\n * returned by the pattern match. This function can use these arguments to\n * implement any kind of lint detection logic it wants. If it determines\n * that there is no lint, then it should return null. Otherwise, it should\n * return an error message as a string, or an object with `message`, `start`\n * and `end` properties. The start and end properties are numbers that mark\n * the beginning and end of the problematic content. Note that these numbers\n * are relative to the content string passed to the traversal callback, not\n * to the entire string that was used to generate the parse tree in the\n * first place. TODO(davidflanagan): modify the simple-markdown library to\n * have an option to add the text offset of each node to the parse\n * tree. This will allows us to pinpoint lint errors within a long string\n * of markdown text.\n *\n * - If the function returns null, then check() returns null. Otherwise,\n * check() returns an object with `rule`, `message`, `start` and `end`\n * properties. The value of the `rule` property is the name of the rule,\n * which is useful for error reporting purposes.\n *\n * The name, severity, selector, pattern and function arguments to the Rule()\n * constructor are optional, but you may not omit both the selector and the\n * pattern. If you do not specify a selector, a default selector that matches\n * any node of type \"text\" will be used. If you do not specify a pattern, then\n * any node that matches the selector will be assumed to match the pattern as\n * well. If you don't pass a function as the fourth argument to the Rule()\n * constructor, then you must pass an error message string instead. If you do\n * this, you'll get a default function that unconditionally returns an object\n * that includes the error message and the start and end indexes of the\n * portion of the content string that matched the pattern. If you don't pass a\n * function in the fifth parameter, the rule will be applied in any context.\n *\n * One of the design goals of this Rule class is to allow simple lint rules to\n * be described in JSON files without any JavaScript code. So in addition to\n * the Rule() constructor, the class also defines a Rule.makeRule() factory\n * method. This method takes a single object as its argument and expects the\n * object to have four string properties. The `name` property is passed as the\n * first argument to the Rule() construtctor. The optional `selector`\n * property, if specified, is passed to Selector.parse() and the resulting\n * Selector object is used as the second argument to Rule(). The optional\n * `pattern` property is converted to a RegExp before being passed as the\n * third argument to Rule(). (See Rule.makePattern() for details on the string\n * to RegExp conversion). Finally, the `message` property specifies an error\n * message that is passed as the final argument to Rule(). You can also use a\n * real RegExp as the value of the `pattern` property or define a custom lint\n * function on the `lint` property instead of setting the `message`\n * property. Doing either of these things means that your rule description can\n * no longer be saved in a JSON file, however.\n *\n * For example, here are two lint rules defined with Rule.makeRule():\n *\n * let nestedLists = Rule.makeRule({\n * name: \"nested-lists\",\n * selector: \"list list\",\n * message: `Nested lists:\n * nested lists are hard to read on mobile devices;\n * do not use additional indentation.`,\n * });\n *\n * let longParagraph = Rule.makeRule({\n * name: \"long-paragraph\",\n * selector: \"paragraph\",\n * pattern: /^.{501,}/,\n * lint: function(state, content, nodes, match) {\n * return `Paragraph too long:\n * This paragraph is ${content.length} characters long.\n * Shorten it to 500 characters or fewer.`;\n * },\n * });\n *\n * Certain advanced lint rules need additional information about the content\n * being linted in order to detect lint. For example, a rule to check for\n * whitespace at the start and end of the URL for an image can't use the\n * information in the node or content arguments because the markdown parser\n * strips leading and trailing whitespace when parsing. (Nevertheless, these\n * spaces have been a practical problem for our content translation process so\n * in order to check for them, a lint rule needs access to the original\n * unparsed source text. Similarly, there are various lint rules that check\n * widget usage. For example, it is easy to write a lint rule to ensure that\n * images have alt text for images encoded in markdown. But when images are\n * added to our content via an image widget we also want to be able to check\n * for alt text. In order to do this, the lint rule needs to be able to look\n * widgets up by name in the widgets object associated with the parse tree.\n *\n * In order to support advanced linting rules like these, the check() method\n * takes a context object as its optional fourth argument, and passes this\n * object on to the lint function of each rule. Rules that require extra\n * context should not assume that they will always get it, and should verify\n * that the necessary context has been supplied before using it. Currently the\n * \"content\" property of the context object is the unparsed source text if\n * available, and the \"widgets\" property of the context object is the widget\n * object associated with that content string in the JSON object that defines\n * the Perseus article or exercise that is being linted.\n */\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\nimport Selector from \"./selector\";\n\nimport type {TraversalState, TreeNode} from \"./tree-transformer\";\n\nexport type MakeRuleOptions = {\n name: string;\n pattern?: RegExp;\n severity?: number;\n selector?: string;\n locale?: string;\n message?: string;\n lint?: (\n state: TraversalState,\n content: string,\n nodes: any,\n match: any,\n context: LintRuleContextObject,\n ) => string | undefined;\n applies?: AppliesTester;\n};\n\n// This represents the type returned by String.match(). It is an\n// array of strings, but also has index:number and input:string properties.\n// TypeScript doesn't handle it well, so we punt and just use any.\ntype PatternMatchType = any;\n\n// This is the return type of the check() method of a Rule object\ntype RuleCheckReturnType =\n | {\n rule: string;\n message: string;\n start: number;\n end: number;\n severity?: number;\n }\n | null\n | undefined;\n\n// This is the return type of the lint detection function passed as the 4th\n// argument to the Rule() constructor. It can return null or a string or an\n// object containing a string and two numbers.\n// prettier-ignore\n// (prettier formats this in a way that ka-lint does not like)\ntype LintTesterReturnType = string | {\n message: string,\n start: number,\n end: number\n} | null | undefined;\n\ntype LintRuleContextObject =\n | {\n content: string;\n contentType: \"article\" | \"exercise\";\n stack: string[];\n widgets: any[];\n }\n | null\n | undefined;\n\n// This is the type of the lint detection function that the Rule() constructor\n// expects as its fourth argument. It is passed the TraversalState object and\n// content string that were passed to check(), and is also passed the array of\n// nodes returned by the selector match and the array of strings returned by\n// the pattern match. It should return null if no lint is detected or an\n// error message or an object contining an error message.\ntype LintTester = (\n state: TraversalState,\n content: string,\n selectorMatch: ReadonlyArray<TreeNode>,\n patternMatch: PatternMatchType,\n context: LintRuleContextObject,\n) => LintTesterReturnType;\n\n// An optional check to verify whether or not a particular rule should\n// be checked by context. For example, some rules only apply in exercises,\n// and should never be applied to articles. Defaults to true, so if we\n// omit the applies function in a rule, it'll be tested everywhere.\ntype AppliesTester = (context: LintRuleContextObject) => boolean;\n\n/**\n * A Rule object describes a Perseus lint rule. See the comment at the top of\n * this file for detailed description.\n */\nexport default class Rule {\n name: string; // The name of the rule\n severity: number; // The severity of the rule\n selector: Selector; // The specified selector or the DEFAULT_SELECTOR\n pattern: RegExp | null | undefined; // A regular expression if one was specified\n lint: LintTester; // The lint-testing function or a default\n applies: AppliesTester; // Checks to see if we should apply a rule or not\n message: string | null | undefined; // The error message for use with the default function\n static DEFAULT_SELECTOR: Selector;\n\n // The comment at the top of this file has detailed docs for\n // this constructor and its arguments\n constructor(\n name: string | null | undefined,\n severity: number | null | undefined,\n selector: Selector | null | undefined,\n pattern: RegExp | null | undefined,\n lint: LintTester | string | undefined,\n applies: AppliesTester | undefined,\n ) {\n if (!selector && !pattern) {\n throw new PerseusError(\n \"Lint rules must have a selector or pattern\",\n Errors.InvalidInput,\n {metadata: {name}},\n );\n }\n\n this.name = name || \"unnamed rule\";\n this.severity = severity || Rule.Severity.BULK_WARNING;\n this.selector = selector || Rule.DEFAULT_SELECTOR;\n this.pattern = pattern || null;\n\n // If we're called with an error message instead of a function then\n // use a default function that will return the message.\n if (typeof lint === \"function\") {\n this.lint = lint;\n this.message = null;\n } else {\n this.lint = (...args) => this._defaultLintFunction(...args);\n this.message = lint;\n }\n\n this.applies =\n applies ||\n function () {\n return true;\n };\n }\n\n // A factory method for use with rules described in JSON files\n // See the documentation at the start of this file for details.\n static makeRule(options: MakeRuleOptions): Rule {\n return new Rule(\n options.name,\n options.severity,\n options.selector ? Selector.parse(options.selector) : null,\n Rule.makePattern(options.pattern),\n options.lint || options.message,\n options.applies,\n );\n }\n\n // Check the node n to see if it violates this lint rule. A return value\n // of false means there is no lint. A returned object indicates a lint\n // error. See the documentation at the top of this file for details.\n check(\n node: TreeNode,\n traversalState: TraversalState,\n content: string,\n context: LintRuleContextObject,\n ): RuleCheckReturnType {\n // First, see if we match the selector.\n // If no selector was passed to the constructor, we use a\n // default selector that matches text nodes.\n const selectorMatch = this.selector.match(traversalState);\n\n // If the selector did not match, then we're done\n if (!selectorMatch) {\n return null;\n }\n\n // If the selector matched, then see if the pattern matches\n let patternMatch;\n if (this.pattern) {\n patternMatch = content.match(this.pattern);\n } else {\n // If there is no pattern, then just match all of the content.\n // Use a fake RegExp match object to represent this default match.\n patternMatch = Rule.FakePatternMatch(content, content, 0);\n }\n\n // If there was a pattern and it didn't match, then we're done\n if (!patternMatch) {\n return null;\n }\n\n try {\n // If we get here, then the selector and pattern have matched\n // so now we call the lint function to see if there is lint.\n const error = this.lint(\n traversalState,\n content,\n selectorMatch,\n patternMatch,\n context,\n );\n\n if (!error) {\n return null; // No lint; we're done\n }\n if (typeof error === \"string\") {\n // If the lint function returned a string we assume it\n // applies to the entire content of the node and return it.\n return {\n rule: this.name,\n severity: this.severity,\n message: error,\n start: 0,\n end: content.length,\n };\n }\n // If the lint function returned an object, then we just\n // add the rule name to the message, start and end.\n return {\n rule: this.name,\n severity: this.severity,\n message: error.message,\n start: error.start,\n end: error.end,\n };\n } catch (e: any) {\n // If the lint function threw an exception we handle that as\n // a special type of lint. We want the user to see the lint\n // warning in this case (even though it is out of their control)\n // so that the bug gets reported. Otherwise we'd never know that\n // a rule was failing.\n return {\n rule: \"lint-rule-failure\",\n message: `Exception in rule ${this.name}: ${e.message}\nStack trace:\n${e.stack}`,\n start: 0,\n end: content.length,\n };\n }\n }\n\n // This internal method is the default lint function that we use when a\n // rule is defined without a function. This is useful for rules where the\n // selector and/or pattern match are enough to indicate lint. This\n // function unconditionally returns the error message that was passed in\n // place of a function, but also adds start and end properties that\n // specify which particular portion of the node content matched the\n // pattern.\n _defaultLintFunction(\n state: TraversalState,\n content: string,\n selectorMatch: ReadonlyArray<TreeNode>,\n patternMatch: PatternMatchType,\n context: LintRuleContextObject,\n ): {\n end: number;\n message: string;\n start: number;\n } {\n return {\n message: this.message || \"\",\n start: patternMatch.index,\n end: patternMatch.index + patternMatch[0].length,\n };\n }\n\n // The makeRule() factory function uses this static method to turn its\n // argument into a RegExp. If the argument is already a RegExp, we just\n // return it. Otherwise, we compile it into a RegExp and return that.\n // The reason this is necessary is that Rule.makeRule() is designed for\n // use with data from JSON files and JSON files can't include RegExp\n // literals. Strings passed to this function do not need to be delimited\n // with / characters unless you want to include flags for the RegExp.\n //\n // Examples:\n //\n // input \"\" ==> output null\n // input /foo/ ==> output /foo/\n // input \"foo\" ==> output /foo/\n // input \"/foo/i\" ==> output /foo/i\n //\n static makePattern(\n pattern?: RegExp | string | null,\n ): RegExp | null | undefined {\n if (!pattern) {\n return null;\n }\n if (pattern instanceof RegExp) {\n return pattern;\n }\n if (pattern[0] === \"/\") {\n const lastSlash = pattern.lastIndexOf(\"/\");\n const expression = pattern.substring(1, lastSlash);\n const flags = pattern.substring(lastSlash + 1);\n // @ts-expect-error - TS2713 - Cannot access 'RegExp.flags' because 'RegExp' is a type, but not a namespace. Did you mean to retrieve the type of the property 'flags' in 'RegExp' with 'RegExp[\"flags\"]'?\n return new RegExp(expression, flags as RegExp.flags);\n }\n return new RegExp(pattern);\n }\n\n // This static method returns an string array with index and input\n // properties added, in order to simulate the return value of the\n // String.match() method. We use it when a Rule has no pattern and we\n // want to simulate a match on the entire content string.\n static FakePatternMatch(\n input: string,\n match: string | null | undefined,\n index: number,\n ): PatternMatchType {\n const result: any = [match];\n result.index = index;\n result.input = input;\n return result;\n }\n\n static Severity: {\n BULK_WARNING: number;\n ERROR: number;\n GUIDELINE: number;\n WARNING: number;\n } = {\n ERROR: 1,\n WARNING: 2,\n GUIDELINE: 3,\n BULK_WARNING: 4,\n };\n}\n\nRule.DEFAULT_SELECTOR = Selector.parse(\"text\");\n","/* eslint-disable no-useless-escape */\n// Return the portion of a URL between // and /. This is the authority\n// portion which is usually just the hostname, but may also include\n// a username, password or port. We don't strip those things out because\n// we typically want to reject any URL that includes them\nconst HOSTNAME = /\\/\\/([^\\/]+)/;\n\n// Return the hostname of the URL, with any \"www.\" prefix removed.\n// If this is a relative URL with no hostname, return an empty string.\nexport function getHostname(url: string): string {\n if (!url) {\n return \"\";\n }\n const match = url.match(HOSTNAME);\n return match ? match[1] : \"\";\n}\n","import Rule from \"../rule\";\n\nimport {getHostname} from \"./lint-utils\";\n\nexport default Rule.makeRule({\n name: \"absolute-url\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"link, image\",\n lint: function (state, content, nodes, match) {\n const url = nodes[0].target;\n const hostname = getHostname(url);\n\n if (\n hostname === \"khanacademy.org\" ||\n hostname.endsWith(\".khanacademy.org\")\n ) {\n return `Don't use absolute URLs:\nWhen linking to KA content or images, omit the\nhttps://www.khanacademy.org URL prefix.\nUse a relative URL beginning with / instead.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"blockquoted-math\",\n severity: Rule.Severity.WARNING,\n selector: \"blockQuote math, blockQuote blockMath\",\n message: `Blockquoted math:\nmath should not be indented.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"blockquoted-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"blockQuote widget\",\n message: `Blockquoted widget:\nwidgets should not be indented.`,\n}) as Rule;\n","/* eslint-disable no-useless-escape */\nimport Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"double-spacing-after-terminal\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"paragraph\",\n pattern: /[.!\\?] {2}/i,\n message: `Use a single space after a sentence-ending period, or\nany other kind of terminal punctuation.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nfunction buttonNotInButtonSet(name: string, set: string): string {\n return `Answer requires a button not found in the button sets: ${name} (in ${set})`;\n}\n\nconst stringToButtonSet = {\n \"\\\\sqrt\": \"prealgebra\",\n \"\\\\sin\": \"trig\",\n \"\\\\cos\": \"trig\",\n \"\\\\tan\": \"trig\",\n \"\\\\log\": \"logarithms\",\n \"\\\\ln\": \"logarithms\",\n};\n\n/**\n * Rule to make sure that Expression questions that require\n * a specific math symbol to answer have that math symbol\n * available in the keypad (desktop learners can use a keyboard,\n * but mobile learners must use the MathInput keypad)\n */\nexport default Rule.makeRule({\n name: \"expression-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: function (state, content, nodes, match, context) {\n // This rule only looks at image widgets\n if (state.currentNode().widgetType !== \"expression\") {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n // If it can't find a definition for the widget it does nothing\n const widget = context?.widgets?.[nodeId];\n if (!widget) {\n return;\n }\n\n const answers = widget.options.answerForms;\n const buttons = widget.options.buttonSets;\n for (const answer of answers) {\n for (const [str, set] of Object.entries(stringToButtonSet)) {\n if (answer.value.includes(str) && !buttons.includes(set)) {\n return buttonNotInButtonSet(str, set);\n }\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"extra-content-spacing\",\n selector: \"paragraph\",\n pattern: /\\s+$/,\n applies: function (context) {\n return context?.contentType === \"article\";\n },\n message: `No extra whitespace at the end of content blocks.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-level-1\",\n severity: Rule.Severity.WARNING,\n selector: \"heading\",\n lint: function (state, content, nodes, match) {\n if (nodes[0].level === 1) {\n return `Don't use level-1 headings:\nBegin headings with two or more # characters.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-level-skip\",\n severity: Rule.Severity.WARNING,\n selector: \"heading ~ heading\",\n lint: function (state, content, nodes, match) {\n const currentHeading = nodes[1];\n const previousHeading = nodes[0];\n // A heading can have a level less than, the same as\n // or one more than the previous heading. But going up\n // by 2 or more levels is not right\n if (currentHeading.level > previousHeading.level + 1) {\n return `Skipped heading level:\nthis heading is level ${currentHeading.level} but\nthe previous heading was level ${previousHeading.level}`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"heading-sentence-case\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"heading\",\n pattern: /^\\W*[a-z]/, // first letter is lowercase\n message: `First letter is lowercase:\nthe first letter of a heading should be capitalized.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\n// These are 3-letter and longer words that we would not expect to be\n// capitalized even in a title-case heading. See\n// http://blog.apastyle.org/apastyle/2012/03/title-case-and-sentence-case-capitalization-in-apa-style.html\nconst littleWords = {\n and: true,\n nor: true,\n but: true,\n the: true,\n for: true,\n} as const;\n\nfunction isCapitalized(word: any) {\n const c = word[0];\n return c === c.toUpperCase();\n}\n\nexport default Rule.makeRule({\n name: \"heading-title-case\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"heading\",\n pattern: /[^\\s:]\\s+[A-Z]+[a-z]/,\n locale: \"en\",\n lint: function (state, content, nodes, match) {\n // We want to assert that heading text is in sentence case, not\n // title case. The pattern above requires a capital letter at the\n // start of the heading and allows them after a colon, or in\n // acronyms that are all capitalized.\n //\n // But we can't warn just because the pattern matched because\n // proper nouns are also allowed bo be capitalized. We're not\n // going to do dictionary lookup to check for proper nouns, so\n // we try a heuristic: if the title is more than 3 words long\n // and if all the words are capitalized or are on the list of\n // words that don't get capitalized, then we'll assume that\n // the heading is incorrectly in title case and will warn.\n // But if there is at least one non-capitalized long word then\n // we're not in title case and we should not warn.\n //\n // TODO(davidflanagan): if this rule causes a lot of false\n // positives, we should tweak it or remove it. Note that it will\n // fail for headings like \"World War II in Russia\"\n //\n // TODO(davidflanagan): This rule is specific to English.\n // It is marked with a locale property above, but that is NYI\n //\n // for APA style rules for title case\n\n const heading = content.trim();\n let words = heading.split(/\\s+/);\n\n // Remove the first word and the little words\n words.shift();\n words = words.filter(\n // eslint-disable-next-line no-prototype-builtins\n (w) => w.length > 2 && !littleWords.hasOwnProperty(w),\n );\n\n // If there are at least 3 remaining words and all\n // are capitalized, then the heading is in title case.\n if (words.length >= 3 && words.every((w) => isCapitalized(w))) {\n return `Title-case heading:\nThis heading appears to be in title-case, but should be sentence-case.\nOnly capitalize the first letter and proper nouns.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-alt-text\",\n severity: Rule.Severity.WARNING,\n selector: \"image\",\n lint: function (state, content, nodes, match) {\n const image = nodes[0];\n if (!image.alt || !image.alt.trim()) {\n return `Images should have alt text:\nfor accessibility, all images should have alt text.\nSpecify alt text inside square brackets after the !.`;\n }\n if (image.alt.length < 8) {\n return `Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ${image.alt.length} characters long.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-in-table\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"table image\",\n message: `Image in table:\ndo not put images inside of tables.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"image-spaces-around-urls\",\n severity: Rule.Severity.ERROR,\n selector: \"image\",\n lint: function (state, content, nodes, match, context) {\n const image = nodes[0];\n const url = image.target;\n\n // The markdown parser strips leading and trailing spaces for us,\n // but they're still a problem for our translation process, so\n // we need to go check for them in the unparsed source string\n // if we have it.\n if (context && context.content) {\n // Find the url in the original content and make sure that the\n // character before is '(' and the character after is ')'\n const index = context.content.indexOf(url);\n if (index === -1) {\n // It is not an error if we didn't find it.\n return;\n }\n\n if (\n context.content[index - 1] !== \"(\" ||\n context.content[index + url.length] !== \")\"\n ) {\n return `Whitespace before or after image url:\nFor images, don't include any space or newlines after '(' or before ')'.\nWhitespace in image URLs causes translation difficulties.`;\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Normally we have one rule per file. But since our selector class\n// can't match specific widget types directly, this rule implements\n// a number of image widget related rules in one place. This should\n// slightly increase efficiency, but it means that if there is more\n// than one problem with an image widget, the user will only see one\n// problem at a time.\nexport default Rule.makeRule({\n name: \"image-widget\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: function (state, content, nodes, match, context) {\n // This rule only looks at image widgets\n if (state.currentNode().widgetType !== \"image\") {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n // If it can't find a definition for the widget it does nothing\n const widget = context && context.widgets && context.widgets[nodeId];\n if (!widget) {\n return;\n }\n\n // Make sure there is alt text\n const alt = widget.options.alt;\n if (!alt) {\n return `Images should have alt text:\nfor accessibility, all images should have a text description.\nAdd a description in the \"Alt Text\" box of the image widget.`;\n }\n\n // Make sure the alt text it is not trivial\n if (alt.trim().length < 8) {\n return `Images should have alt text:\nfor accessibility, all images should have descriptive alt text.\nThis image's alt text is only ${alt.trim().length} characters long.`;\n }\n\n // Make sure there is no math in the caption\n if (widget.options.caption && widget.options.caption.match(/[^\\\\]\\$/)) {\n return `No math in image captions:\nDon't include math expressions in image captions.`;\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"link-click-here\",\n severity: Rule.Severity.WARNING,\n selector: \"link\",\n pattern: /click here/i,\n message: `Inappropriate link text:\nDo not use the words \"click here\" in links.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"long-paragraph\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"paragraph\",\n pattern: /^.{501,}/,\n lint: function (state, content, nodes, match) {\n return `Paragraph too long:\nThis paragraph is ${content.length} characters long.\nShorten it to 500 characters or fewer.`;\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-adjacent\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath+blockMath\",\n message: `Adjacent math blocks:\ncombine the blocks between \\\\begin{align} and \\\\end{align}`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-align-extra-break\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath\",\n pattern: /(\\\\{2,})\\s*\\\\end{align}/,\n message: `Extra space at end of block:\nDon't end an align block with backslashes`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-align-linebreaks\",\n severity: Rule.Severity.WARNING,\n selector: \"blockMath\",\n // Match any align block with double backslashes in it\n // Use [\\s\\S]* instead of .* so we match newlines as well.\n pattern: /\\\\begin{align}[\\s\\S]*\\\\\\\\[\\s\\S]+\\\\end{align}/,\n // Look for double backslashes and ensure that they are\n // followed by optional space and another pair of backslashes.\n // Note that this rule can't know where line breaks belong so\n // it can't tell whether backslashes are completely missing. It just\n // enforces that you don't have the wrong number of pairs of backslashes.\n lint: function (state, content, nodes, match) {\n let text = match[0];\n while (text.length) {\n const index = text.indexOf(\"\\\\\\\\\");\n if (index === -1) {\n // No more backslash pairs, so we found no lint\n return;\n }\n text = text.substring(index + 2);\n\n // Now we expect to find optional spaces, another pair of\n // backslashes, and more optional spaces not followed immediately\n // by another pair of backslashes.\n const nextpair = text.match(/^\\s*\\\\\\\\\\s*(?!\\\\\\\\)/);\n\n // If that does not match then we either have too few or too\n // many pairs of backslashes.\n if (!nextpair) {\n return \"Use four backslashes between lines of an align block\";\n }\n\n // If it did match, then, shorten the string and continue looping\n // (because a single align block may have multiple lines that\n // all must be separated by two sets of double backslashes).\n text = text.substring(nextpair[0].length);\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-empty\",\n severity: Rule.Severity.WARNING,\n selector: \"math, blockMath\",\n pattern: /^$/,\n message: \"Empty math: don't use $$ in your markdown.\",\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-font-size\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern:\n /\\\\(tiny|Tiny|small|large|Large|LARGE|huge|Huge|scriptsize|normalsize)\\s*{/,\n message: `Math font size:\nDon't change the default font size with \\\\Large{} or similar commands`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-frac\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern: /\\\\frac[ {]/,\n message: \"Use \\\\dfrac instead of \\\\frac in your math expressions.\",\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-nested\",\n severity: Rule.Severity.ERROR,\n selector: \"math, blockMath\",\n pattern: /\\\\text{[^$}]*\\$[^$}]*\\$[^}]*}/,\n message: `Nested math:\nDon't nest math expressions inside \\\\text{} blocks`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-starts-with-space\",\n severity: Rule.Severity.GUIDELINE,\n selector: \"math, blockMath\",\n pattern: /^\\s*(~|\\\\qquad|\\\\quad|\\\\,|\\\\;|\\\\:|\\\\ |\\\\!|\\\\enspace|\\\\phantom)/,\n message: `Math starts with space:\nmath should not be indented. Do not begin math expressions with\nLaTeX space commands like ~, \\\\;, \\\\quad, or \\\\phantom`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"math-text-empty\",\n severity: Rule.Severity.WARNING,\n selector: \"math, blockMath\",\n pattern: /\\\\text{\\s*}/,\n message: \"Empty \\\\text{} block in math expression\",\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Because no selector is specified, this rule only applies to text nodes.\n// Math and code hold their content directly and do not have text nodes\n// beneath them (unlike the HTML DOM) so this rule automatically does not\n// apply inside $$ or ``.\nexport default Rule.makeRule({\n name: \"math-without-dollars\",\n severity: Rule.Severity.GUIDELINE,\n pattern: /\\\\\\w+{[^}]*}|{|}/,\n message: `This looks like LaTeX:\ndid you mean to put it inside dollar signs?`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"nested-lists\",\n severity: Rule.Severity.WARNING,\n selector: \"list list\",\n message: `Nested lists:\nnested lists are hard to read on mobile devices;\ndo not use additional indentation.`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"static-widget-in-question-stem\",\n severity: Rule.Severity.WARNING,\n selector: \"widget\",\n lint: (state, content, nodes, match, context) => {\n if (context?.contentType !== \"exercise\") {\n return;\n }\n\n if (context.stack.includes(\"hint\")) {\n return;\n }\n\n const nodeId = state.currentNode().id;\n if (!nodeId) {\n return;\n }\n\n const widget = context?.widgets?.[nodeId];\n if (!widget) {\n return;\n }\n\n if (widget.static) {\n return `Widget in question stem is static (non-interactive).`;\n }\n },\n});\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"table-missing-cells\",\n severity: Rule.Severity.WARNING,\n selector: \"table\",\n lint: function (state, content, nodes, match) {\n const table = nodes[0];\n const headerLength = table.header.length;\n const rowLengths = table.cells.map((r) => r.length);\n for (let r = 0; r < rowLengths.length; r++) {\n if (rowLengths[r] !== headerLength) {\n return `Table rows don't match header:\nThe table header has ${headerLength} cells, but\nRow ${r + 1} has ${rowLengths[r]} cells.`;\n }\n }\n },\n}) as Rule;\n","import Rule from \"../rule\";\n\n// Because no selector is specified, this rule only applies to text nodes.\n// Math and code hold their content directly and do not have text nodes\n// beneath them (unlike the HTML DOM) so this rule automatically does not\n// apply inside $$ or ``.\nexport default Rule.makeRule({\n name: \"unbalanced-code-delimiters\",\n severity: Rule.Severity.ERROR,\n pattern: /[`~]+/,\n message: `Unbalanced code delimiters:\ncode blocks should begin and end with the same type and number of delimiters`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"unescaped-dollar\",\n severity: Rule.Severity.ERROR,\n selector: \"unescapedDollar\",\n message: `Unescaped dollar sign:\nDollar signs must appear in pairs or be escaped as \\\\$`,\n}) as Rule;\n","import Rule from \"../rule\";\n\nexport default Rule.makeRule({\n name: \"widget-in-table\",\n severity: Rule.Severity.BULK_WARNING,\n selector: \"table widget\",\n message: `Widget in table:\ndo not put widgets inside of tables.`,\n}) as Rule;\n","// TODO(davidflanagan):\n// This should probably be converted to use import and to export\n// and object that maps rule names to rules. Also, maybe this should\n// be an auto-generated file with a script that updates it any time\n// we add a new rule?\n\nimport AbsoluteUrl from \"./absolute-url\";\nimport BlockquotedMath from \"./blockquoted-math\";\nimport BlockquotedWidget from \"./blockquoted-widget\";\nimport DoubleSpacingAfterTerminal from \"./double-spacing-after-terminal\";\nimport ExpressionWidget from \"./expression-widget\";\nimport ExtraContentSpacing from \"./extra-content-spacing\";\nimport HeadingLevel1 from \"./heading-level-1\";\nimport HeadingLevelSkip from \"./heading-level-skip\";\nimport HeadingSentenceCase from \"./heading-sentence-case\";\nimport HeadingTitleCase from \"./heading-title-case\";\nimport ImageAltText from \"./image-alt-text\";\nimport ImageInTable from \"./image-in-table\";\nimport ImageSpacesAroundUrls from \"./image-spaces-around-urls\";\nimport ImageWidget from \"./image-widget\";\nimport LinkClickHere from \"./link-click-here\";\nimport LongParagraph from \"./long-paragraph\";\nimport MathAdjacent from \"./math-adjacent\";\nimport MathAlignExtraBreak from \"./math-align-extra-break\";\nimport MathAlignLinebreaks from \"./math-align-linebreaks\";\nimport MathEmpty from \"./math-empty\";\nimport MathFontSize from \"./math-font-size\";\nimport MathFrac from \"./math-frac\";\nimport MathNested from \"./math-nested\";\nimport MathStartsWithSpace from \"./math-starts-with-space\";\nimport MathTextEmpty from \"./math-text-empty\";\nimport MathWithoutDollars from \"./math-without-dollars\";\nimport NestedLists from \"./nested-lists\";\nimport StaticWidgetInQuestionStem from \"./static-widget-in-question-stem\";\nimport TableMissingCells from \"./table-missing-cells\";\nimport UnbalancedCodeDelimiters from \"./unbalanced-code-delimiters\";\nimport UnescapedDollar from \"./unescaped-dollar\";\nimport WidgetInTable from \"./widget-in-table\";\n\nexport default [\n AbsoluteUrl,\n BlockquotedMath,\n BlockquotedWidget,\n DoubleSpacingAfterTerminal,\n ExpressionWidget,\n ExtraContentSpacing,\n HeadingLevel1,\n HeadingLevelSkip,\n HeadingSentenceCase,\n HeadingTitleCase,\n ImageAltText,\n ImageInTable,\n LinkClickHere,\n LongParagraph,\n MathAdjacent,\n MathAlignExtraBreak,\n MathAlignLinebreaks,\n MathEmpty,\n MathFontSize,\n MathFrac,\n MathNested,\n MathStartsWithSpace,\n MathTextEmpty,\n NestedLists,\n StaticWidgetInQuestionStem,\n TableMissingCells,\n UnescapedDollar,\n WidgetInTable,\n MathWithoutDollars,\n UnbalancedCodeDelimiters,\n ImageSpacesAroundUrls,\n ImageWidget,\n];\n","/**\n * TreeTransformer is a class for traversing and transforming trees. Create a\n * TreeTransformer by passing the root node of the tree to the\n * constructor. Then traverse that tree by calling the traverse() method. The\n * argument to traverse() is a callback function that will be called once for\n * each node in the tree. This is a post-order depth-first traversal: the\n * callback is not called on the a way down, but on the way back up. That is,\n * the children of a node are traversed before the node itself is.\n *\n * The traversal callback function is passed three arguments, the node being\n * traversed, a TraversalState object, and the concatentated text content of\n * the node and all of its descendants. The TraversalState object is the most\n * most interesting argument: it has methods for querying the ancestors and\n * siblings of the node, and for deleting or replacing the node. These\n * transformation methods are why this class is a tree transformer and not\n * just a tree traverser.\n *\n * A typical tree traversal looks like this:\n *\n * new TreeTransformer(root).traverse((node, state, content) => {\n * let parent = state.parent();\n * let previous = state.previousSibling();\n * // etc.\n * });\n *\n * The traverse() method descends through nodes and arrays of nodes and calls\n * the traverse callback on each node on the way back up to the root of the\n * tree. (Note that it only calls the callback on the nodes themselves, not\n * any arrays that contain nodes.) A node is loosely defined as any object\n * with a string-valued `type` property. Objects that do not have a type\n * property are assumed to not be part of the tree and are not traversed. When\n * traversing an array, all elements of the array are examined, and any that\n * are nodes or arrays are recursively traversed. When traversing a node, all\n * properties of the object are examined and any node or array values are\n * recursively traversed. In typical parse trees, the children of a node are\n * in a `children` or `content` array, but this class is designed to handle\n * more general trees. The Perseus markdown parser, for example, produces\n * nodes of type \"table\" that have children in the `header` and `cells`\n * properties.\n *\n * CAUTION: the traverse() method does not make any attempt to detect\n * cycles. If you call it on a cyclic graph instead of a tree, it will cause\n * infinite recursion (or, more likely, a stack overflow).\n *\n * TODO(davidflanagan): it probably wouldn't be hard to detect cycles: when\n * pushing a new node onto the containers stack we could just check that it\n * isn't already there.\n *\n * If a node has a text-valued `content` property, it is taken to be the\n * plain-text content of the node. The traverse() method concatenates these\n * content strings and passes them to the traversal callback for each\n * node. This means that the callback has access the full text content of its\n * node and all of the nodes descendants.\n *\n * See the TraversalState class for more information on what information and\n * methods are available to the traversal callback.\n **/\n\nimport {Errors, PerseusError} from \"@khanacademy/perseus-core\";\n\n// TreeNode is the type of a node in a parse tree. The only real requirement is\n// that every node has a string-valued `type` property\nexport type TreeNode = {\n type: string;\n widgetType?: string;\n id?: string;\n};\n\n// TraversalCallback is the type of the callback function passed to the\n// traverse() method. It is invoked with node, state, and content arguments\n// and is expected to return nothing.\nexport type TraversalCallback = (\n node: TreeNode,\n state: TraversalState,\n content: string,\n) => void;\n\n// This is the TreeTransformer class described in detail at the\n// top of this file.\nexport default class TreeTransformer {\n root: TreeNode;\n\n // To create a tree transformer, just pass the root node of the tree\n constructor(root: TreeNode) {\n this.root = root;\n }\n\n // A utility function for determing whether an arbitrary value is a node\n static isNode(n: any): boolean {\n return n && typeof n === \"object\" && typeof n.type === \"string\";\n }\n\n // Determines whether a value is a node with type \"text\" and has\n // a text-valued `content` property.\n static isTextNode(n: any): boolean {\n return (\n TreeTransformer.isNode(n) &&\n n.type === \"text\" &&\n typeof n.content === \"string\"\n );\n }\n\n // This is the main entry point for the traverse() method. See the comment\n // at the top of this file for a detailed description. Note that this\n // method just creates a new TraversalState object to use for this\n // traversal and then invokes the internal _traverse() method to begin the\n // recursion.\n traverse(f: TraversalCallback): void {\n this._traverse(this.root, new TraversalState(this.root), f);\n }\n\n // Do a post-order traversal of node and its descendants, invoking the\n // callback function f() once for each node and returning the concatenated\n // text content of the node and its descendants. f() is passed three\n // arguments: the current node, a TraversalState object representing the\n // current state of the traversal, and a string that holds the\n // concatenated text of the node and its descendants.\n //\n // This private method holds all the traversal logic and implementation\n // details. Note that this method uses the TraversalState object to store\n // information about the structure of the tree.\n _traverse(\n n: TreeNode | Array<TreeNode>,\n state: TraversalState,\n f: TraversalCallback,\n ): string {\n let content = \"\";\n if (TreeTransformer.isNode(n)) {\n // If we were called on a node object, then we handle it\n // this way.\n const node = n as TreeNode; // safe cast; we just tested\n\n // Put the node on the stack before recursing on its children\n state._containers.push(node);\n state._ancestors.push(node);\n\n // Record the node's text content if it has any.\n // Usually this is for nodes with a type property of \"text\",\n // but other nodes types like \"math\" may also have content.\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n if (typeof node.content === \"string\") {\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n content = node.content;\n }\n\n // Recurse on the node. If there was content above, then there\n // probably won't be any children to recurse on, but we check\n // anyway.\n //\n // If we wanted to make the traversal completely specific to the\n // actual Perseus parse trees that we'll be dealing with we could\n // put a switch statement here to dispatch on the node type\n // property with specific recursion steps for each known type of\n // node.\n const keys = Object.keys(node);\n keys.forEach((key) => {\n // Never recurse on the type property\n if (key === \"type\") {\n return;\n }\n // Ignore properties that are null or primitive and only\n // recurse on objects and arrays. Note that we don't do a\n // isNode() check here. That is done in the recursive call to\n // _traverse(). Note that the recursive call on each child\n // returns the text content of the child and we add that\n // content to the content for this node. Also note that we\n // push the name of the property we're recursing over onto a\n // TraversalState stack.\n const value = node[key];\n if (value && typeof value === \"object\") {\n state._indexes.push(key);\n content += this._traverse(value, state, f);\n state._indexes.pop();\n }\n });\n\n // Restore the stacks after recursing on the children\n state._currentNode = state._ancestors.pop();\n state._containers.pop();\n\n // And finally call the traversal callback for this node. Note\n // that this is post-order traversal. We call the callback on the\n // way back up the tree, not on the way down. That way we already\n // know all the content contained within the node.\n f(node, state, content);\n } else if (Array.isArray(n)) {\n // If we were called on an array instead of a node, then\n // this is the code we use to recurse.\n const nodes = n;\n\n // Push the array onto the stack. This will allow the\n // TraversalState object to locate siblings of this node.\n state._containers.push(nodes);\n\n // Now loop through this array and recurse on each element in it.\n // Before recursing on an element, we push its array index on a\n // TraversalState stack so that the TraversalState sibling methods\n // can work. Note that TraversalState methods can alter the length\n // of the array, and change the index of the current node, so we\n // are careful here to test the array length on each iteration and\n // to reset the index when we pop the stack. Also note that we\n // concatentate the text content of the children.\n let index = 0;\n while (index < nodes.length) {\n state._indexes.push(index);\n content += this._traverse(nodes[index], state, f);\n // Casting to convince TypeScript that this is a number\n index = (state._indexes.pop() as number) + 1;\n }\n\n // Pop the array off the stack. Note, however, that we do not call\n // the traversal callback on the array. That function is only\n // called for nodes, not arrays of nodes.\n state._containers.pop();\n }\n\n // The _traverse() method always returns the text content of\n // this node and its children. This is the one piece of state that\n // is not tracked in the TraversalState object.\n return content;\n }\n}\n\n// An instance of this class is passed to the callback function for\n// each node traversed. The class itself is not exported, but its\n// methods define the API available to the traversal callback.\n\n/**\n * This class represents the state of a tree traversal. An instance is created\n * by the traverse() method of the TreeTransformer class to maintain the state\n * for that traversal, and the instance is passed to the traversal callback\n * function for each node that is traversed. This class is not intended to be\n * instantiated directly, but is exported so that its type can be used for\n * type annotaions.\n **/\nexport class TraversalState {\n // The root node of the tree being traversed\n root: TreeNode;\n\n // These are internal state properties. Use the accessor methods defined\n // below instead of using these properties directly. Note that the\n // _containers and _indexes stacks can have two different types of\n // elements, depending on whether we just recursed on an array or on a\n // node. This is hard for TypeScript to deal with, so you'll see a number of\n // type casts through the any type when working with these two properties.\n _currentNode: TreeNode | null | undefined;\n _containers: Stack<TreeNode | Array<TreeNode>>;\n _indexes: Stack<string | number>;\n _ancestors: Stack<TreeNode>;\n\n // The constructor just stores the root node and creates empty stacks.\n constructor(root: TreeNode) {\n this.root = root;\n\n // When the callback is called, this property will hold the\n // node that is currently being traversed.\n this._currentNode = null;\n\n // This is a stack of the objects and arrays that we've\n // traversed through before reaching the currentNode.\n // It is different than the ancestors array.\n this._containers = new Stack();\n\n // This stack has the same number of elements as the _containers\n // stack. The last element of this._indexes[] is the index of\n // the current node in the object or array that is the last element\n // of this._containers[]. If the last element of this._containers[] is\n // an array, then the last element of this stack will be a number.\n // Otherwise if the last container is an object, then the last index\n // will be a string property name.\n this._indexes = new Stack();\n\n // This is a stack of the ancestor nodes of the current one.\n // It is different than the containers[] stack because it only\n // includes nodes, not arrays.\n this._ancestors = new Stack();\n }\n\n /**\n * Return the current node in the traversal. Any time the traversal\n * callback is called, this method will return the name value as the\n * first argument to the callback.\n */\n currentNode(): TreeNode {\n return this._currentNode || this.root;\n }\n\n /**\n * Return the parent of the current node, if there is one, or null.\n */\n parent(): TreeNode | null | undefined {\n return this._ancestors.top();\n }\n\n /**\n * Return an array of ancestor nodes. The first element of this array is\n * the same as this.parent() and the last element is the root node. If we\n * are currently at the root node, the the returned array will be empty.\n * This method makes a copy of the internal state, so modifications to the\n * returned array have no effect on the traversal.\n */\n ancestors(): ReadonlyArray<TreeNode> {\n return this._ancestors.values();\n }\n\n /**\n * Return the next sibling of this node, if it has one, or null otherwise.\n */\n nextSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n\n // If we're at the root of the tree or if the parent is an\n // object instead of an array, then there are no siblings.\n if (!siblings || !Array.isArray(siblings)) {\n return null;\n }\n\n // The top index is a number because the top container is an array\n const index = this._indexes.top() as number;\n if (siblings.length > index + 1) {\n return siblings[index + 1];\n }\n return null; // There is no next sibling\n }\n\n /**\n * Return the previous sibling of this node, if it has one, or null\n * otherwise.\n */\n previousSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n\n // If we're at the root of the tree or if the parent is an\n // object instead of an array, then there are no siblings.\n if (!siblings || !Array.isArray(siblings)) {\n return null;\n }\n\n // The top index is a number because the top container is an array\n const index = this._indexes.top() as number;\n if (index > 0) {\n return siblings[index - 1];\n }\n return null; // There is no previous sibling\n }\n\n /**\n * Remove the next sibling node (if there is one) from the tree. Returns\n * the removed sibling or null. This method makes it easy to traverse a\n * tree and concatenate adjacent text nodes into a single node.\n */\n removeNextSibling(): TreeNode | null | undefined {\n const siblings = this._containers.top();\n if (siblings && Array.isArray(siblings)) {\n // top index is a number because top container is an array\n const index = this._indexes.top() as number;\n if (siblings.length > index + 1) {\n return siblings.splice(index + 1, 1)[0];\n }\n }\n return null;\n }\n\n /**\n * Replace the current node in the tree with the specified nodes. If no\n * nodes are passed, this is a node deletion. If one node (or array) is\n * passed, this is a 1-for-1 replacement. If more than one node is passed\n * then this is a combination of deletion and insertion. The new node or\n * nodes will not be traversed, so this method can safely be used to\n * reparent the current node node beneath a new parent.\n *\n * This method throws an error if you attempt to replace the root node of\n * the tree.\n */\n replace(...replacements: ReadonlyArray<TreeNode>): void {\n const parent = this._containers.top();\n if (!parent) {\n throw new PerseusError(\n \"Can't replace the root of the tree\",\n Errors.Internal,\n );\n }\n\n // The top of the container stack is either an array or an object\n // and the top of the indexes stack is a corresponding array index\n // or object property. This is hard for TypeScript, so we have to do some\n // unsafe casting and be careful when we use which cast version\n if (Array.isArray(parent)) {\n const index = this._indexes.top() as number;\n // For an array parent we just splice the new nodes in\n parent.splice(index, 1, ...replacements);\n // Adjust the index to account for the changed array length.\n // We don't want to traverse any of the newly inserted nodes.\n this._indexes.pop();\n this._indexes.push(index + replacements.length - 1);\n } else {\n const property = this._indexes.top() as string;\n // For an object parent we care how many new nodes there are\n if (replacements.length === 0) {\n // Deletion\n delete parent[property];\n } else if (replacements.length === 1) {\n // Replacement\n parent[property] = replacements[0];\n } else {\n // Replace one node with an array of nodes\n parent[property] = replacements;\n }\n }\n }\n\n /**\n * Returns true if the current node has a previous sibling and false\n * otherwise. If this method returns false, then previousSibling() will\n * return null, and goToPreviousSibling() will throw an error.\n */\n hasPreviousSibling(): boolean {\n return (\n Array.isArray(this._containers.top()) &&\n (this._indexes.top() as number) > 0\n );\n }\n\n /**\n * Modify this traversal state object to have the state it would have had\n * when visiting the previous sibling. Note that you may want to use\n * clone() to make a copy before modifying the state object like this.\n * This mutator method is not typically used during ordinary tree\n * traversals, but is used by the Selector class for matching multi-node\n * selectors.\n */\n goToPreviousSibling(): void {\n if (!this.hasPreviousSibling()) {\n throw new PerseusError(\n \"goToPreviousSibling(): node has no previous sibling\",\n Errors.Internal,\n );\n }\n\n this._currentNode = this.previousSibling();\n // Since we know that we have a previous sibling, we know that\n // the value on top of the stack is a number, but we have to do\n // this unsafe cast because TypeScript doesn't know that.\n const index = this._indexes.pop() as number;\n this._indexes.push(index - 1);\n }\n\n /**\n * Returns true if the current node has an ancestor and false otherwise.\n * If this method returns false, then the parent() method will return\n * null and goToParent() will throw an error\n */\n hasParent(): boolean {\n return this._ancestors.size() !== 0;\n }\n\n /**\n * Modify this object to look like it will look when we (later) visit the\n * parent node of this node. You should not modify the instance passed to\n * the tree traversal callback. Instead, make a copy with the clone()\n * method and modify that. This mutator method is not typically used\n * during ordinary tree traversals, but is used by the Selector class for\n * matching multi-node selectors that involve parent and ancestor\n * selectors.\n */\n goToParent(): void {\n if (!this.hasParent()) {\n throw new PerseusError(\n \"goToParent(): node has no ancestor\",\n Errors.NotAllowed,\n );\n }\n\n this._currentNode = this._ancestors.pop();\n\n // We need to pop the containers and indexes stacks at least once\n // and more as needed until we restore the invariant that\n // this._containers.top()[this.indexes.top()] === this._currentNode\n //\n while (\n this._containers.size() &&\n this._containers.top()[this._indexes.top()] !== this._currentNode\n ) {\n this._containers.pop();\n this._indexes.pop();\n }\n }\n\n /**\n * Return a new TraversalState object that is a copy of this one.\n * This method is useful in conjunction with the mutating methods\n * goToParent() and goToPreviousSibling().\n */\n clone(): TraversalState {\n const clone = new TraversalState(this.root);\n clone._currentNode = this._currentNode;\n clone._containers = this._containers.clone();\n clone._indexes = this._indexes.clone();\n clone._ancestors = this._ancestors.clone();\n return clone;\n }\n\n /**\n * Returns true if this TraversalState object is equal to that\n * TraversalState object, or false otherwise. This method exists\n * primarily for use by our unit tests.\n */\n equals(that: TraversalState): boolean {\n return (\n this.root === that.root &&\n this._currentNode === that._currentNode &&\n this._containers.equals(that._containers) &&\n this._indexes.equals(that._indexes) &&\n this._ancestors.equals(that._ancestors)\n );\n }\n}\n\n/**\n * This class is an internal utility that just treats an array as a stack\n * and gives us a top() method so we don't have to write expressions like\n * `ancestors[ancestors.length-1]`. The values() method automatically\n * copies the internal array so we don't have to worry about client code\n * modifying our internal stacks. The use of this Stack abstraction makes\n * the TraversalState class simpler in a number of places.\n */\nclass Stack<T> {\n stack: Array<T>;\n\n constructor(array?: ReadonlyArray<T> | null) {\n this.stack = array ? array.slice(0) : [];\n }\n\n /** Push a value onto the stack. */\n push(v: T): void {\n this.stack.push(v);\n }\n\n /** Pop a value off of the stack. */\n pop(): T {\n // @ts-expect-error - TS2322 - Type 'T | undefined' is not assignable to type 'T'.\n return this.stack.pop();\n }\n\n /** Return the top value of the stack without popping it. */\n top(): T {\n return this.stack[this.stack.length - 1];\n }\n\n /** Return a copy of the stack as an array */\n values(): ReadonlyArray<T> {\n return this.stack.slice(0);\n }\n\n /** Return the number of elements in the stack */\n size(): number {\n return this.stack.length;\n }\n\n /** Return a string representation of the stack */\n toString(): string {\n return this.stack.toString();\n }\n\n /** Return a shallow copy of the stack */\n clone(): Stack<T> {\n return new Stack(this.stack);\n }\n\n /**\n * Compare this stack to another and return true if the contents of\n * the two arrays are the same.\n */\n equals(that: Stack<T>): boolean {\n if (!that || !that.stack || that.stack.length !== this.stack.length) {\n return false;\n }\n for (let i = 0; i < this.stack.length; i++) {\n if (this.stack[i] !== that.stack[i]) {\n return false;\n }\n }\n return true;\n }\n}\n","// This file is processed by a Rollup plugin (replace) to inject the production\n// version number during the release build.\n// In dev, you'll never see the version number.\n\nimport {addLibraryVersionToPerseusDebug} from \"@khanacademy/perseus-core\";\n\nconst libName = \"@khanacademy/perseus-linter\";\nexport const libVersion = \"__lib_version__\";\n\naddLibraryVersionToPerseusDebug(libName, libVersion);\n","// Define the shape of the linter context object that is passed through the\n// tree with additional information about what we are checking.\nimport PropTypes from \"prop-types\";\n\nimport type {LinterContextProps} from \"./types\";\n\nexport const linterContextProps = PropTypes.shape({\n contentType: PropTypes.string,\n highlightLint: PropTypes.bool,\n paths: PropTypes.arrayOf(PropTypes.string),\n stack: PropTypes.arrayOf(PropTypes.string),\n});\n\nexport const linterContextDefault: LinterContextProps = {\n contentType: \"\",\n highlightLint: false,\n paths: [] as ReadonlyArray<any>,\n stack: [] as ReadonlyArray<any>,\n};\n","import Rule from \"./rule\";\nimport AllRules from \"./rules/all-rules\";\nimport TreeTransformer from \"./tree-transformer\";\n\nexport {libVersion} from \"./version\";\n\nexport {linterContextProps, linterContextDefault} from \"./proptypes\";\nexport type {LinterContextProps} from \"./types\";\n\nconst allLintRules: ReadonlyArray<any> = AllRules.filter(\n (r) => r.severity < Rule.Severity.BULK_WARNING,\n);\n\nexport {Rule, allLintRules as rules};\n\n/**\n * Run the Perseus linter over the specified markdown parse tree,\n * with the specified context object, and\n * return a (possibly empty) array of lint warning objects. If the\n * highlight argument is true, this function also modifies the parse\n * tree to add \"lint\" nodes that can be visually rendered,\n * highlighting the problems for the user. The optional rules argument\n * is an array of Rule objects specifying which lint rules should be\n * applied to this parse tree. When omitted, a default set of rules is used.\n *\n * The context object may have additional properties that some lint\n * rules require:\n *\n * context.content is the source content string that was parsed to create\n * the parse tree.\n *\n * context.widgets is the widgets object associated\n * with the content string\n *\n * TODO: to make this even more general, allow the first argument to be\n * a string and run the parser over it in that case? (but ignore highlight\n * in that case). This would allow the one function to be used for both\n * online linting and batch linting.\n */\nexport function runLinter(\n tree: any,\n context: any,\n highlight: boolean,\n rules: ReadonlyArray<any> = allLintRules,\n): ReadonlyArray<any> {\n const warnings: Array<any> = [];\n const tt = new TreeTransformer(tree);\n\n // The markdown parser often outputs adjacent text nodes. We\n // coalesce them before linting for efficiency and accuracy.\n tt.traverse((node, state, content) => {\n if (TreeTransformer.isTextNode(node)) {\n let next = state.nextSibling();\n while (TreeTransformer.isTextNode(next)) {\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'. | TS2533 - Object is possibly 'null' or 'undefined'. | TS2339 - Property 'content' does not exist on type 'TreeNode'.\n node.content += next.content;\n state.removeNextSibling();\n next = state.nextSibling();\n }\n }\n });\n\n // HTML tables are complicated, and the CSS we use in\n // ../components/lint.jsx to display lint does not work to\n // correctly position the lint indicators in the margin when the\n // lint is inside a table. So as a workaround we keep track of all\n // the lint that appears within a table and move it up to the\n // table element itself.\n //\n // It is not ideal to have to do this here,\n // but it is cleaner here than fixing up the lint during rendering\n // in perseus-markdown.jsx. If our lint display was simpler and\n // did not require indicators in the margin, this wouldn't be a\n // problem. Or, if we modified the lint display stuff so that\n // indicator positioning and tooltip display were both handled\n // with JavaScript (instead of pure CSS), then we could avoid this\n // issue too. But using JavaScript has its own downsides: there is\n // risk that the linter JavaScript would interfere with\n // widget-related Javascript.\n let tableWarnings: Array<never> = [];\n let insideTable = false;\n\n // Traverse through the nodes of the parse tree. At each node, loop\n // through the array of lint rules and check whether there is a\n // lint violation at that node.\n tt.traverse((node, state, content) => {\n const nodeWarnings: Array<any> = [];\n\n // If our rule is only designed to be tested against a particular\n // content type and we're not in that content type, we don't need to\n // consider that rule.\n const applicableRules = rules.filter((r) => r.applies(context));\n\n // Generate a stack so we can identify our position in the tree in\n // lint rules\n const stack = [...context.stack];\n stack.push(node.type);\n\n const nodeContext = {\n ...context,\n stack: stack.join(\".\"),\n } as const;\n\n applicableRules.forEach((rule) => {\n const warning = rule.check(node, state, content, nodeContext);\n if (warning) {\n // The start and end locations are relative to this\n // particular node, and so are not generally very useful.\n // TODO: When the markdown parser saves the node\n // locations in the source string then we can add\n // these numbers to that one and get and absolute\n // character range that will be useful\n if (warning.start || warning.end) {\n warning.target = content.substring(\n warning.start,\n warning.end,\n );\n }\n\n // Add the warning to the list of all lint we've found\n warnings.push(warning);\n\n // If we're going to be highlighting lint, then we also\n // need to keep track of warnings specific to this node.\n if (highlight) {\n nodeWarnings.push(warning);\n }\n }\n });\n\n // If we're not highlighting lint in the tree, then we're done\n // traversing this node.\n if (!highlight) {\n return;\n }\n\n // If the node we are currently at is a table, and there was lint\n // inside the table, then we want to add that lint here\n if (node.type === \"table\") {\n if (tableWarnings.length) {\n nodeWarnings.push(...tableWarnings);\n }\n\n // We're not in a table anymore, and don't have to remember\n // the warnings for the table\n insideTable = false;\n tableWarnings = [];\n } else if (!insideTable) {\n // Otherwise, if we are not already inside a table, check\n // to see if we've entered one. Because this is a post-order\n // traversal we'll see the table contents before the table itself.\n // Note that once we're inside the table, we don't have to\n // do this check each time... We can just wait until we ascend\n // up to the table, then we'll know we're out of it.\n insideTable = state.ancestors().some((n) => n.type === \"table\");\n }\n\n // If we are inside a table and there were any warnings on\n // this node, then we need to save the warnings for display\n // on the table itself\n if (insideTable && nodeWarnings.length) {\n // @ts-expect-error - TS2345 - Argument of type 'any' is not assignable to parameter of type 'never'.\n tableWarnings.push(...nodeWarnings);\n }\n\n // If there were any warnings on this node, and if we're highlighting\n // lint, then reparent the node so we can highlight it. Note that\n // a single node can have multiple warnings. If this happends we\n // concatenate the warnings and newline separate them. (The lint.jsx\n // component that displays the warnings may want to convert the\n // newlines into <br> tags.) We also provide a lint rule name\n // so that lint.jsx can link to a document that provides more details\n // on that particular lint rule. If there is more than one warning\n // we only link to the first rule, however.\n //\n // Note that even if we're inside a table, we still reparent the\n // linty node so that it can be highlighted. We just make a note\n // of whether this lint is inside a table or not.\n if (nodeWarnings.length) {\n nodeWarnings.sort((a, b) => {\n return a.severity - b.severity;\n });\n\n if (node.type !== \"text\" || nodeWarnings.length > 1) {\n // If the linty node is not a text node, or if there is more\n // than one warning on a text node, then reparent the entire\n // node under a new lint node and put the warnings there.\n state.replace({\n type: \"lint\",\n // @ts-expect-error - TS2345 - Argument of type '{ type: string; content: TreeNode; message: string; ruleName: any; blockHighlight: any; insideTable: boolean; severity: any; }' is not assignable to parameter of type 'TreeNode'.\n content: node,\n message: nodeWarnings.map((w) => w.message).join(\"\\n\\n\"),\n ruleName: nodeWarnings[0].rule,\n blockHighlight: nodeContext.blockHighlight,\n insideTable: insideTable,\n severity: nodeWarnings[0].severity,\n });\n } else {\n //\n // Otherwise, it is a single warning on a text node, and we\n // only want to highlight the actual linty part of that string\n // of text. So we want to replace the text node with (in the\n // general case) three nodes:\n //\n // 1) A new text node that holds the non-linty prefix\n //\n // 2) A lint node that is the parent of a new text node\n // that holds the linty part\n //\n // 3) A new text node that holds the non-linty suffix\n //\n // If the lint begins and/or ends at the boundaries of the\n // original text node, then nodes 1 and/or 3 won't exist, of\n // course.\n //\n // Note that we could generalize this to work with multple\n // warnings on a text node as long as the warnings are\n // non-overlapping. Hopefully, though, multiple warnings in a\n // single text node will be rare in practice. Also, we don't\n // have a good way to display multiple lint indicators on a\n // single line, so keeping them combined in that case might\n // be the best thing, anyway.\n //\n // @ts-expect-error - TS2339 - Property 'content' does not exist on type 'TreeNode'.\n const content = node.content; // Text nodes have content\n const warning = nodeWarnings[0]; // There is only one warning.\n // These are the lint boundaries within the content\n const start = warning.start || 0;\n const end = warning.end || content.length;\n const prefix = content.substring(0, start);\n const lint = content.substring(start, end);\n const suffix = content.substring(end);\n // TODO(FEI-5003): Give this a real type.\n const replacements: any[] = []; // What we'll replace the node with\n\n // The prefix text node, if there is one\n if (prefix) {\n replacements.push({\n type: \"text\",\n content: prefix,\n });\n }\n\n // The lint node wrapped around the linty text\n replacements.push({\n type: \"lint\",\n content: {\n type: \"text\",\n content: lint,\n },\n message: warning.message,\n ruleName: warning.rule,\n insideTable: insideTable,\n severity: warning.severity,\n });\n\n // The suffix node, if there is one\n if (suffix) {\n replacements.push({\n type: \"text\",\n content: suffix,\n });\n }\n\n // Now replace the lint text node with the one to three\n // nodes in the replacement array\n state.replace(...replacements);\n }\n }\n });\n\n return warnings;\n}\n\nexport function pushContextStack(context: any, name: string): any {\n const stack = context.stack || [];\n return {\n ...context,\n stack: stack.concat(name),\n };\n}\n"],"names":["Selector","parse","selectorText","Parser","match","state","PerseusError","Errors","NotAllowed","toString","constructor","s","tokens","tokenIndex","trim","replace","TOKENS","nextToken","consume","isIdentifier","c","skipSpace","ts","parseTreeSelector","token","treeSelectors","ParseError","push","SelectorList","ns","parseNodeSelector","AncestorCombinator","ParentCombinator","PreviousCombinator","SiblingCombinator","t","AnyNode","TypeSelector","Error","message","selectors","i","length","result","currentNode","type","node","SelectorCombinator","left","right","rightResult","clone","hasParent","goToParent","leftResult","concat","hasPreviousSibling","goToPreviousSibling","Rule","name","severity","selector","pattern","lint","applies","InvalidInput","metadata","Severity","BULK_WARNING","DEFAULT_SELECTOR","args","_defaultLintFunction","makeRule","options","makePattern","check","traversalState","content","context","selectorMatch","patternMatch","FakePatternMatch","error","rule","start","end","e","stack","index","RegExp","lastSlash","lastIndexOf","expression","substring","flags","input","ERROR","WARNING","GUIDELINE","HOSTNAME","getHostname","url","nodes","target","hostname","endsWith","buttonNotInButtonSet","set","stringToButtonSet","_context$widgets","widgetType","nodeId","id","widget","widgets","answers","answerForms","buttons","buttonSets","answer","str","Object","entries","value","includes","contentType","level","currentHeading","previousHeading","littleWords","and","nor","but","the","for","isCapitalized","word","toUpperCase","locale","heading","words","split","shift","filter","w","hasOwnProperty","every","image","alt","indexOf","caption","text","nextpair","static","table","headerLength","header","rowLengths","cells","map","r","AbsoluteUrl","BlockquotedMath","BlockquotedWidget","DoubleSpacingAfterTerminal","ExpressionWidget","ExtraContentSpacing","HeadingLevel1","HeadingLevelSkip","HeadingSentenceCase","HeadingTitleCase","ImageAltText","ImageInTable","LinkClickHere","LongParagraph","MathAdjacent","MathAlignExtraBreak","MathAlignLinebreaks","MathEmpty","MathFontSize","MathFrac","MathNested","MathStartsWithSpace","MathTextEmpty","NestedLists","StaticWidgetInQuestionStem","TableMissingCells","UnescapedDollar","WidgetInTable","MathWithoutDollars","UnbalancedCodeDelimiters","ImageSpacesAroundUrls","ImageWidget","TreeTransformer","root","isNode","n","isTextNode","traverse","f","_traverse","TraversalState","_containers","_ancestors","keys","forEach","key","_indexes","pop","_currentNode","Array","isArray","Stack","parent","top","ancestors","values","nextSibling","siblings","previousSibling","removeNextSibling","splice","replacements","Internal","property","size","equals","that","array","slice","v","libName","libVersion","addLibraryVersionToPerseusDebug","linterContextProps","PropTypes","shape","string","highlightLint","bool","paths","arrayOf","linterContextDefault","allLintRules","AllRules","runLinter","tree","highlight","rules","warnings","tt","next","tableWarnings","insideTable","nodeWarnings","applicableRules","nodeContext","_extends","join","warning","some","sort","a","b","ruleName","blockHighlight","prefix","suffix","pushContextStack"],"mappings":";;;AAAe,SAAS,QAAQ,GAAG;AACnC,EAAE,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,UAAU,MAAM,EAAE;AAChD,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC/C,MAAM,IAAI,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAChC;AACA,MAAM,KAAK,IAAI,GAAG,IAAI,MAAM,EAAE;AAC9B,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;AAC/D,UAAU,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;AACpC,SAAS;AACT,OAAO;AACP,KAAK;AACL;AACA,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,CAAC;AACJ;AACA,EAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AACzC;;AChBA;AA4FA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,MAAMA,QAAQ,CAAC;EAC1B,OAAOC,KAAKA,CAACC,YAAoB,EAAY;IACzC,OAAO,IAAIC,MAA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I,CAACN,IAAI,CAAC5C,KAAK,CAACC,KAAK,CAAC,CAAA;AACzC,QAAA,IAAIiD,UAAU,EAAE;AACZ,UAAA,OAAOA,UAAU,CAACC,MAAM,CAACL,WAAW,CAAC,CAAA;AACzC,SAAA;AACJ,OAAA;AACJ,KAAA;AACA,IAAA,OAAO,IAAI,CAAA;AACf,GAAA;AAEAzC,EAAAA,QAAQA,GAAW;AACf,IAAA,OAAO,IAAI,CAACuC,IAAI,CAACvC,QAAQ,EAAE,GAAG,KAAK,GAAG,IAAI,CAACwC,KAAK,CAACxC,QAAQ,EAAE,CAAA;AAC/D,GAAA;AACJ;;ACvfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AAGA;AAYA;AACA;AACA;AACA;AACA;AAiBA;AACA;AACA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACe,MAAMiD,IAAI,CAAC;AAUtB;AACA;AACAhD,EAAAA,WAAWA,CACPiD,IAA+B,EAC/BC,QAAmC,EACnCC,QAAqC,EACrCC,OAAkC,EAClCC,IAAq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C,UAAAA,OAAO,EAAE;AACLhC,YAAAA,IAAI,EAAE,MAAM;AACZgC,YAAAA,OAAO,EAAEd,IAAAA;WACZ;UACDxB,OAAO,EAAE4N,OAAO,CAAC5N,OAAO;UACxBiO,QAAQ,EAAEL,OAAO,CAAChL,IAAI;AACtB0K,UAAAA,WAAW,EAAEA,WAAW;UACxBjM,QAAQ,EAAEuM,OAAO,CAACvM,QAAAA;AACtB,SAAC,CAAC,CAAA;;AAEF;AACA,QAAA,IAAI+M,MAAM,EAAE;UACR7C,YAAY,CAACnM,IAAI,CAAC;AACdkB,YAAAA,IAAI,EAAE,MAAM;AACZgC,YAAAA,OAAO,EAAE8L,MAAAA;AACb,WAAC,CAAC,CAAA;AACN,SAAA;;AAEA;AACA;AACAtQ,QAAAA,KAAK,CAACU,OAAO,CAAC,GAAG+M,YAAY,CAAC,CAAA;AAClC,OAAA;AACJ,KAAA;AACJ,GAAC,CAAC,CAAA;AAEF,EAAA,OAAO2B,QAAQ,CAAA;AACnB,CAAA;AAEO,SAASmB,gBAAgBA,CAAC9L,OAAY,EAAEnB,IAAY,EAAO;AAC9D,EAAA,MAAM4B,KAAK,GAAGT,OAAO,CAACS,KAAK,IAAI,EAAE,CAAA;EACjC,OAAA0K,QAAA,KACOnL,OAAO,EAAA;AACVS,IAAAA,KAAK,EAAEA,KAAK,CAAChC,MAAM,CAACI,IAAI,CAAA;AAAC,GAAA,CAAA,CAAA;AAEjC;;;;"}
package/dist/index.js CHANGED
@@ -1830,7 +1830,7 @@ class Stack {
1830
1830
 
1831
1831
  // This file is processed by a Rollup plugin (replace) to inject the production
1832
1832
  const libName = "@khanacademy/perseus-linter";
1833
- const libVersion = "1.2.5";
1833
+ const libVersion = "1.2.6";
1834
1834
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
1835
1835
 
1836
1836
  // Define the shape of the linter context object that is passed through the
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Linter engine for Perseus",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "1.2.5",
6
+ "version": "1.2.6",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -25,10 +25,10 @@
25
25
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
26
26
  },
27
27
  "dependencies": {
28
- "@khanacademy/perseus-core": "2.0.0"
28
+ "@khanacademy/perseus-core": "3.0.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@khanacademy/pure-markdown": "^0.3.14",
31
+ "@khanacademy/pure-markdown": "^0.3.15",
32
32
  "prop-types": "15.6.1"
33
33
  },
34
34
  "peerDependencies": {