@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.
@@ -3333,11 +3333,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
3333
3333
  }
3334
3334
  var leftDelimExpr = buildDelimiterExpr(
3335
3335
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
3336
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3336
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3337
3337
  );
3338
3338
  var rightDelimExpr = buildDelimiterExpr(
3339
3339
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
3340
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3340
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3341
3341
  );
3342
3342
 
3343
3343
  // src/editor/display/frac.ts
@@ -4383,9 +4383,56 @@ function astNodeToEditorNode(node) {
4383
4383
  }
4384
4384
  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}` };
4385
4385
  }
4386
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
4387
+ "\\vert": "\\vert",
4388
+ "\\lvert": "\\rvert",
4389
+ "\\Vert": "\\Vert",
4390
+ "\\lVert": "\\rVert",
4391
+ "\\|": "\\|"
4392
+ };
4393
+ function isBareCommand(node, name) {
4394
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
4395
+ }
4396
+ function normalizeVerticalDelimiterCommands(chain) {
4397
+ const normalized = [];
4398
+ for (let index = 0; index < chain.chain.length; index += 1) {
4399
+ const left = chain.chain[index];
4400
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
4401
+ normalized.push(left);
4402
+ continue;
4403
+ }
4404
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
4405
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
4406
+ normalized.push(left);
4407
+ continue;
4408
+ }
4409
+ let rightIndex = -1;
4410
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
4411
+ if (isBareCommand(chain.chain[candidate], rightName)) {
4412
+ rightIndex = candidate;
4413
+ break;
4414
+ }
4415
+ }
4416
+ if (rightIndex < 0) {
4417
+ normalized.push(left);
4418
+ continue;
4419
+ }
4420
+ const right = chain.chain[rightIndex];
4421
+ const delimiter = new DelimiterNode(
4422
+ left.name,
4423
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
4424
+ right.name
4425
+ );
4426
+ delimiter.superscript = right.superscript;
4427
+ delimiter.subscript = right.subscript;
4428
+ normalized.push(delimiter);
4429
+ index = rightIndex;
4430
+ }
4431
+ return new ChainNode(normalized);
4432
+ }
4386
4433
  function chainToEditorChain(chain) {
4387
4434
  const nodes = [];
4388
- for (const astNode of chain.chain) {
4435
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
4389
4436
  const converted = astNodeToEditorNode(astNode);
4390
4437
  if (!converted.editable) {
4391
4438
  return converted;