@khanacademy/perseus-linter 4.6.8 → 4.6.9

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
@@ -4,7 +4,7 @@ import * as KAS from '@khanacademy/kas';
4
4
  import { parse, traverseContent } from '@khanacademy/pure-markdown';
5
5
  import { vector } from '@khanacademy/kmath';
6
6
 
7
- const libName="@khanacademy/perseus-linter";const libVersion="4.6.8";addLibraryVersionToPerseusDebug(libName,libVersion);
7
+ const libName="@khanacademy/perseus-linter";const libVersion="4.6.9";addLibraryVersionToPerseusDebug(libName,libVersion);
8
8
 
9
9
  const linterContextDefault={contentType:"",highlightLint:false,paths:[],stack:[]};
10
10
 
@@ -24,7 +24,7 @@ Use a relative URL beginning with / instead.`}}});
24
24
  var DoubleSpacingAfterTerminal = Rule.makeRule({name:"double-spacing-after-terminal",severity:Rule.Severity.BULK_WARNING,selector:"paragraph",pattern:/[.!\?] {2}/i,message:`Use a single space after a sentence-ending period, or
25
25
  any other kind of terminal punctuation.`});
26
26
 
27
- function buttonNotInButtonSet(name,set){return `Answer requires a button not found in the button sets: ${name} (in ${set})`}const stringToButtonSet={"\\sqrt":"prealgebra","\\sin":"trig","\\cos":"trig","\\tan":"trig","\\log":"logarithms","\\ln":"logarithms"};var ExpressionWidget = Rule.makeRule({name:"expression-widget",severity:Rule.Severity.WARNING,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="expression"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const answers=widget.options.answerForms;const buttons=widget.options.buttonSets;for(const answer of answers){for(const[str,set]of Object.entries(stringToButtonSet)){if(answer.value.includes(str)&&!buttons.includes(set)){return buttonNotInButtonSet(str,set)}}}}});
27
+ function buttonNotInButtonSet(name,set){return `Answer requires a button not found in the button sets: ${name} (in ${set})`}const stringToButtonSet={"\\sqrt":"prealgebra","^":"prealgebra","\\sin":"trig","\\cos":"trig","\\tan":"trig","\\log":"logarithms","\\ln":"logarithms"};var ExpressionWidget = Rule.makeRule({name:"expression-widget",severity:Rule.Severity.WARNING,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="expression"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context?.widgets?.[nodeId];if(!widget){return}const answers=widget.options.answerForms;const buttons=widget.options.buttonSets;for(const answer of answers){for(const[str,set]of Object.entries(stringToButtonSet)){if(answer.value.includes(str)&&!buttons.includes(set)){return buttonNotInButtonSet(str,set)}}}}});
28
28
 
29
29
  var ExpressionWidgetError = Rule.makeRule({name:"expression-widget-error",severity:Rule.Severity.ERROR,selector:"widget",lint:function(state,content,nodes,match,context){if(state.currentNode().widgetType!=="expression"){return}const nodeId=state.currentNode().id;if(!nodeId){return}const widget=context&&context.widgets&&context.widgets[nodeId];if(!widget){return}const issues=[];const{answerForms,functions}=widget.options;if(answerForms.length===0){issues.push("No answers specified.");}else {const hasCorrect=answerForms.some(form=>{return form.considered==="correct"});if(!hasCorrect){issues.push("No correct answer specified.");}answerForms.forEach((form,ix)=>{if(form.value===""){issues.push(`Answer ${ix+1} is empty.`);}else {const expression=KAS.parse(form.value,{functions:functions});if(!expression.parsed){issues.push(`Couldn't parse ${form.value}.`);}else if(form.simplify&&!expression.expr.isSimplified()){issues.push(`${form.value} isn't simplified, but is required to be.`);}}});}const allWarningsString=issues.join("\n\n");return allWarningsString}});
30
30