@drghaliasri/butex 7.1.2 → 7.1.4

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.
@@ -5080,11 +5080,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
5080
5080
  }
5081
5081
  var leftDelimExpr = buildDelimiterExpr(
5082
5082
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5083
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5083
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5084
5084
  );
5085
5085
  var rightDelimExpr = buildDelimiterExpr(
5086
5086
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5087
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5087
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5088
5088
  );
5089
5089
  var DELIMITER_BASE_HEIGHT_PX = 18;
5090
5090
  var DELIMITER_MAX_SCALE = 4.8;
@@ -5097,7 +5097,7 @@ function applyDelimiterScale(pair, inner) {
5097
5097
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5098
5098
  }
5099
5099
  function visibleDelimiter(expr) {
5100
- return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5100
+ 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");
5101
5101
  }
5102
5102
  function buildDelimiterNodeBody(node, buildChain) {
5103
5103
  const pair = document.createElement("span");
@@ -7414,9 +7414,56 @@ function astNodeToEditorNode(node) {
7414
7414
  }
7415
7415
  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}` };
7416
7416
  }
7417
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
7418
+ "\\vert": "\\vert",
7419
+ "\\lvert": "\\rvert",
7420
+ "\\Vert": "\\Vert",
7421
+ "\\lVert": "\\rVert",
7422
+ "\\|": "\\|"
7423
+ };
7424
+ function isBareCommand(node, name) {
7425
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
7426
+ }
7427
+ function normalizeVerticalDelimiterCommands(chain) {
7428
+ const normalized = [];
7429
+ for (let index = 0; index < chain.chain.length; index += 1) {
7430
+ const left = chain.chain[index];
7431
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
7432
+ normalized.push(left);
7433
+ continue;
7434
+ }
7435
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
7436
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
7437
+ normalized.push(left);
7438
+ continue;
7439
+ }
7440
+ let rightIndex = -1;
7441
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
7442
+ if (isBareCommand(chain.chain[candidate], rightName)) {
7443
+ rightIndex = candidate;
7444
+ break;
7445
+ }
7446
+ }
7447
+ if (rightIndex < 0) {
7448
+ normalized.push(left);
7449
+ continue;
7450
+ }
7451
+ const right = chain.chain[rightIndex];
7452
+ const delimiter = new DelimiterNode(
7453
+ left.name,
7454
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
7455
+ right.name
7456
+ );
7457
+ delimiter.superscript = right.superscript;
7458
+ delimiter.subscript = right.subscript;
7459
+ normalized.push(delimiter);
7460
+ index = rightIndex;
7461
+ }
7462
+ return new ChainNode(normalized);
7463
+ }
7417
7464
  function chainToEditorChain(chain) {
7418
7465
  const nodes = [];
7419
- for (const astNode of chain.chain) {
7466
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
7420
7467
  const converted = astNodeToEditorNode(astNode);
7421
7468
  if (!converted.editable) {
7422
7469
  return converted;