@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.
@@ -5109,11 +5109,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
5109
5109
  }
5110
5110
  var leftDelimExpr = buildDelimiterExpr(
5111
5111
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5112
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5112
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5113
5113
  );
5114
5114
  var rightDelimExpr = buildDelimiterExpr(
5115
5115
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5116
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5116
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5117
5117
  );
5118
5118
  var DELIMITER_BASE_HEIGHT_PX = 18;
5119
5119
  var DELIMITER_MAX_SCALE = 4.8;
@@ -5126,7 +5126,7 @@ function applyDelimiterScale(pair, inner) {
5126
5126
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5127
5127
  }
5128
5128
  function visibleDelimiter(expr) {
5129
- return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5129
+ 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");
5130
5130
  }
5131
5131
  function buildDelimiterNodeBody(node, buildChain) {
5132
5132
  const pair = document.createElement("span");
@@ -7443,9 +7443,56 @@ function astNodeToEditorNode(node) {
7443
7443
  }
7444
7444
  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}` };
7445
7445
  }
7446
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
7447
+ "\\vert": "\\vert",
7448
+ "\\lvert": "\\rvert",
7449
+ "\\Vert": "\\Vert",
7450
+ "\\lVert": "\\rVert",
7451
+ "\\|": "\\|"
7452
+ };
7453
+ function isBareCommand(node, name) {
7454
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
7455
+ }
7456
+ function normalizeVerticalDelimiterCommands(chain) {
7457
+ const normalized = [];
7458
+ for (let index = 0; index < chain.chain.length; index += 1) {
7459
+ const left = chain.chain[index];
7460
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
7461
+ normalized.push(left);
7462
+ continue;
7463
+ }
7464
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
7465
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
7466
+ normalized.push(left);
7467
+ continue;
7468
+ }
7469
+ let rightIndex = -1;
7470
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
7471
+ if (isBareCommand(chain.chain[candidate], rightName)) {
7472
+ rightIndex = candidate;
7473
+ break;
7474
+ }
7475
+ }
7476
+ if (rightIndex < 0) {
7477
+ normalized.push(left);
7478
+ continue;
7479
+ }
7480
+ const right = chain.chain[rightIndex];
7481
+ const delimiter = new DelimiterNode(
7482
+ left.name,
7483
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
7484
+ right.name
7485
+ );
7486
+ delimiter.superscript = right.superscript;
7487
+ delimiter.subscript = right.subscript;
7488
+ normalized.push(delimiter);
7489
+ index = rightIndex;
7490
+ }
7491
+ return new ChainNode(normalized);
7492
+ }
7446
7493
  function chainToEditorChain(chain) {
7447
7494
  const nodes = [];
7448
- for (const astNode of chain.chain) {
7495
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
7449
7496
  const converted = astNodeToEditorNode(astNode);
7450
7497
  if (!converted.editable) {
7451
7498
  return converted;