@khanacademy/perseus 17.6.2 → 17.7.0

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/index.js CHANGED
@@ -1939,6 +1939,15 @@ const insertBraces = value => {
1939
1939
  // TODO(alex): Properly hack MathQuill to always use explicit braces.
1940
1940
  return value.replace(/([_^])([^{])/g, "$1{$2}");
1941
1941
  };
1942
+ const anglicizeOperators = tex => {
1943
+ // sen is used instead of sin in some languages, e.g. Portuguese.
1944
+ // To ensure that answers in various languages are graded correctly, we
1945
+ // convert operators to their Englishy forms.
1946
+ return tex.replace(/\\operatorname{sen}/g, "\\sin ");
1947
+ };
1948
+ const normalizeTex = tex => {
1949
+ return anglicizeOperators(insertBraces(tex));
1950
+ };
1942
1951
  const deriveKeypadVersion = apiOptions => {
1943
1952
  // We can derive which version of the keypad is in use. This is
1944
1953
  // a bit tricky, but this code will be relatively short-lived
@@ -2094,7 +2103,7 @@ class Expression extends React__namespace.Component {
2094
2103
  };
2095
2104
  }
2096
2105
  static getUserInputFromProps(props) {
2097
- return insertBraces(props.value);
2106
+ return normalizeTex(props.value);
2098
2107
  }
2099
2108
  static getOneCorrectAnswerFromRubric(rubric) {
2100
2109
  const correctAnswers = (rubric.answerForms || []).filter(answerForm => answerForm.considered === "correct");
@@ -2201,7 +2210,7 @@ class Expression extends React__namespace.Component {
2201
2210
  ___default["default"].extend(options, {
2202
2211
  decimal_separator: i18n__namespace.getDecimalSeparator()
2203
2212
  });
2204
- return KAS__namespace.parse(insertBraces(value), options);
2213
+ return KAS__namespace.parse(normalizeTex(value), options);
2205
2214
  };
2206
2215
  changeAndTrack = (e, cb) => {
2207
2216
  this.change("value", e, cb);
@@ -44140,7 +44149,7 @@ const init = function (options) {
44140
44149
 
44141
44150
  // This file is processed by a Rollup plugin (replace) to inject the production
44142
44151
  const libName = "@khanacademy/perseus";
44143
- const libVersion = "17.6.2";
44152
+ const libVersion = "17.7.0";
44144
44153
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
44145
44154
 
44146
44155
  const apiVersion = {