@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.
@@ -5973,11 +5973,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
5973
5973
  }
5974
5974
  var leftDelimExpr = buildDelimiterExpr(
5975
5975
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
5976
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5976
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
5977
5977
  );
5978
5978
  var rightDelimExpr = buildDelimiterExpr(
5979
5979
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
5980
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5980
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
5981
5981
  );
5982
5982
  var DELIMITER_BASE_HEIGHT_PX = 18;
5983
5983
  var DELIMITER_MAX_SCALE = 4.8;
@@ -5990,7 +5990,7 @@ function applyDelimiterScale(pair, inner) {
5990
5990
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
5991
5991
  }
5992
5992
  function visibleDelimiter(expr) {
5993
- return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
5993
+ 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");
5994
5994
  }
5995
5995
  function buildDelimiterNodeBody(node, buildChain) {
5996
5996
  const pair = document.createElement("span");
@@ -8307,9 +8307,56 @@ function astNodeToEditorNode(node) {
8307
8307
  }
8308
8308
  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}` };
8309
8309
  }
8310
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
8311
+ "\\vert": "\\vert",
8312
+ "\\lvert": "\\rvert",
8313
+ "\\Vert": "\\Vert",
8314
+ "\\lVert": "\\rVert",
8315
+ "\\|": "\\|"
8316
+ };
8317
+ function isBareCommand(node, name) {
8318
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
8319
+ }
8320
+ function normalizeVerticalDelimiterCommands(chain) {
8321
+ const normalized = [];
8322
+ for (let index = 0; index < chain.chain.length; index += 1) {
8323
+ const left = chain.chain[index];
8324
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
8325
+ normalized.push(left);
8326
+ continue;
8327
+ }
8328
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
8329
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
8330
+ normalized.push(left);
8331
+ continue;
8332
+ }
8333
+ let rightIndex = -1;
8334
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
8335
+ if (isBareCommand(chain.chain[candidate], rightName)) {
8336
+ rightIndex = candidate;
8337
+ break;
8338
+ }
8339
+ }
8340
+ if (rightIndex < 0) {
8341
+ normalized.push(left);
8342
+ continue;
8343
+ }
8344
+ const right = chain.chain[rightIndex];
8345
+ const delimiter = new DelimiterNode(
8346
+ left.name,
8347
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
8348
+ right.name
8349
+ );
8350
+ delimiter.superscript = right.superscript;
8351
+ delimiter.subscript = right.subscript;
8352
+ normalized.push(delimiter);
8353
+ index = rightIndex;
8354
+ }
8355
+ return new ChainNode(normalized);
8356
+ }
8310
8357
  function chainToEditorChain(chain) {
8311
8358
  const nodes = [];
8312
- for (const astNode of chain.chain) {
8359
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
8313
8360
  const converted = astNodeToEditorNode(astNode);
8314
8361
  if (!converted.editable) {
8315
8362
  return converted;