@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.
@@ -3075,11 +3075,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
3075
3075
  }
3076
3076
  var leftDelimExpr = buildDelimiterExpr(
3077
3077
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
3078
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3078
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
3079
3079
  );
3080
3080
  var rightDelimExpr = buildDelimiterExpr(
3081
3081
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
3082
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3082
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
3083
3083
  );
3084
3084
 
3085
3085
  // src/editor/display/frac.ts
@@ -4117,9 +4117,56 @@ function astNodeToEditorNode(node) {
4117
4117
  }
4118
4118
  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}` };
4119
4119
  }
4120
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
4121
+ "\\vert": "\\vert",
4122
+ "\\lvert": "\\rvert",
4123
+ "\\Vert": "\\Vert",
4124
+ "\\lVert": "\\rVert",
4125
+ "\\|": "\\|"
4126
+ };
4127
+ function isBareCommand(node, name) {
4128
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
4129
+ }
4130
+ function normalizeVerticalDelimiterCommands(chain) {
4131
+ const normalized = [];
4132
+ for (let index = 0; index < chain.chain.length; index += 1) {
4133
+ const left = chain.chain[index];
4134
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
4135
+ normalized.push(left);
4136
+ continue;
4137
+ }
4138
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
4139
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
4140
+ normalized.push(left);
4141
+ continue;
4142
+ }
4143
+ let rightIndex = -1;
4144
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
4145
+ if (isBareCommand(chain.chain[candidate], rightName)) {
4146
+ rightIndex = candidate;
4147
+ break;
4148
+ }
4149
+ }
4150
+ if (rightIndex < 0) {
4151
+ normalized.push(left);
4152
+ continue;
4153
+ }
4154
+ const right = chain.chain[rightIndex];
4155
+ const delimiter = new DelimiterNode(
4156
+ left.name,
4157
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
4158
+ right.name
4159
+ );
4160
+ delimiter.superscript = right.superscript;
4161
+ delimiter.subscript = right.subscript;
4162
+ normalized.push(delimiter);
4163
+ index = rightIndex;
4164
+ }
4165
+ return new ChainNode(normalized);
4166
+ }
4120
4167
  function chainToEditorChain(chain) {
4121
4168
  const nodes = [];
4122
- for (const astNode of chain.chain) {
4169
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
4123
4170
  const converted = astNodeToEditorNode(astNode);
4124
4171
  if (!converted.editable) {
4125
4172
  return converted;