@drghaliasri/butex 7.0.4 → 7.1.1

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.
@@ -1986,6 +1986,14 @@ var ATOMIC_COMMANDS = {
1986
1986
  arabicLabel: "\u0646\u0640\u0640\u0640\u0640\u0640\u0647\u0627",
1987
1987
  title: "\u062D\u062F"
1988
1988
  },
1989
+ arg: {
1990
+ id: "arg",
1991
+ category: "limits_series",
1992
+ englishTex: "\\arg",
1993
+ arabicTex: "\\ararg",
1994
+ arabicLabel: "\u062D\u062C",
1995
+ title: "\u062D\u062C\u0629"
1996
+ },
1989
1997
  max: {
1990
1998
  id: "max",
1991
1999
  category: "limits_series",
@@ -7073,6 +7081,104 @@ function applyDocument2Command(json, commandInput) {
7073
7081
  return toDocumentJson2(document2);
7074
7082
  }
7075
7083
 
7084
+ // src/document2/diff.ts
7085
+ import { diffJson } from "diff";
7086
+ var MAX_TOTAL_TEXT_CHARS = 16e3;
7087
+ var MAX_CHANGED_CHUNK_CHARS = 4e3;
7088
+ var MAX_CONTEXT_CHUNK_CHARS = 600;
7089
+ var TRUNCATION_MARKER = "\n\u2026\n";
7090
+ var IDENTITY_KEYS = /* @__PURE__ */ new Set(["id", "inline_ids", "caption_inline_ids", "cell_inline_ids"]);
7091
+ function comparisonValue(value, key) {
7092
+ if (key && IDENTITY_KEYS.has(key)) {
7093
+ return void 0;
7094
+ }
7095
+ if (Array.isArray(value)) {
7096
+ return value.map((entry) => comparisonValue(entry));
7097
+ }
7098
+ if (value && typeof value === "object") {
7099
+ const result = {};
7100
+ for (const childKey of Object.keys(value).sort()) {
7101
+ const child = comparisonValue(value[childKey], childKey);
7102
+ if (child !== void 0) {
7103
+ result[childKey] = child;
7104
+ }
7105
+ }
7106
+ return result;
7107
+ }
7108
+ return value;
7109
+ }
7110
+ function normalizedComparisonDocument(document2) {
7111
+ return comparisonValue(toDocumentJson2(fromDocumentJson2(document2)));
7112
+ }
7113
+ function withoutFinalNewline(value) {
7114
+ return value.endsWith("\n") ? value.slice(0, -1) : value;
7115
+ }
7116
+ function shorten(text, limit, mode) {
7117
+ if (text.length <= limit) {
7118
+ return { text, truncated: false };
7119
+ }
7120
+ if (limit <= TRUNCATION_MARKER.length) {
7121
+ return { text: text.slice(0, Math.max(0, limit)), truncated: true };
7122
+ }
7123
+ const available = limit - TRUNCATION_MARKER.length;
7124
+ if (mode === "head") {
7125
+ return { text: `${text.slice(0, available)}${TRUNCATION_MARKER}`, truncated: true };
7126
+ }
7127
+ if (mode === "tail") {
7128
+ return { text: `${TRUNCATION_MARKER}${text.slice(text.length - available)}`, truncated: true };
7129
+ }
7130
+ const head = Math.ceil(available / 2);
7131
+ const tail = available - head;
7132
+ return {
7133
+ text: `${text.slice(0, head)}${TRUNCATION_MARKER}${text.slice(text.length - tail)}`,
7134
+ truncated: true
7135
+ };
7136
+ }
7137
+ function diffDocument2(before, after) {
7138
+ const beforeComparable = normalizedComparisonDocument(before);
7139
+ const afterComparable = normalizedComparisonDocument(after);
7140
+ const parts = diffJson(beforeComparable, afterComparable);
7141
+ const changed = parts.some((part) => part.added === true || part.removed === true);
7142
+ if (!changed) {
7143
+ return { version: 1, changed: false, truncated: false, chunks: [] };
7144
+ }
7145
+ const chunks = [];
7146
+ let truncated = false;
7147
+ let totalTextChars = 0;
7148
+ const append = (kind, rawText, limit, mode) => {
7149
+ const cleaned = withoutFinalNewline(rawText);
7150
+ if (cleaned.length === 0) return;
7151
+ const perChunk = shorten(cleaned, limit, mode);
7152
+ truncated ||= perChunk.truncated;
7153
+ const remaining = MAX_TOTAL_TEXT_CHARS - totalTextChars;
7154
+ if (remaining <= 0) {
7155
+ truncated = true;
7156
+ return;
7157
+ }
7158
+ const withinBudget = shorten(perChunk.text, remaining, mode);
7159
+ truncated ||= withinBudget.truncated;
7160
+ if (withinBudget.text.length === 0) return;
7161
+ chunks.push({ kind, text: withinBudget.text });
7162
+ totalTextChars += withinBudget.text.length;
7163
+ };
7164
+ parts.forEach((part, index) => {
7165
+ if (part.added) {
7166
+ append("added", part.value, MAX_CHANGED_CHUNK_CHARS, "both");
7167
+ return;
7168
+ }
7169
+ if (part.removed) {
7170
+ append("removed", part.value, MAX_CHANGED_CHUNK_CHARS, "both");
7171
+ return;
7172
+ }
7173
+ const previousChanged = index > 0 && (parts[index - 1]?.added === true || parts[index - 1]?.removed === true);
7174
+ const nextChanged = index + 1 < parts.length && (parts[index + 1]?.added === true || parts[index + 1]?.removed === true);
7175
+ if (!previousChanged && !nextChanged) return;
7176
+ const mode = previousChanged && nextChanged ? "both" : previousChanged ? "head" : "tail";
7177
+ append("context", part.value, MAX_CONTEXT_CHUNK_CHARS, mode);
7178
+ });
7179
+ return { version: 1, changed: true, truncated, chunks };
7180
+ }
7181
+
7076
7182
  // src/document2/outline.ts
7077
7183
  var EXCERPT_LIMIT = 160;
7078
7184
  function normalizeExcerpt(value) {
@@ -7438,6 +7544,7 @@ ${fontCommands}
7438
7544
  \newcommand{\arprod}[0]{\text{جـــذ}}
7439
7545
 
7440
7546
  \newcommand{\arlim}[0]{\text{نـــــها}}
7547
+ \newcommand{\ararg}[0]{\text{حج}}
7441
7548
  \newcommand{\armax}[0]{\text{أكبر}}
7442
7549
  \newcommand{\armin}[0]{\text{أصغر}}
7443
7550
  \newcommand{\arsup}[0]{\text{أعلى}}
@@ -8404,6 +8511,7 @@ export {
8404
8511
  defaultFloatMeta,
8405
8512
  detectInlineSpans2,
8406
8513
  detectMathSpans2,
8514
+ diffDocument2,
8407
8515
  document2HasAbstract,
8408
8516
  document2HasMaketitle,
8409
8517
  document2HasTitleStack,