@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.
package/dist/react.mjs CHANGED
@@ -4364,11 +4364,11 @@ function buildDelimiterExpr(prefixes, delimiters) {
4364
4364
  }
4365
4365
  var leftDelimExpr = buildDelimiterExpr(
4366
4366
  ["\\left", "\\bigl", "\\Bigl", "\\biggl", "\\Biggl"],
4367
- ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
4367
+ ["(", "[", "\\{", "\\lfloor", "\\lceil", "\\langle", "`", "|", "\\|", "\\lvert", "\\vert", "\\lVert", "\\Vert"]
4368
4368
  );
4369
4369
  var rightDelimExpr = buildDelimiterExpr(
4370
4370
  ["\\right", "\\bigr", "\\Bigr", "\\biggr", "\\Biggr"],
4371
- [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
4371
+ [")", "]", "\\}", "\\rfloor", "\\rceil", "\\rangle", "`", "|", "\\|", "\\rvert", "\\vert", "\\rVert", "\\Vert"]
4372
4372
  );
4373
4373
  var DELIMITER_BASE_HEIGHT_PX = 18;
4374
4374
  var DELIMITER_MAX_SCALE = 4.8;
@@ -4381,7 +4381,7 @@ function applyDelimiterScale(pair, inner) {
4381
4381
  pair.style.setProperty("--butex-delim-scale", scale.toFixed(3));
4382
4382
  }
4383
4383
  function visibleDelimiter(expr) {
4384
- return expr.replace(/\\\\(?:left|right|bigl|Bigl|biggl|Biggl|bigr|Bigr|biggr|Biggr)/, "").replace("\\{", "{").replace("\\}", "}").replace(/\\\\(?:lvert|rvert|vert)/, "|").replace(/\\\\(?:lVert|rVert|Vert)/, "\u2016");
4384
+ 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");
4385
4385
  }
4386
4386
  function buildDelimiterNodeBody(node, buildChain) {
4387
4387
  const pair = document.createElement("span");
@@ -8938,9 +8938,56 @@ function astNodeToEditorNode(node) {
8938
8938
  }
8939
8939
  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}` };
8940
8940
  }
8941
+ var VERTICAL_DELIMITER_COMMAND_PAIRS = {
8942
+ "\\vert": "\\vert",
8943
+ "\\lvert": "\\rvert",
8944
+ "\\Vert": "\\Vert",
8945
+ "\\lVert": "\\rVert",
8946
+ "\\|": "\\|"
8947
+ };
8948
+ function isBareCommand(node, name) {
8949
+ return node instanceof CommandNode && node.name === name && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0;
8950
+ }
8951
+ function normalizeVerticalDelimiterCommands(chain) {
8952
+ const normalized = [];
8953
+ for (let index = 0; index < chain.chain.length; index += 1) {
8954
+ const left = chain.chain[index];
8955
+ if (!(left instanceof CommandNode) || left.superscript || left.subscript) {
8956
+ normalized.push(left);
8957
+ continue;
8958
+ }
8959
+ const rightName = VERTICAL_DELIMITER_COMMAND_PAIRS[left.name];
8960
+ if (!rightName || left.optionalArgs.length > 0 || left.mandatoryArgs.length > 0) {
8961
+ normalized.push(left);
8962
+ continue;
8963
+ }
8964
+ let rightIndex = -1;
8965
+ for (let candidate = index + 1; candidate < chain.chain.length; candidate += 1) {
8966
+ if (isBareCommand(chain.chain[candidate], rightName)) {
8967
+ rightIndex = candidate;
8968
+ break;
8969
+ }
8970
+ }
8971
+ if (rightIndex < 0) {
8972
+ normalized.push(left);
8973
+ continue;
8974
+ }
8975
+ const right = chain.chain[rightIndex];
8976
+ const delimiter = new DelimiterNode(
8977
+ left.name,
8978
+ new ChainNode(chain.chain.slice(index + 1, rightIndex)),
8979
+ right.name
8980
+ );
8981
+ delimiter.superscript = right.superscript;
8982
+ delimiter.subscript = right.subscript;
8983
+ normalized.push(delimiter);
8984
+ index = rightIndex;
8985
+ }
8986
+ return new ChainNode(normalized);
8987
+ }
8941
8988
  function chainToEditorChain(chain) {
8942
8989
  const nodes = [];
8943
- for (const astNode of chain.chain) {
8990
+ for (const astNode of normalizeVerticalDelimiterCommands(chain).chain) {
8944
8991
  const converted = astNodeToEditorNode(astNode);
8945
8992
  if (!converted.editable) {
8946
8993
  return converted;