@drghaliasri/butex 7.1.2 → 7.1.3

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/react.js CHANGED
@@ -4382,11 +4382,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
4382
4382
  }
4383
4383
  var leftDelimExpr = buildDelimiterExpr(
4384
4384
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
4385
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
4385
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
4386
4386
  );
4387
4387
  var rightDelimExpr = buildDelimiterExpr(
4388
4388
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
4389
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
4389
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
4390
4390
  );
4391
4391
  var DELIMITER_BASE_HEIGHT_PX = 18;
4392
4392
  var DELIMITER_MAX_SCALE = 4.8;
@@ -4399,7 +4399,7 @@ function applyDelimiterScale(pair, inner) {
4399
4399
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
4400
4400
  }
4401
4401
  function visibleDelimiter(expr) {
4402
- return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
4402
+ return expr.replace(/\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\(?:lvert|rvert|vert)/, "|").replace(/\\(?:lVert|rVert|Vert)/, "\u2016").replace("\\|", "\u2016");
4403
4403
  }
4404
4404
  function buildDelimiterNodeBody(node, buildChain) {
4405
4405
  const pair = document.createElement("span");
@@ -8956,9 +8956,56 @@ function astNodeToEditorNode(node) {
8956
8956
  }
8957
8957
  return { editable: false, reason: `\u0639\u0642\u062F\u0629 \u0631\u064A\u0627\u0636\u064A\u0629 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645\u0629 \u062D\u0627\u0644\u064A\u0627: ${node.nodeType}` };
8958
8958
  }
8959
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
8960
+ "\\vert": "\\vert",
8961
+ "\\lvert": "\\rvert",
8962
+ "\\Vert": "\\Vert",
8963
+ "\\lVert": "\\rVert",
8964
+ "\\|": "\\|"
8965
+ };
8966
+ function isBareCommand(node, name) {
8967
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
8968
+ }
8969
+ function normalizeVerticalDelimiterCommands(chain) {
8970
+ const normalized = [];
8971
+ for (let index = 0; index < chain.chain.length; index += 1) {
8972
+ const left = chain.chain[index];
8973
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
8974
+ normalized.push(left);
8975
+ continue;
8976
+ }
8977
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
8978
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
8979
+ normalized.push(left);
8980
+ continue;
8981
+ }
8982
+ let rightIndex = -1;
8983
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
8984
+ if (isBareCommand(chain.chain[candidate], rightName)) {
8985
+ rightIndex = candidate;
8986
+ break;
8987
+ }
8988
+ }
8989
+ if (rightIndex < 0) {
8990
+ normalized.push(left);
8991
+ continue;
8992
+ }
8993
+ const right = chain.chain[rightIndex];
8994
+ const delimiter = new DelimiterNode(
8995
+ left.name,
8996
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
8997
+ right.name
8998
+ );
8999
+ delimiter.superscript = right.superscript;
9000
+ delimiter.subscript = right.subscript;
9001
+ normalized.push(delimiter);
9002
+ index = rightIndex;
9003
+ }
9004
+ return new ChainNode(normalized);
9005
+ }
8959
9006
  function chainToEditorChain(chain) {
8960
9007
  const nodes = [];
8961
- for (const astNode of chain.chain) {
9008
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
8962
9009
  const converted = astNodeToEditorNode(astNode);
8963
9010
  if (!converted.editable) {
8964
9011
  return converted;