@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.
@@ -3104,11 +3104,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
3104
3104
  }
3105
3105
  var leftDelimExpr = buildDelimiterExpr(
3106
3106
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
3107
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3107
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3108
3108
  );
3109
3109
  var rightDelimExpr = buildDelimiterExpr(
3110
3110
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
3111
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3111
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3112
3112
  );
3113
3113
 
3114
3114
  // src/editor/display/frac.ts
@@ -4146,9 +4146,56 @@ function astNodeToEditorNode(node) {
4146
4146
  }
4147
4147
  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}` };
4148
4148
  }
4149
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
4150
+ "\\vert": "\\vert",
4151
+ "\\lvert": "\\rvert",
4152
+ "\\Vert": "\\Vert",
4153
+ "\\lVert": "\\rVert",
4154
+ "\\|": "\\|"
4155
+ };
4156
+ function isBareCommand(node, name) {
4157
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
4158
+ }
4159
+ function normalizeVerticalDelimiterCommands(chain) {
4160
+ const normalized = [];
4161
+ for (let index = 0; index < chain.chain.length; index += 1) {
4162
+ const left = chain.chain[index];
4163
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
4164
+ normalized.push(left);
4165
+ continue;
4166
+ }
4167
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
4168
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
4169
+ normalized.push(left);
4170
+ continue;
4171
+ }
4172
+ let rightIndex = -1;
4173
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
4174
+ if (isBareCommand(chain.chain[candidate], rightName)) {
4175
+ rightIndex = candidate;
4176
+ break;
4177
+ }
4178
+ }
4179
+ if (rightIndex < 0) {
4180
+ normalized.push(left);
4181
+ continue;
4182
+ }
4183
+ const right = chain.chain[rightIndex];
4184
+ const delimiter = new DelimiterNode(
4185
+ left.name,
4186
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
4187
+ right.name
4188
+ );
4189
+ delimiter.superscript = right.superscript;
4190
+ delimiter.subscript = right.subscript;
4191
+ normalized.push(delimiter);
4192
+ index = rightIndex;
4193
+ }
4194
+ return new ChainNode(normalized);
4195
+ }
4149
4196
  function chainToEditorChain(chain) {
4150
4197
  const nodes = [];
4151
- for (const astNode of chain.chain) {
4198
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
4152
4199
  const converted = astNodeToEditorNode(astNode);
4153
4200
  if (!converted.editable) {
4154
4201
  return converted;